This commit is contained in:
crowetic 2024-10-24 14:58:01 -07:00
parent 259824ddcd
commit 34cac086a5

View File

@ -11,12 +11,22 @@ log() {
# Check if screen is installed
if command -v screen &> /dev/null; then
log "Screen is installed, running script in a screen session..."
screen -S qortal_restart -dm bash -c "cd $QORTAL_DIR && ./$(basename "$0")"
log "Screen is installed, creating wrapper and running script in a screen session..."
# Wrapper script name and path
WRAPPER_SCRIPT="$QORTAL_DIR/start_qortal_wrapper.sh"
# Create a wrapper script to start the main script
echo "#!/bin/bash" > "$WRAPPER_SCRIPT"
echo "bash $(realpath "$0")" >> "$WRAPPER_SCRIPT"
chmod +x "$WRAPPER_SCRIPT"
# Run the wrapper script in screen
screen -S qortal_restart -dm bash -c "cd $QORTAL_DIR && ./start_qortal_wrapper.sh"
if [ $? -eq 0 ]; then
log "Script successfully started in screen session 'qortal_restart'."
log "Wrapper script successfully started in screen session 'qortal_restart'."
else
log "Failed to start script in screen session."
log "Failed to start wrapper script in screen session."
fi
exit 0
else