redesign around s6-overlay

This commit is contained in:
2023-05-27 13:43:46 +00:00
parent 056748f20c
commit 3f239e2527
18 changed files with 199 additions and 104 deletions

53
root/container-init.sh Normal file
View File

@ -0,0 +1,53 @@
#!/command/with-contenv bash
# shellcheck shell=bash
echo ""
echo ""
echo "================================================"
echo "| __ _______ __ ___________________ |"
echo "| / |/ / __ \/ |/ / ____/ ____/ __ ) |"
echo "| / /|_/ / /_/ / /|_/ / __/ / __/ / __ | |"
echo "| / / / / _, _/ / / / /___/ /___/ /_/ / |"
echo "| /_/ /_/_/ |_/_/ /_/_____/_____/_____/ |"
echo "| |"
echo "================================================"
echo ""
echo "Initialising container"
echo "
----------------------------------------------------------------------
ENVIRONMENT
----------------------------------------------------------------------
PUID=${PUID}
PGID=${PGID}
TZ=${TZ}
MODE=${MODE}
----------------------------------------------------------------------
"
#Setting UID and GID as configured
if [[ ! "${PUID}" -eq 0 ]] && [[ ! "${PGID}" -eq 0 ]]; then
echo "Executing usermod..."
mkdir "/tmp/temphome"
usermod -d "/tmp/temphome" mrmeeb
usermod -o -u "${PUID}" mrmeeb
usermod -d /config mrmeeb
rm -rf "/tmp/temphome"
groupmod -o -g "${PGID}" mrmeeb
else
echo "Running as root is not supported, please fix your PUID and PGID!"
exit 1
fi
echo "Checking permissions in /config and /app (this can take some time)."
if [ ! "$(stat -c %u /app)" -eq "${PUID}" ] || [ ! "$(stat -c %g /app)" -eq "${PGID}" ]
then
echo "Fixing permissions for /app."
chown -R mrmeeb:mrmeeb /app
fi
if [ ! "$(stat -c %u /config)" -eq "${PUID}" ] || [ ! "$(stat -c %g /config)" -eq "${PGID}" ]
then
echo "Fixing permissions for /config."
chown -R mrmeeb:mrmeeb /config
fi

107
root/cronicle-prepare.sh Normal file
View File

@ -0,0 +1,107 @@
#!/command/with-contenv bash
# shellcheck shell=bash
echo "Preparing Cronicle"
#Importing and running additional scripts placed in /config/init
if [ -d /config/init ]
then
if [ "$(ls -A /config/init)" ]
then
echo "Running additional startup scripts."
bash /config/init/*
else
echo "/config/init is empty - no additional startup scripts detected."
fi
else
echo "Directory /config/init not found. Creating."
mkdir /config/init
fi
if [ ! -d /config/cronicle ]
then
echo "Directory /config/cronicle not found. Creating."
mkdir /config/cronicle
fi
#Detecting what mode Cronicle should be started in
if [ $MODE == "manager" ]
then
echo "Cronicle is running in 'manager' mode."
#Copying config directory to /config/cronicle/conf if not already there, then linking back into Cronicle
if [ ! -d /config/cronicle/conf ]
then
cp -r /app/cronicle/conf /config/cronicle/conf
rm -rf /app/cronicle/conf
ln -s /config/cronicle/conf /app/cronicle/conf
fi
if [ ! -f /config/cronicle/data/.setup_done ]
then
echo "Setup needed - running now."
/app/cronicle/bin/control.sh setup
touch /app/cronicle/data/.setup_done
#Moving data dir to /config, then linking it back into Cronicle
mv -n /app/cronicle/data /config/cronicle/data
rm -rf /app/cronicle/data
ln -s /config/cronicle/data /app/cronicle/data
#exec node /app/cronicle/lib/main.js --color 1
else
echo "Setup already completed."
rm -rf /app/cronicle/data
ln -s /config/cronicle/data /app/cronicle/data
#exec node /app/cronicle/lib/main.js --color 1
fi
elif [ $MODE == "worker" ]
then
echo "Cronicle is running in 'worker' mode."
if [ ! -f /config/cronicle/conf/config.json ]
then
echo "No config found. Copy config.json from the manager server and place it in /config/cronicle/conf dir."
mkdir -p /config/cronicle/conf
exit 0
else
#Removing default config.json and linking provided one back into Cronicle
rm -rf /app/cronicle/conf/config.json
ln -s /config/config.json /app/cronicle/conf/config.json
#exec node /app/cronicle/lib/main.js --color 1
fi
else
echo "'$MODE' is not a recognised appion for the MODE environment variable. Accepted appions are 'manager' and 'worker'."
fi
#echo "Applying permissions to /config and /app (this can take a while on first run or after PUID/PGID changes)"
#chmod "=rwx" /config
#chown -R mrmeeb:mrmeeb /config
#chown -R mrmeeb:mrmeeb /app

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
/container-init.sh

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
exec s6-setuidgid mrmeeb /cronicle-prepare.sh

View File

@ -0,0 +1 @@
echo "$e" > /run/s6-linux-init-container-results/exitcode

View File

@ -0,0 +1,3 @@
#!/command/with-contenv bash
# shellcheck shell=bash
exec s6-setuidgid mrmeeb node /app/cronicle/lib/main.js --color 1

View File

@ -0,0 +1 @@
longrun