Skip to content

Commit

Permalink
feat(docker): skip assets install on permission error
Browse files Browse the repository at this point in the history
  • Loading branch information
bastienwirtz committed Nov 13, 2024
1 parent a40acb2 commit 3396257
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/bin/sh

PERMISSION_ERROR="Check assets directory permissions & docker user or skip default assets install by setting the INIT_ASSETS env var to 0"

# Default assets & exemple configuration installation if possible.
# Default assets & example configuration installation
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
if [[ -w "/www/assets/" ]];
then
while true; do echo n; done | cp -Ri /www/default-assets/* /www/assets/
yes n | cp -i /www/default-assets/config.yml.dist /www/assets/config.yml
else
echo "Assets directory not writable, skipping default config install.";
echo "Check assets directory permissions & docker user or skip default assets install by setting the INIT_ASSETS env var to 0."
fi
fi

echo "Starting webserver"
Expand Down

0 comments on commit 3396257

Please sign in to comment.