forked from leftypol/leftypol
docker: boostrap script handle secrets.php, copy static files
This commit is contained in:
parent
4edb0b5563
commit
1682352b66
1 changed files with 26 additions and 18 deletions
|
@ -2,6 +2,19 @@
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
function set_cfg() {
|
||||||
|
if [ -L "/var/www/inc/$1" ]; then
|
||||||
|
echo "INFO: Resetting $1"
|
||||||
|
rm "/var/www/inc/$1"
|
||||||
|
cp "/code/inc/$1" "/var/www/inc/$1"
|
||||||
|
chown www-data "/var/www/inc/$1"
|
||||||
|
chgrp www-data "/var/www/inc/$1"
|
||||||
|
chmod 600 "/var/www/inc/$1"
|
||||||
|
else
|
||||||
|
echo "INFO: Using existing $1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if ! mountpoint -q /var/www; then
|
if ! mountpoint -q /var/www; then
|
||||||
echo "WARNING: '/var/www' is not a mountpoint. All the data will remain inside the container!"
|
echo "WARNING: '/var/www' is not a mountpoint. All the data will remain inside the container!"
|
||||||
fi
|
fi
|
||||||
|
@ -14,8 +27,6 @@ fi
|
||||||
# Link the entrypoints from the exposed directory.
|
# Link the entrypoints from the exposed directory.
|
||||||
ln -nfs \
|
ln -nfs \
|
||||||
/code/banners/ \
|
/code/banners/ \
|
||||||
/code/static/ \
|
|
||||||
/code/stylesheets/ \
|
|
||||||
/code/tools/ \
|
/code/tools/ \
|
||||||
/code/walls/ \
|
/code/walls/ \
|
||||||
/code/*.php \
|
/code/*.php \
|
||||||
|
@ -23,6 +34,10 @@ ln -nfs \
|
||||||
/code/404.html \
|
/code/404.html \
|
||||||
/code/install.sql \
|
/code/install.sql \
|
||||||
/var/www/
|
/var/www/
|
||||||
|
# Static files accessible from the webserver must be copied.
|
||||||
|
cp -ur /code/static /var/www/
|
||||||
|
cp -ur /code/stylesheets /var/www/
|
||||||
|
|
||||||
# Ensure correct permissions are set, since this might be bind mount.
|
# Ensure correct permissions are set, since this might be bind mount.
|
||||||
chown www-data /var/www
|
chown www-data /var/www
|
||||||
chgrp www-data /var/www
|
chgrp www-data /var/www
|
||||||
|
@ -30,13 +45,8 @@ chgrp www-data /var/www
|
||||||
# Initialize an empty robots.txt with the default if it doesn't exist.
|
# Initialize an empty robots.txt with the default if it doesn't exist.
|
||||||
touch /var/www/robots.txt
|
touch /var/www/robots.txt
|
||||||
|
|
||||||
# Initialize an empty writable secrests.php with the default if it doesn't exist.
|
|
||||||
touch /var/www/inc/secrets.php
|
|
||||||
chown www-data /var/www/inc/secrets.php
|
|
||||||
chgrp www-data /var/www/inc/secrets.php
|
|
||||||
|
|
||||||
# Link the cache and tmp files directory.
|
# Link the cache and tmp files directory.
|
||||||
ln -nfs /var/tmp/leftypol /var/www/tmp
|
ln -nfs /var/tmp/vichan /var/www/tmp
|
||||||
|
|
||||||
# Link the javascript directory.
|
# Link the javascript directory.
|
||||||
ln -nfs /code/js /var/www/
|
ln -nfs /code/js /var/www/
|
||||||
|
@ -60,17 +70,15 @@ for file in /code/inc/*; do
|
||||||
ln -s /code/inc/$file /var/www/inc/
|
ln -s /code/inc/$file /var/www/inc/
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Copy an empty instance configuration if the file is a link (it was linked because it did not exist before).
|
# Copy an empty instance configuration if the file is a link (it was linked because it did not exist before).
|
||||||
if [ -L '/var/www/inc/instance-config.php' ]; then
|
set_cfg 'instance-config.php'
|
||||||
echo 'INFO: Resetting instance configuration'
|
set_cfg 'secrets.php'
|
||||||
rm /var/www/inc/instance-config.php
|
|
||||||
cp /code/inc/instance-config.php /var/www/inc/instance-config.php
|
# Initialize an empty writable secrests.php with the default if it doesn't exist.
|
||||||
chown www-data /var/www/inc/instance-config.php
|
#touch /var/www/inc/secrets.php
|
||||||
chgrp www-data /var/www/inc/instance-config.php
|
#chown www-data /var/www/inc/secrets.php
|
||||||
chmod 600 /var/www/inc/instance-config.php
|
#chgrp www-data /var/www/inc/secrets.php
|
||||||
else
|
|
||||||
echo 'INFO: Using existing instance configuration'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Link the composer dependencies.
|
# Link the composer dependencies.
|
||||||
ln -nfs /code/vendor /var/www/
|
ln -nfs /code/vendor /var/www/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue