mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dev' into 'master'
Pre Release Fixes- 11/06/22 See merge request crafty-controller/crafty-4!311
This commit is contained in:
commit
bf7bdb17a5
@ -14,6 +14,7 @@ import tempfile
|
|||||||
# TZLocal is set as a hidden import on win pipeline
|
# TZLocal is set as a hidden import on win pipeline
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
|
from apscheduler.jobstores.base import JobLookupError
|
||||||
|
|
||||||
from app.classes.minecraft.stats import Stats
|
from app.classes.minecraft.stats import Stats
|
||||||
from app.classes.minecraft.mc_ping import ping, ping_bedrock
|
from app.classes.minecraft.mc_ping import ping, ping_bedrock
|
||||||
@ -592,9 +593,14 @@ class ServerInstance:
|
|||||||
self.cleanup_server_object()
|
self.cleanup_server_object()
|
||||||
server_users = PermissionsServers.get_server_user_list(self.server_id)
|
server_users = PermissionsServers.get_server_user_list(self.server_id)
|
||||||
|
|
||||||
# remove the stats polling job since server is stopped
|
try:
|
||||||
self.server_scheduler.remove_job("stats_" + str(self.server_id))
|
# remove the stats polling job since server is stopped
|
||||||
|
self.server_scheduler.remove_job("stats_" + str(self.server_id))
|
||||||
|
except JobLookupError as e:
|
||||||
|
logger.error(
|
||||||
|
f"Could not remove job with id stats_{self.server_id} due"
|
||||||
|
+ f" to error: {e}"
|
||||||
|
)
|
||||||
self.record_server_stats()
|
self.record_server_stats()
|
||||||
|
|
||||||
for user in server_users:
|
for user in server_users:
|
||||||
@ -687,7 +693,13 @@ class ServerInstance:
|
|||||||
proc.kill()
|
proc.kill()
|
||||||
# kill the main process we are after
|
# kill the main process we are after
|
||||||
logger.info("Sending SIGKILL to parent")
|
logger.info("Sending SIGKILL to parent")
|
||||||
self.server_scheduler.remove_job("stats_" + str(self.server_id))
|
try:
|
||||||
|
self.server_scheduler.remove_job("stats_" + str(self.server_id))
|
||||||
|
except JobLookupError as e:
|
||||||
|
logger.error(
|
||||||
|
f"Could not remove job with id stats_{self.server_id} due"
|
||||||
|
+ f" to error: {e}"
|
||||||
|
)
|
||||||
self.process.kill()
|
self.process.kill()
|
||||||
|
|
||||||
def get_start_time(self):
|
def get_start_time(self):
|
||||||
|
@ -1,31 +1,44 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Check if config exists from existing installation (venv or previous docker launch)
|
# Check if config exists taking one from image if needed.
|
||||||
if [ ! "$(ls -A --ignore=.gitkeep ./app/config)" ]; then
|
if [ ! "$(ls -A --ignore=.gitkeep ./app/config)" ]; then
|
||||||
echo "Wrapper | Config not found, pulling defaults..."
|
echo "Wrapper | 🏗️ Config not found, pulling defaults..."
|
||||||
mkdir ./app/config/ 2> /dev/null
|
mkdir ./app/config/ 2> /dev/null
|
||||||
cp -r ./app/config_original/* ./app/config/
|
cp -r ./app/config_original/* ./app/config/
|
||||||
|
|
||||||
|
if [ $(id -u) -eq 0 ]; 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..."
|
||||||
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ $(id -u) -eq 0 ]; then
|
if [ $(id -u) -eq 0 ]; then
|
||||||
# We're running as root;
|
# We're running as root
|
||||||
# Need to ensure all dirs are owned by the root group,
|
|
||||||
# This fixes bind mounts that may have incorrect perms.
|
|
||||||
|
|
||||||
# Look for files & dirs that require group permissions to be fixed
|
# If we find files in import directory, we need to ensure all dirs are owned by the root group,
|
||||||
echo "Wrapper | Looking for problem bind mount permissions"
|
# This fixes bind mounts that may have incorrect perms.
|
||||||
find . ! -group root -exec chgrp root {} \;
|
if [ ! "$(ls -A --ignore=.gitkeep ./app/import)" ]; then
|
||||||
find . ! -perm g+rw -exec chmod g+rw {} \;
|
echo "Wrapper | 📋 Files present in import, checking/fixing permissions..."
|
||||||
find . -type d ! -perm g+s -exec chmod g+s {} \;
|
echo "Wrapper | ⏳ 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!)"
|
||||||
|
fi
|
||||||
|
|
||||||
# Switch user, activate our prepared venv and lauch crafty
|
# Switch user, activate our prepared venv and lauch crafty
|
||||||
args="$@"
|
args="$@"
|
||||||
echo "Wrapper | Launching crafty with [$args]"
|
echo "Wrapper | 🚀 Launching crafty with [$args]"
|
||||||
exec sudo -u crafty bash -c "source ./.venv/bin/activate && exec python3 main.py $args"
|
exec sudo -u crafty bash -c "source ./.venv/bin/activate && exec python3 main.py $args"
|
||||||
else
|
else
|
||||||
# Activate our prepared venv
|
# Activate our prepared venv
|
||||||
echo "Wrapper | Non-root host detected, using normal exec"
|
echo "Wrapper | 🚀 Non-root host detected, using normal exec"
|
||||||
. ./.venv/bin/activate
|
. ./.venv/bin/activate
|
||||||
# Use exec as our perms are already correct
|
# Use exec as our perms are already correct
|
||||||
# This is likely if using Kubernetes/OpenShift etc
|
# This is likely if using Kubernetes/OpenShift etc
|
||||||
|
Loading…
Reference in New Issue
Block a user