]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - entrypoint.sh
Simplify the container starting process to allow it to run with a
[github/bastienwirtz/homer.git] / entrypoint.sh
index e10e17e7d82d3f25cb11351d627844124da90364..eba1cb20ac3c39d79c92d35640cb36b10adcae24 100644 (file)
@@ -1,23 +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
-
-# Install default config if no one is available.
-yes n | cp -i /www/default-assets/config.yml.dist /www/assets/config.yml &> /dev/null
+# Default assets & exemple configuration installation if possible.
+if [[ "${INIT_ASSETS}" == "1" ]] && [[ ! -f "/www/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
 
-# Create symbolic link for hosting in subfolder.
-if [[ -n "${SUBFOLDER}" ]]; then
-  ln -s /www "/www/$SUBFOLDER"
-  chown -h $USER:$GROUP "/www/$SUBFOLDER"
+    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
-
 echo "Starting webserver"
 lighttpd -D -f /lighttpd.conf