Просмотр исходного кода

More alterations for exitcodes

Daniel Gibbs 10 лет назад
Родитель
Сommit
b077588f36

+ 1 - 2
lgsm/functions/check_ip.sh

@@ -18,8 +18,7 @@ if [ "${gamename}" != "Teamspeak 3" ]; then
 
 	if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
 		if [ "${getipwc}" -ge "2" ]; then
-			fn_print_fatal "Multiple active network interfaces found.\n\n"
-			fn_script_log_fatal "Multiple active network interfaces found."
+			fn_print_fail "Multiple active network interfaces found.\n\n"
 			echo -en "Manually specify the IP you want to use within the ${selfname} script.\n"
 			echo -en "Set ip=\"0.0.0.0\" to one of the following:\n"
 			echo -en "${getip}\n"

+ 1 - 1
lgsm/functions/check_root.sh

@@ -7,7 +7,7 @@ lgsm_version="210516"
 if [ $(whoami) = "root" ]; then
 	fn_print_fail_nl "Do NOT run this script as root!"
 	if [ -d "${scriptlogdir}" ]; then
-		fn_scriptlog "${selfname} attempted to run as root."
+		fn_scriptlog_fatal "${selfname} attempted to run as root."
 	fi
 	exit 1
 fi

+ 5 - 5
lgsm/functions/check_steamcmd.sh

