aboutsummaryrefslogtreecommitdiffhomepage
path: root/entrypoint.sh
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2022-04-10 11:55:11 +0200
committerBastien Wirtz <bastien.wirtz@gmail.com>2022-04-30 15:39:36 +0200
commit049f85221e945b90bf87d21afe4d306839d65740 (patch)
tree1288ab580f2a274df8b507e2bbe37e2ff03c70ca /entrypoint.sh
parentcd75da69f9e57c3fe0f63c3ed6def0577d75a47c (diff)
downloadhomer-049f85221e945b90bf87d21afe4d306839d65740.tar.gz
homer-049f85221e945b90bf87d21afe4d306839d65740.tar.zst
homer-049f85221e945b90bf87d21afe4d306839d65740.zip
Simplify the container starting process to allow it to run with a
unprivileged user
Diffstat (limited to 'entrypoint.sh')
-rw-r--r--entrypoint.sh25
1 files changed, 10 insertions, 15 deletions
diff --git a/entrypoint.sh b/entrypoint.sh
index e10e17e..eba1cb2 100644
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -1,23 +1,18 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Ensure default assets are present. 3PERMISSION_ERROR="Check assets directory permissions & docker user or skip default assets install by setting the INIT_ASSETS env var to 0"
4while true; do echo n; done | cp -Ri /www/default-assets/* /www/assets/ &> /dev/null
5 4
6# Ensure compatibility with previous version (config.yml was in the root directory) 5# Default assets & exemple configuration installation if possible.
7if [ -f "/www/config.yml" ]; then 6if [[ "${INIT_ASSETS}" == "1" ]] && [[ ! -f "/www/config.yml" ]]; then
8 yes n | cp -i /www/config.yml /www/assets/ &> /dev/null 7 echo "No configuration found, installing default config & assets"
9fi 8 if [[ ! -w "/www/assets/" ]]; then echo "Assets directory not writable. $PERMISSION_ERROR" && exit 1; fi
10 9
11# Install default config if no one is available. 10 while true; do echo n; done | cp -Ri /www/default-assets/* /www/assets/ &> /dev/null
12yes n | cp -i /www/default-assets/config.yml.dist /www/assets/config.yml &> /dev/null 11 if [[ $? -ne 0 ]]; then echo "Fail to copy default assets. $PERMISSION_ERROR" && exit 1; fi
13 12
14# Create symbolic link for hosting in subfolder. 13 yes n | cp -i /www/default-assets/config.yml.dist /www/assets/config.yml &> /dev/null
15if [[ -n "${SUBFOLDER}" ]]; then 14 if [[ $? -ne 0 ]]; then echo "Fail to copy default config file. $PERMISSION_ERROR" && exit 1; fi
16 ln -s /www "/www/$SUBFOLDER"
17 chown -h $USER:$GROUP "/www/$SUBFOLDER"
18fi 15fi
19 16
20chown -R $UID:$GID /www/assets
21
22echo "Starting webserver" 17echo "Starting webserver"
23lighttpd -D -f /lighttpd.conf 18lighttpd -D -f /lighttpd.conf