-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker-entrypoint
executable file
·44 lines (34 loc) · 1.27 KB
/
docker-entrypoint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copy configuration template
echo "$1"
mkdir -p /gitea/data/gitea/conf/
if [ ! -e /gitea/data/gitea/conf/app.ini ]; then
cp /tmp/app.ini /gitea/data/gitea/conf/app.ini
fi
# Create git directory
if [ ! -e /data/git ]; then
mkdir -p /gitea/data/git
fi
# Generate secret key
generate_secret_key=$(grep SECRET_KEY /gitea/data/gitea/conf/app.ini | grep generate | wc -l)
if [ "$generate_secret_key" = "1" ]; then
secret_key=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9_' | fold -w 10 | head -n 1)
sed -i "s/^SECRET_KEY.*$/SECRET_KEY = ${secret_key}/" /gitea/data/gitea/conf/app.ini
fi
# Generate lfs jwt secret
generate_lfs_jwt_secret=$(grep LFS_JWT_SECRET /gitea/data/gitea/conf/app.ini | grep generate | wc -l)
if [ "$generate_lfs_jwt_secret" = "1" ]; then
lfs_jwt_secret=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9_' | fold -w 43 | head -n 1)
sed -i "s/^LFS_JWT_SECRET.*$/LFS_JWT_SECRET = ${lfs_jwt_secret}/" /gitea/data/gitea/conf/app.ini
fi
# Update root url
if [ ! -z $GITEA_HOSTNAME ]; then
if [ ! -z $PROTOCOL ]; then
PROTOCOL="http"
fi
sed -i "s,^ROOT_URL.*$,ROOT_URL = ${PROTOCOL}://${GITEA_HOSTNAME}," /data/gitea/conf/app.ini
fi
# Run gitea
cd /gitea/data/gitea
echo "Starting Gitea"
ls -l /opt/app/gitea/gitea
/opt/app/gitea/gitea web