@@ -20,18 +20,18 @@ fn_install_steamcmd(){
 fn_check_steamcmd_user(){
 	# Checks steamuser is setup.
 	if [ "${steamuser}" == "username" ]; then
-		fn_print_fail_nl "Steam login not set. Update steamuser."
+		fn_print_fail_nl "Steam login not set. Update steamuser in ${selfname}."
 		echo "	* Change steamuser=\"username\" to a valid steam login."
 		if [ -d "${scriptlogdir}" ]; then
-			fn_script_log "edit ${selfname}. change steamuser=\"username\" to a valid steam login."
-			exit 1
+			fn_script_log_fatal "Steam login not set. Update steamuser in ${selfname}."
 		fi
+		core_exit.sh
 	fi
 	# Anonymous user is set if steamuser is missing
 	if [ -z "${steamuser}" ]; then
 		fn_print_warn_nl "Steam login not set. Using anonymous login."
 		if [ -d "${scriptlogdir}" ]; then
-			fn_script_log "Steam login not set. Using anonymous login."
+			fn_script_log_error "Steam login not set. Using anonymous login."
 		fi
 		steamuser="anonymous"
 		steampass=""
@@ -48,7 +48,7 @@ fn_check_steamcmd_sh(){
 			fn_install_steamcmd
 		else
 			fn_print_warn_nl "SteamCMD is missing"
-			fn_script_log "SteamCMD is missing"
+			fn_script_log_warn "SteamCMD is missing"
 			sleep 1
 			fn_install_steamcmd
 		fi

+ 3 - 2
lgsm/functions/check_system_dir.sh

@@ -7,7 +7,8 @@ lgsm_version="210516"
 if [ ! -d "${systemdir}" ]; then
 	fn_print_fail_nl "Cannot access ${systemdir}: No such directory"
 	if [ -d "${scriptlogdir}" ]; then
-		fn_script_log "Cannot access ${systemdir}: No such directory."
+		fn_script_log_failure "Cannot access ${systemdir}: No such directory."
 	fi
-	exit 1
+	exitcode=1
+	core_exit.sh
 fi

+ 2 - 2
lgsm/functions/check_tmux.sh

@@ -11,10 +11,10 @@ if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin
 else
 	fn_print_fail_nl "Tmux not installed"
 	sleep 1
-	fn_script_log "Tmux is not installed"
+	fn_script_log_fatal "Tmux is not installed"
 	echo "	* Tmux is required to run this server."
 	# Suitable passive agressive message
 	echo "	* Please see the the following link."
 	echo "	* https://gameservermanagers.com/tmux-not-found"
-	exit 127
+	core_exit.sh
 fi

+ 3 - 3
lgsm/functions/command_debug.sh

@@ -55,10 +55,9 @@ fn_script_log_info "Stopping any running servers"
 sleep 1
 command_stop.sh
 fn_print_dots "Starting debug"
-fn_script_log "Starting debug"
+fn_script_log_info "Starting debug"
 sleep 1
 fn_print_ok_nl "Starting debug"
-fn_script_log "Started debug"
 
 # create lock file.
 date > "${rootdir}/${lockselfname}"
@@ -73,4 +72,5 @@ else
 fi
 
 # remove trap.
-trap - INT
+trap - INT
+core_exit.sh

+ 1 - 0
lgsm/functions/command_details.sh

@@ -612,3 +612,4 @@ else
 fi
 
 fn_details_statusbottom
+core_exit.sh

+ 2 - 1
lgsm/functions/command_dev_debug.sh

@@ -16,4 +16,5 @@ else
 	date > .dev-debug
 	fn_print_ok_nl "Enabled dev-debug"
 	fn_script_log_info "Enabled dev-debug"
-fi
+fi
+core_exit.sh

+ 1 - 0
lgsm/functions/command_install.sh

@@ -36,3 +36,4 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then
 fi
 fix.sh
 install_complete.sh
+core_exit.sh

+ 2 - 1
lgsm/functions/command_monitor.sh

@@ -96,4 +96,5 @@ if [ "${gamename}" == "Teamspeak 3" ]; then
 	fn_monitor_teamspeak3
 else
 	fn_monitor_tmux
-fi
+fi
+core_exit.sh

+ 2 - 3
lgsm/functions/command_start.sh

@@ -26,7 +26,6 @@ fn_start_teamspeak3(){
 	fi
 
 	fn_print_dots "${servername}"
-	fn_script_log "${servername}"
 	sleep 1
 	check_status.sh
 	if [ "${status}" != "0" ]; then
@@ -60,7 +59,6 @@ fn_start_teamspeak3(){
 fn_start_tmux(){
 	fn_parms
 	fn_print_dots "${servername}"
-	fn_script_log "${servername}"
 	sleep 1
 
 	# Log rotation
@@ -110,7 +108,7 @@ fn_start_tmux(){
 	elif [ "${consolelogging}" == "off" ]; then
 		touch "${consolelog}"
 		cat "Console logging disabled by user" >> "{consolelog}"
-		fn_script_log "Console logging disabled by user"
+		fn_script_log_info "Console logging disabled by user"
 	fi
 	sleep 1
 
@@ -186,3 +184,4 @@ if [ "${gamename}" == "Teamspeak 3" ]; then
 else
 	fn_start_tmux
 fi
+core_exit.sh

+ 8 - 10
lgsm/functions/command_stop.sh

@@ -12,7 +12,7 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 # Attempts Graceful of source using rcon 'quit' command.
 fn_stop_graceful_source(){
 	fn_print_dots "Graceful: rcon quit"
-	fn_script_log "Graceful: rcon quit"
+	fn_script_log_info "Graceful: rcon quit"
 	# sends quit
 	tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
 	# waits up to 30 seconds giving the server time to shutdown gracefuly
@@ -43,7 +43,7 @@ fn_stop_graceful_source(){
 # preventing the server from coming back online.
 fn_stop_graceful_goldsource(){
 	fn_print_dots "Graceful: rcon quit"
-	fn_script_log "Graceful: rcon quit"
+	fn_script_log_info "Graceful: rcon quit"
 	# sends quit
 	tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
 	# waits 3 seconds as goldsource servers restart with the quit command
@@ -81,7 +81,7 @@ fn_stop_telnet_sdtd(){
 
 fn_stop_graceful_sdtd(){
 	fn_print_dots "Graceful: telnet"
-	fn_script_log "Graceful: telnet"
+	fn_script_log_info "Graceful: telnet"
 	sleep 1
 	if [ "${telnetenabled}" == "false" ]; then
 		fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}"
@@ -89,7 +89,7 @@ fn_stop_graceful_sdtd(){
 		# Tries to shutdown with both localhost and server IP.
 		for telnetip in 127.0.0.1 ${ip}; do
 			fn_print_dots "Graceful: telnet: ${telnetip}"
-			fn_script_log "Graceful: telnet: ${telnetip}"
+			fn_script_log_info "Graceful: telnet: ${telnetip}"
 			sleep 1
 			fn_stop_telnet_sdtd
 			completed=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Completed.")
@@ -136,8 +136,6 @@ fn_stop_graceful_sdtd(){
 			echo -en "\n\n" | tee -a "${scriptlog}"
 		fi
 	else
-		fn_print_dots "Graceful: telnet: "
-		fn_script_log "Graceful: telnet: "
 		fn_print_fail "Graceful: telnet: expect not installed: "
 		fn_print_fail_eol_nl
 		fn_script_log_fail "Graceful: telnet: expect not installed: FAIL"
@@ -199,7 +197,6 @@ fn_stop_ark(){
 
 fn_stop_teamspeak3(){
 	fn_print_dots "${servername}"
-	fn_script_log "${servername}"
 	sleep 1
 	${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1
 	check_status.sh
@@ -216,7 +213,7 @@ fn_stop_teamspeak3(){
 
 fn_stop_tmux(){
 	fn_print_dots "${servername}"
-	fn_script_log "tmux kill-session: ${servername}"
+	fn_script_log_info "tmux kill-session: ${servername}"
 	sleep 1
 	# Kill tmux session
 	tmux kill-session -t "${servicename}" > /dev/null 2>&1
@@ -232,10 +229,10 @@ fn_stop_tmux(){
 						echo -en "\n"
 				fi
 		fn_print_ok_nl "${servername}"
-		fn_script_log "Stopped ${servername}"
+		fn_script_log_pass "Stopped ${servername}"
 	else
 		fn_print_fail_nl "Unable to stop${servername}"
-		fn_script_log "Unable to stop${servername}"
+		fn_script_log_error "Unable to stop${servername}"
 	fi
 }
 
@@ -266,3 +263,4 @@ fn_print_dots "${servername}"
 fn_script_log "${servername}"
 sleep 1
 fn_stop_pre_check
+core_exit.sh

+ 3 - 3
lgsm/functions/command_ts3_server_pass.sh

@@ -28,14 +28,14 @@ fn_serveradmin_password_prompt(){
 		* ) echo "Please answer yes or no.";;
 	esac
 	done
-	fn_script_log "Initiating ${gamename} ServerAdmin password change"
+	fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
 	read -p "Enter new password : " newpassword
 	}
 
 
 	fn_serveradmin_password_set(){
 	fn_print_info_nl "Applying new password"
-	fn_script_log "Applying new password"
+	fn_script_log_info "Applying new password"
 	sleep 1
 	# Stop any running server
 	command_stop.sh
@@ -47,7 +47,7 @@ fn_serveradmin_password_prompt(){
 	command_stop.sh
 	ts3serverpass="0"
 	fn_print_ok_nl "Password applied"
-	fn_script_log "New ServerAdmin password applied"
+	fn_script_log_pass "New ServerAdmin password applied"
 	sleep 1
 }
 

+ 1 - 0
lgsm/functions/command_update_functions.sh

@@ -33,6 +33,7 @@ if [ "${exitcode}" == "0" ]; then
 	fn_script_log "Success! Updating functions"
 else
 	fn_print_fail "Updating functions"
+
 	fn_script_log "Failure! Updating functions"
 fi
 echo -ne "\n"