Skip to content

Commit

Permalink
Major cleaning of tmux handling
Browse files Browse the repository at this point in the history
- Improved tmux session listing
- Removed redundant checks
- Reorganized tests orders
- Added a missing space
  • Loading branch information
UltimateByte committed Apr 16, 2018
1 parent cddf624 commit 01919f2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 48 deletions.
2 changes: 1 addition & 1 deletion lgsm/functions/check_status.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ elif [ "${gamename}" == "Mumble" ]; then
status=1 status=1
fi fi
else else
status=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:") status=$(tmux list-sessions -F "#{session_name}" | grep -Ecx "^${servicename}")
fi fi
47 changes: 16 additions & 31 deletions lgsm/functions/command_start.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ fn_start_teamspeak3(){
touch "${servercfgfullpath}" touch "${servercfgfullpath}"
fi fi
sleep 0.5 sleep 0.5
check_status.sh
if [ "${status}" != "0" ]; then
fn_print_info_nl "${servername} is already running"
fn_script_log_error "${servername} is already running"
if [ -z "${exitbypass}" ]; then
core_exit.sh
fi
fi
if [ -f "${lgsmlog}" ]; then if [ -f "${lgsmlog}" ]; then
mv "${lgsmlog}" "${lgsmlogdate}" mv "${lgsmlog}" "${lgsmlogdate}"
fi fi
Expand Down Expand Up @@ -81,28 +73,15 @@ fn_start_tmux(){
fi fi


# Log rotation # Log rotation
check_status.sh fn_script_log_info "Rotating log files"
if [ "${status}" == "0" ]; then if [ "${engine}" == "unreal2" ]; then
fn_script_log_info "Rotating log files" if [ -f "${gamelog}" ]; then
if [ "${engine}" == "unreal2" ]; then mv "${gamelog}" "${gamelogdate}"
if [ -f "${gamelog}" ]; then
mv "${gamelog}" "${gamelogdate}"
fi
fi fi
mv "${lgsmlog}" "${lgsmlogdate}" mv "${lgsmlog}" "${lgsmlogdate}"
mv "${consolelog}" "${consolelogdate}" mv "${consolelog}" "${consolelogdate}"
fi fi


# If server is already running exit
check_status.sh
if [ "${status}" != "0" ]; then
fn_print_info_nl "${servername} is already running"
fn_script_log_error "${servername} is already running"
if [ -z "${exitbypass}" ]; then
core_exit.sh
fi
fi

# Create lockfile # Create lockfile
date > "${rootdir}/${lockselfname}" date > "${rootdir}/${lockselfname}"
cd "${executabledir}" cd "${executabledir}"
Expand Down Expand Up @@ -209,17 +188,23 @@ sleep 0.5
fn_print_dots "${servername}" fn_print_dots "${servername}"
sleep 0.5 sleep 0.5
check.sh check.sh
# Is the server already started
if [ "${status}" != "0" ]; then # $status comes from check_status.sh, which is run by check.sh for this command
fn_print_info_nl "${servername} is already running"
fn_script_log_error "${servername} is already running"
if [ -z "${exitbypass}" ]; then
core_exit.sh
fi
fi
fix.sh fix.sh
info_config.sh info_config.sh
logs.sh logs.sh


# Will check for updates is updateonstart is yes # Will check for updates is updateonstart is yes
if [ "${status}" == "0" ]; then if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then
if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then exitbypass=1
exitbypass=1 unset updateonstart
unset updateonstart command_update.sh
command_update.sh
fi
fi fi


if [ "${gamename}" == "TeamSpeak 3" ]; then if [ "${gamename}" == "TeamSpeak 3" ]; then
Expand Down
25 changes: 9 additions & 16 deletions lgsm/functions/command_stop.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -277,28 +277,21 @@ fn_stop_tmux(){
fn_print_ok_nl "${servername}" fn_print_ok_nl "${servername}"
fn_script_log_pass "Stopped ${servername}" fn_script_log_pass "Stopped ${servername}"
else else
fn_print_fail_nl "Unable to stop${servername}" fn_print_fail_nl "Unable to stop ${servername}"
fn_script_log_fatal "Unable to stop${servername}" fn_script_log_fatal "Unable to stop ${servername}"
fi fi
} }


# checks if the server is already stopped before trying to stop. # checks if the server is already stopped before trying to stop.
fn_stop_pre_check(){ fn_stop_pre_check(){
if [ "${gamename}" == "TeamSpeak 3" ]; then # Is the server already stopped
check_status.sh if [ "${status}" == "0" ]; then # $status comes from check_status.sh, which is run by check.sh for this command
if [ "${status}" == "0" ]; then fn_print_info_nl "${servername} is already stopped"
fn_print_info_nl "${servername} is already stopped" fn_script_log_error "${servername} is already stopped"
fn_script_log_error "${servername} is already stopped" elif [ "${gamename}" == "TeamSpeak 3" ]; then
else fn_stop_teamspeak3
fn_stop_teamspeak3
fi
else else
if [ "${status}" == "0" ]; then fn_stop_graceful_select
fn_print_info_nl "${servername} is already stopped"
fn_script_log_error "${servername} is already stopped"
else
fn_stop_graceful_select
fi
fi fi
} }


Expand Down

0 comments on commit 01919f2

Please sign in to comment.