mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add version inheretence & config check
Also add pretty colours
Also config check will always return true but meh 🤷♂️
If api key location changes it will be accurate
This commit is contained in:
parent
fff186e547
commit
c0006e47f4
@ -2,7 +2,7 @@
|
||||
|
||||
# Check if config exists taking one from image if needed.
|
||||
if [ ! "$(ls -A --ignore=.gitkeep ./app/config)" ]; then
|
||||
echo "Wrapper | 🏗️ Config not found, pulling defaults..."
|
||||
echo "\033[36mWrapper | \033[33m🏗️ Config not found, pulling defaults..."
|
||||
mkdir ./app/config/ 2> /dev/null
|
||||
cp -r ./app/config_original/* ./app/config/
|
||||
|
||||
@ -10,11 +10,24 @@ if [ ! "$(ls -A --ignore=.gitkeep ./app/config)" ]; then
|
||||
# We're running as root;
|
||||
# Look for files & dirs that require group permissions to be fixed
|
||||
# This will do the full /crafty dir, so will take a miniute.
|
||||
echo "Wrapper | 📋 Looking for problem bind mount permissions globally..."
|
||||
echo "\033[36mWrapper | \033[35m📋 Looking for problem bind mount permissions globally..."
|
||||
find . ! -group root -exec chgrp root {} \;
|
||||
find . ! -perm g+rw -exec chmod g+rw {} \;
|
||||
find . -type d ! -perm g+s -exec chmod g+s {} \;
|
||||
fi
|
||||
else
|
||||
# Keep version file up to date with image
|
||||
cp -f ./app/config_original/version.json ./app/config/version.json
|
||||
|
||||
# Compare if user's config is different from image, and show differences.
|
||||
echo "\033[36mWrapper | \033[35m🏗️ Checking for config.json changes..."
|
||||
cp -f ./app/config_original/config.json ./app/config/config_image_template
|
||||
if [ "$(diff -q ./app/config/config.json ./app/config/config_image_template)" ]; then
|
||||
echo "\033[36mWrapper | \033[33m👷 We've found differences in your local config, please review!,"
|
||||
echo "\033[36m | \033[33m (This could be an outdated config.json)"
|
||||
else
|
||||
echo "\033[36mWrapper | \033[32m✅ Config good! Proceeding..."
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@ -24,21 +37,21 @@ if [ $(id -u) -eq 0 ]; then
|
||||
# If we find files in import directory, we need to ensure all dirs are owned by the root group,
|
||||
# This fixes bind mounts that may have incorrect perms.
|
||||
if [ "$(ls -A --ignore=.gitkeep ./import)" ]; then
|
||||
echo "Wrapper | 📋 Files present in import, checking/fixing permissions..."
|
||||
echo "Wrapper | ⏳ Please be paitent for larger servers..."
|
||||
echo "\033[36mWrapper | \033[35m📋 Files present in import directory, checking/fixing permissions..."
|
||||
echo "\033[36mWrapper | \033[33m⏳ Please be paitent for larger servers..."
|
||||
find . ! -group root -exec chgrp root {} \;
|
||||
find . ! -perm g+rw -exec chmod g+rw {} \;
|
||||
find . -type d ! -perm g+s -exec chmod g+s {} \;
|
||||
echo "Wrapper | ✅ Permissions Fixed! (This will happen every boot until /import is empty!)"
|
||||
echo "\033[36mWrapper | \033[32m✅ Permissions Fixed! (This will happen every boot until /import is empty!)"
|
||||
fi
|
||||
|
||||
# Switch user, activate our prepared venv and lauch crafty
|
||||
args="$@"
|
||||
echo "Wrapper | 🚀 Launching crafty with [$args]"
|
||||
echo "\033[36mWrapper | \033[32m🚀 Launching crafty with [\033[34m$args\033[32m]"
|
||||
exec sudo -u crafty bash -c "source ./.venv/bin/activate && exec python3 main.py $args"
|
||||
else
|
||||
# Activate our prepared venv
|
||||
echo "Wrapper | 🚀 Non-root host detected, using normal exec"
|
||||
echo "\033[36mWrapper | \033[32m🚀 Non-root host detected, using normal exec"
|
||||
. ./.venv/bin/activate
|
||||
# Use exec as our perms are already correct
|
||||
# This is likely if using Kubernetes/OpenShift etc
|
||||
|
Loading…
Reference in New Issue
Block a user