Browse Source

Revert "Resshuffled code to better suite exitcodes"

This reverts commit 6deeb0a706.
pull/914/head
Daniel Gibbs 9 years ago
parent
commit
f9fe306ce6
  1. 155
      lgsm/functions/command_start.sh

155
lgsm/functions/command_start.sh

@ -72,94 +72,97 @@ 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"
else core_exit.sh
# Create lock file fi
date > "${rootdir}/${lockselfname}"
# Start session # Create lock file
cd "${executabledir}" date > "${rootdir}/${lockselfname}"
tmux new-session -d -s "${servicename}" "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp" cd "${executabledir}"
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
elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then # Console logging disabled: Bug in tmux 1.8 breaks logging
echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then
echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}"
echo "Currently installed: $(tmux -V)" >> "${consolelog}" echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}"
# Console logging enable or not set echo "Currently installed: $(tmux -V)" >> "${consolelog}"
elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then
touch "${consolelog}" # Console logging enable or not set
tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'" elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then
# Console logging disabled touch "${consolelog}"
elif [ "${consolelogging}" == "off" ]; then tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'"
touch "${consolelog}"
cat "Console logging disabled by user" >> "{consolelog}" # Console logging disabled
fn_script_log_info "Console logging disabled by user" elif [ "${consolelogging}" == "off" ]; then
fi touch "${consolelog}"
cat "Console logging disabled by user" >> "{consolelog}"
fn_script_log_info "Console logging disabled by user"
fi
sleep 1
# If the server fails to start
check_status.sh
if [ "${status}" == "0" ]; then
fn_print_fail_nl "Unable to start ${servername}"
fn_script_log_fatal "Unable to start ${servername}"
sleep 1 sleep 1
if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then
fn_print_fail_nl "Unable to start ${servername}: Tmux error:"
fn_script_log_fatal "Unable to start ${servername}: Tmux error:"
echo ""
echo "Command"
echo "================================="
echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" | tee -a "${scriptlog}"
echo ""
echo "Error"
echo "================================="
cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" | tee -a "${scriptlog}"
# Check if the server fails to start # Detected error https://gameservermanagers.com/issues
check_status.sh if [ $(grep -c "Operation not permitted" "${scriptlogdir}/.${servicename}-tmux-error.tmp") ]; then
if [ "${status}" == "0" ]; then echo ""
fn_print_fail_nl "Unable to start ${servername}" echo "Fix"
fn_script_log_fatal "Unable to start ${servername}" echo "================================="
sleep 1 if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then
if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then echo "$(whoami) is not part of the tty group."
fn_print_fail_nl "Unable to start ${servername}: Tmux error:" fn_script_log_info "$(whoami) is not part of the tty group."
fn_script_log_fatal "Unable to start ${servername}: Tmux error:" group=$(grep tty /etc/group)
echo "" echo ""
echo "Command" echo " ${group}"
echo "=================================" fn_script_log_info "${group}"
echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" | tee -a "${scriptlog}"
echo ""
echo "Error"
echo "================================="
cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" | tee -a "${scriptlog}"
# Detected error https://gameservermanagers.com/issues
if [ $(grep -c "Operation not permitted" "${scriptlogdir}/.${servicename}-tmux-error.tmp") ]; then
echo "" echo ""
echo "Fix" echo "Run the following command with root privileges."
echo "=================================" echo ""
if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then echo " usermod -G tty $(whoami)"
echo "$(whoami) is not part of the tty group." echo ""
fn_script_log_info "$(whoami) is not part of the tty group." echo "https://gameservermanagers.com/tmux-op-perm"
group=$(grep tty /etc/group) fn_script_log_info "https://gameservermanagers.com/tmux-op-perm"
echo "" else
echo " ${group}" echo "No known fix currently. Please log an issue."
fn_script_log_info "${group}" fn_script_log_info "No known fix currently. Please log an issue."
echo "" echo "https://gameservermanagers.com/issues"
echo "Run the following command with root privileges." fn_script_log_info "https://gameservermanagers.com/issues"
echo ""
echo " usermod -G tty $(whoami)"
echo ""
echo "https://gameservermanagers.com/tmux-op-perm"
fn_script_log_info "https://gameservermanagers.com/tmux-op-perm"
else
echo "No known fix currently. Please log an issue."
fn_script_log_info "No known fix currently. Please log an issue."
echo "https://gameservermanagers.com/issues"
fn_script_log_info "https://gameservermanagers.com/issues"
fi
fi fi
fi fi
else
fn_print_ok "${servername}"
fn_script_log_pass "Started ${servername}"
fi fi
rm "${scriptlogdir}/.${servicename}-tmux-error.tmp"
echo -en "\n" core_exit.sh
else
fn_print_ok "${servername}"
fn_script_log_pass "Started ${servername}"
fi fi
rm "${scriptlogdir}/.${servicename}-tmux-error.tmp"
echo -en "\n"
} }
check.sh check.sh

Loading…
Cancel
Save