diff --git a/lgsm/functions/command_execute.sh b/lgsm/functions/command_execute.sh new file mode 100644 index 000000000..757aae69c --- /dev/null +++ b/lgsm/functions/command_execute.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# LGSM command_execute.sh function +# Author: Juhani Aronen +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Send message to server + +local modulename="Execute" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + +TMUX_BIN=tmux + +check.sh + +execute() +{ + $TMUX_BIN send -t ${servicename} "$*" "enter" + echo "Command executed: '$*'" +} diff --git a/lgsm/functions/command_restart_countdown.sh b/lgsm/functions/command_restart_countdown.sh new file mode 100644 index 000000000..7d114b7d0 --- /dev/null +++ b/lgsm/functions/command_restart_countdown.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# LGSM command_restart_countdown.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Restart's server with countdown + +local modulename="Restarting" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + +check.sh +command_execute.sh + +# checks if the server is already stopped before trying to stop. + + check_status.sh + if [ "${status}" == "0" ]; then + fn_print_ok_nl "${servername} is already stopped" + fn_scriptlog "${servername} is already stopped" + command_start.sh + exit + fi + +countdown(){ + +COUNTDOWN_TYPE=RESTART + + if [ "$1" != "fast" ] + then + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in 1 minute!" + sleep 30 + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in 30 seconds!" + sleep 20 + fi + + for SECONDS in 10 9 8 7 6 5 4 3 2 1 + do + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in $SECONDS seconds!" + sleep 1 + done +command_stop.sh +command_start.sh +} \ No newline at end of file diff --git a/lgsm/functions/command_shutdown.sh b/lgsm/functions/command_shutdown.sh new file mode 100644 index 000000000..7f4638b8a --- /dev/null +++ b/lgsm/functions/command_shutdown.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# LGSM command_shutdown.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Stop's the server with countdown +local modulename="Shutingdown" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + + +check.sh +command_execute.sh + +# checks if the server is already stopped before trying to stop. + + check_status.sh + if [ "${status}" == "0" ]; then + fn_print_ok_nl "${servername} is already stopped" + fn_scriptlog "${servername} is already stopped" + exit + fi + +shutdown(){ + +COUNTDOWN_TYPE=SHUTDOWN + + if [ "$1" != "fast" ] + then + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in 1 minute!" + sleep 30 + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in 30 seconds!" + sleep 20 + fi + + for SECONDS in 10 9 8 7 6 5 4 3 2 1 + do + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in $SECONDS seconds!" + sleep 1 + done +command_stop.sh +} \ No newline at end of file diff --git a/lgsm/functions/command_update_countdown.sh b/lgsm/functions/command_update_countdown.sh new file mode 100644 index 000000000..a13b86e36 --- /dev/null +++ b/lgsm/functions/command_update_countdown.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# LGSM command_update_countdown.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Updates's the server with countdown + +local modulename="Updating" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + + +check.sh +command_execute.sh + + +update_countdown_timer(){ + +COUNTDOWN_TYPE=UPDATE + + if [ "$1" != "fast" ] + then + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in 1 minute!" + sleep 30 + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in 30 seconds!" + sleep 20 + fi + + for SECONDS in 10 9 8 7 6 5 4 3 2 1 + do + execute "say WARNING!!! SERVER $COUNTDOWN_TYPE in $SECONDS seconds!" + sleep 1 + done + forceupdate=1; + update_check.sh +} \ No newline at end of file