2021-01-25 13:36:16 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# forward request and error logs to docker log collector
|
|
|
|
ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log && \
|
|
|
|
ln -sf /dev/stdout /var/log/nginx/mediacms.io.access.log && ln -sf /dev/stderr /var/log/nginx/mediacms.io.error.log
|
2021-03-22 19:04:12 +01:00
|
|
|
|
2021-01-25 13:36:16 +01:00
|
|
|
cp /home/mediacms.io/mediacms/deploy/docker/local_settings.py /home/mediacms.io/mediacms/cms/local_settings.py
|
|
|
|
|
2021-06-18 14:39:52 +02:00
|
|
|
mkdir -p /home/mediacms.io/mediacms/{logs,media_files/hls}
|
2021-01-25 13:36:16 +01:00
|
|
|
touch /home/mediacms.io/mediacms/logs/debug.log
|
|
|
|
|
2021-06-18 14:39:52 +02:00
|
|
|
mkdir -p /var/run/mediacms
|
|
|
|
chown www-data:www-data /var/run/mediacms
|
2021-02-18 20:25:40 +01:00
|
|
|
|
2021-01-25 13:36:16 +01:00
|
|
|
TARGET_GID=$(stat -c "%g" /home/mediacms.io/mediacms/)
|
|
|
|
|
|
|
|
EXISTS=$(cat /etc/group | grep $TARGET_GID | wc -l)
|
|
|
|
|
|
|
|
# Create new group using target GID and add www-data user
|
|
|
|
if [ $EXISTS == "0" ]; then
|
|
|
|
groupadd -g $TARGET_GID tempgroup
|
|
|
|
usermod -a -G tempgroup www-data
|
|
|
|
else
|
|
|
|
# GID exists, find group name and add
|
|
|
|
GROUP=$(getent group $TARGET_GID | cut -d: -f1)
|
|
|
|
usermod -a -G $GROUP www-data
|
|
|
|
fi
|
|
|
|
|
2021-03-22 19:04:12 +01:00
|
|
|
# We should do this only for folders that have a different owner, since it is an expensive operation
|
2024-09-20 11:53:56 +02:00
|
|
|
# Also ignoring .git folder to fix this issue https://github.com/mediacms-io/mediacms/issues/934
|
2024-09-20 12:02:00 +02:00
|
|
|
find /home/mediacms.io/mediacms ! \( -path "*.git*" \) -exec chown www-data:$TARGET_GID {} +
|
2021-03-22 19:04:12 +01:00
|
|
|
|
2021-01-25 13:36:16 +01:00
|
|
|
chmod +x /home/mediacms.io/mediacms/deploy/docker/start.sh /home/mediacms.io/mediacms/deploy/docker/prestart.sh
|
|
|
|
|
2021-01-29 19:38:35 +01:00
|
|
|
exec "$@"
|