X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=entrypoint.sh;h=e970d34c93945dd113ca69c88db4b72e63d908b0;hb=f160caecfaafb53404a06dd528cd21df65e49b82;hp=f1a8c229a38159d660f157d4ac089c2c7575cbd7;hpb=db738288fa7c99a3d5aa47f35a634297c7b1f506;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/entrypoint.sh b/entrypoint.sh index f1a8c22..e970d34 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,15 +1,18 @@ #!/bin/sh -# Ensure default assets are present. -while true; do echo n; done | cp -Ri /www/default-assets/* /www/assets/ &> /dev/null +PERMISSION_ERROR="Check assets directory permissions & docker user or skip default assets install by setting the INIT_ASSETS env var to 0" -# Ensure compatibility with previous version (config.yml was in the root directory) -if [ -f "/www/config.yml" ]; then - yes n | cp -i /www/config.yml /www/assets/ &> /dev/null -fi +# Default assets & exemple configuration installation if possible. +if [[ "${INIT_ASSETS}" == "1" ]] && [[ ! -f "/www/assets/config.yml" ]]; then + echo "No configuration found, installing default config & assets" + if [[ ! -w "/www/assets/" ]]; then echo "Assets directory not writable. $PERMISSION_ERROR" && exit 1; fi + + while true; do echo n; done | cp -Ri /www/default-assets/* /www/assets/ &> /dev/null + if [[ $? -ne 0 ]]; then echo "Fail to copy default assets. $PERMISSION_ERROR" && exit 1; fi -# Install default config if no one is available. -yes n | cp -i /www/default-assets/config.yml.dist /www/assets/config.yml &> /dev/null + yes n | cp -i /www/default-assets/config.yml.dist /www/assets/config.yml &> /dev/null + if [[ $? -ne 0 ]]; then echo "Fail to copy default config file. $PERMISSION_ERROR" && exit 1; fi +fi -chown -R $UID:$GID /www/assets -exec su-exec $UID:$GID darkhttpd /www/ --no-listing --port "$PORT" +echo "Starting webserver" +exec lighttpd -D -f /lighttpd.conf