Skip to content

Commit 73287fa

Browse files
HomerHomer
Homer
authored and
Homer
committed
added logic to control how .env is used
1 parent f3e9fb6 commit 73287fa

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

root/etc/cont-init.d/50-config

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,31 @@
33
# create our folders
44
mkdir -p \
55
/config/storage \
6-
/config/uploads
7-
8-
# make symlinks
9-
[[ ! -L /var/www/html/storage ]] && \
10-
ln -sf /config/storage /var/www/html/storage
11-
[[ ! -L /var/www/html/public/uploads ]] && \
12-
ln -sf /config/uploads /var/www/html/public/uploads
13-
[[ ! -e /config/.env ]] && \
14-
cp /defaults/.env /config/.env
15-
[[ ! -L /var/www/html/.env ]] && \
16-
ln -sf /config/.env /var/www/html/.env
17-
18-
for i in "${symlinks[@]}"
19-
do
20-
[[ -e "$i" && ! -L "$i" ]] && rm -rf "$i"
21-
[[ ! -L "$i" ]] && ln -s /config/www/"$(basename "$i")" "$i"
22-
done
6+
/config/public/uploads
7+
8+
# make folder symlinks
9+
symlinks=( \
10+
/var/www/html/storage \
11+
/var/www/html/public/uploads )
12+
13+
for i in "${symlinks[@]}"
14+
do
15+
[[ -e "$i" && ! -L "$i" ]] && rm -rf "$i"
16+
[[ ! -L "$i" ]] && ln -s /config/"$(basename "$i")" "$i"
17+
done
18+
19+
# check for ADVANCED_MODE to be != 0; copy sample env file to /config and ln to /var/www/html if != 0, if = 0 then copy .example.env to .env and run seds
20+
if [ "$ADVANCED_MODE" == 1 && ! -f "/config/.env" ];
21+
then
22+
echo "Advanced Mode"
23+
cp /var/www/html/.env.example /config/.env
24+
ln -s /config/.env /var/www/html/.env
25+
elif [ -z "$ADVANCED_MODE" ];
26+
echo "Basic Mode"
27+
cp /var/www/html/.env.example /var/www/html/.env
28+
else
29+
echo "Finished symlinks"
30+
fi
2331

2432
# Create API key if needed
2533
if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ]
@@ -36,7 +44,7 @@ sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /var/www/html/.env
3644
sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /var/www/html/.env
3745
sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /var/www/html/.env
3846
sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /var/www/html/.env
39-
sed - i "s/# APP_URL=http://bookstack.dev/APP_URL=${APP_URL}/g" /var/www/html/.env
47+
#sed -i "s/.*APP_URL=.*/APP_URL=${APP_URL}/g" /var/www/html/.env
4048

4149
# update database - will set up database if fresh, or, migrate existing
4250
php /var/www/html/artisan migrate --force

0 commit comments

Comments
 (0)