Files
docker-heimdall/root/etc/cont-init.d/50-config
2022-11-24 23:11:37 +00:00

62 lines
1.9 KiB
Plaintext

#!/usr/bin/with-contenv bash
# shellcheck shell=bash
# make our folders
mkdir -p \
/config/www/{avatars,backgrounds,icons,logs,SupportedApps} \
/app/www \
/config/log/heimdall
# install heimdall if necessary
if [[ -f /heimdall/heimdall.tar.gz ]]; then
echo "New container detected, installing Heimdall"
tar xf \
/heimdall/heimdall.tar.gz -C \
/app/www --strip-components=1
echo -e '\n# Heimdall user authorization\nfastcgi_param PHP_AUTH_USER $remote_user;\nfastcgi_param PHP_AUTH_PW $http_authorization;' >> \
/etc/nginx/fastcgi_params
rm -rf /heimdall
cp /app/www/storage/app/searchproviders.yaml /app/www/storage/app/searchproviders.yaml.orig
chown -R abc:abc /app/www
fi
# create symlinks
symlinks=(
/app/www/storage/app/public/avatars
/app/www/storage/app/public/backgrounds
/app/www/storage/app/public/icons
/app/www/storage/logs
/app/www/app/SupportedApps
/app/www/database/app.sqlite
/app/www/.env
)
for i in "${symlinks[@]}"; do
if [[ -e "${i}" && ! -L "${i}" ]]; then
rm -rf "${i}"
fi
if [[ ! -L "${i}" ]]; then
ln -s /config/www/"$(basename "${i}")" "${i}"
fi
done
# copy .env if not exists
if [[ ! -f /config/www/.env ]]; then
cp /app/www/.env.example /config/www/.env
echo "Creating app key. This may take a while on slower systems"
php /app/www/artisan key:generate
fi
# copy searchproviders if not exists and symlink
if [[ ! -f /config/www/searchproviders.yaml ]]; then
cp /app/www/storage/app/searchproviders.yaml.orig /config/www/searchproviders.yaml
fi
rm -rf /app/www/storage/app/searchproviders.yaml
ln -s /config/www/searchproviders.yaml /app/www/storage/app/searchproviders.yaml
# set queue driver to database
sed -i 's/QUEUE_DRIVER=sync/QUEUE_DRIVER=database/' /config/www/.env
# permissions
echo "Setting permissions"
chown -R abc:abc \
/config