]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - entrypoint.sh
Merge pull request #485 from Tooa/fix-healthchecks-service-name
[github/bastienwirtz/homer.git] / entrypoint.sh
index 7623322067fdf874375a9bee0cb77d7eb229a44f..48df1e6fb0371736b1de622b61021c212a8e71f5 100644 (file)
@@ -1,6 +1,18 @@
 #!/bin/sh
 
-yes n | cp -i /www/config.yml.dist /www/config.yml
-while true; do echo n; done | cp -Ri /app/dist/www/assets /www/assets 2>/dev/null
+PERMISSION_ERROR="Check assets directory permissions & docker user or skip default assets install by setting the INIT_ASSETS env var to 0"
 
-darkhttpd /www/ --no-listing --port $PORT
+# 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
+
+    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
+
+echo "Starting webserver"
+lighttpd -D -f /lighttpd.conf