Browse Source

Resshuffled code to better suite exitcodes

pull/914/head
Daniel Gibbs 9 years ago
parent
commit
6deeb0a706
  1. 17
      lgsm/functions/command_start.sh

17
lgsm/functions/command_start.sh

@ -74,36 +74,34 @@ fn_start_tmux(){
mv "${consolelog}" "${consolelogdate}" mv "${consolelog}" "${consolelogdate}"
fi fi
# If server is already running exit
check_status.sh check_status.sh
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
# If server is already running exit
fn_print_info_nl "${servername} is already running" fn_print_info_nl "${servername} is already running"
fn_script_log_error "${servername} is already running" fn_script_log_error "${servername} is already running"
core_exit.sh else
fi
# Create lock file # Create lock file
date > "${rootdir}/${lockselfname}" date > "${rootdir}/${lockselfname}"
# Start session
cd "${executabledir}" cd "${executabledir}"
tmux new-session -d -s "${servicename}" "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp" tmux new-session -d -s "${servicename}" "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp"
## Console logging
# tmux pipe-pane not supported in tmux versions < 1.6 # tmux pipe-pane not supported in tmux versions < 1.6
if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then
echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}" echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}"
echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}"
echo "Currently installed: $(tmux -V)" >> "${consolelog}" echo "Currently installed: $(tmux -V)" >> "${consolelog}"
# Console logging disabled: Bug in tmux 1.8 breaks logging # Console logging disabled: Bug in tmux 1.8 breaks logging
elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then
echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}"
echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}"
echo "Currently installed: $(tmux -V)" >> "${consolelog}" echo "Currently installed: $(tmux -V)" >> "${consolelog}"
# Console logging enable or not set # Console logging enable or not set
elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then
touch "${consolelog}" touch "${consolelog}"
tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'" tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'"
# Console logging disabled # Console logging disabled
elif [ "${consolelogging}" == "off" ]; then elif [ "${consolelogging}" == "off" ]; then
touch "${consolelog}" touch "${consolelog}"
@ -112,7 +110,7 @@ fn_start_tmux(){
fi fi
sleep 1 sleep 1
# If the server fails to start # Check if the server fails to start
check_status.sh check_status.sh
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
fn_print_fail_nl "Unable to start ${servername}" fn_print_fail_nl "Unable to start ${servername}"
@ -157,14 +155,13 @@ fn_start_tmux(){
fi fi
fi fi
fi fi
core_exit.sh
else else
fn_print_ok "${servername}" fn_print_ok "${servername}"
fn_script_log_pass "Started ${servername}" fn_script_log_pass "Started ${servername}"
fi fi
rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" rm "${scriptlogdir}/.${servicename}-tmux-error.tmp"
echo -en "\n" echo -en "\n"
fi
} }
check.sh check.sh

Loading…
Cancel
Save