Use just code-server. May use full code for web UI in the future (see supervisord.conf)

This commit is contained in:
2024-11-15 02:04:17 +01:00
parent c2ba9c4aa3
commit a67dc17751
3 changed files with 115 additions and 15 deletions

51
entrypoint.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
set -e
CODE_UUID="${BACKUPPC_UUID:-1001}"
CODE_GUID="${BACKUPPC_GUID:-1001}"
CODE_USERNAME=$(getent passwd "$CODE_UUID" | cut -d: -f1)
CODE_GROUPNAME=$(getent group "$CODE_GUID" | cut -d: -f1)
if [ -f /firstrun ]; then
echo 'First run of the container. Code will be configured.'
echo 'If exist, configuration and data will be reused and upgraded as needed.'
# Configure timezone if needed
if [ -n "$TZ" ]; then
cp /usr/share/zoneinfo/$TZ /etc/localtime
fi
# Create code user/group if needed
if [ -z "$CODE_GROUPNAME" ]; then
groupadd -r -g "$CODE_GUID" code
CODE_GROUPNAME="code"
fi
if [ -z "$CODE_USERNAME" ]; then
if [ "$CODE_PASSWORD" ] && [ "$CODE_PASSWORD_FILE" ]; then
echo 'error: both CODE_PASSWORD and CODE_PASSWORD_FILE are set (but are exclusive)\n'
exit 1
fi
password=""
if [ "$CODE_PASSWORD" ]; then
password="$CODE_PASSWORD"
elif [ "$CODE_PASSWORD_FILE" ]; then
password="$(< ${CODE_PASSWORD_FILE})"
fi
useradd -r -d /home/code -s /bin/bash -g "$CODE_GUID" -u "$CODE_UUID" -M -N code
echo "code:$password" | chpasswd
CODE_USERNAME="code"
else
usermod -d /home/code "$CODE_USERNAME"
fi
chown "$CODE_USERNAME":"$CODE_GROUPNAME" /home/code
# Clean
rm -rf /firstrun
fi
export CODE_USERNAME
cd /home/code
exec "$@"