Sfoglia il codice sorgente

Changes to terminal and log messages.

* Major changes to terminal and log messages.
* More constant and improved wording of terminal and log messages.
* New local variable "modulename" that is displayed in terminal and log
messages.
* Added commented descriptions to most functions.
Daniel Gibbs 11 anni fa
parent
commit
5cf0a5f5c9

+ 3 - 3
functions/fn_autoip

@@ -2,9 +2,9 @@
 # LGSM fn_autoip function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 291214
+# Version: 010115
 
-# Identifies the server interface IP.
+# Description: Identifies the server interface IP.
 # If multiple interfaces this will need to be set manually.
 
 if [ ! -f /bin/ip ]; then
@@ -17,7 +17,7 @@ getipwc=$(${ipcommand} -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?
 
 if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
 	if [ "${getipwc}" -ge "2" ]; then
-		fn_printwarn "Multiple active network interfaces.\n\n"
+		fn_printwarn "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"

+ 22 - 9
functions/fn_backupserver

@@ -2,8 +2,11 @@
 # LGSM fn_backupserver function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 010115
 
+# Description: Creates a .tar.gz file in the backup directory.
+
+local modulename="Backup"
 fn_rootcheck
 fn_syscheck
 backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')"
@@ -11,7 +14,7 @@ echo ""
 echo "${gamename} Backup"
 echo "============================"
 echo ""
-echo "The following backup will be created."
+echo "The following backup will be created:"
 echo ""
 echo "${backupdir}/${backupname}.tar.gz"
 echo ""
@@ -25,9 +28,11 @@ esac
 done
 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:")
 if [ "${tmuxwc}" -eq 1 ]; then
-	echo -e "\e[0;31mWARNING!\e[0;39m ${servicename} is currently running"
+	echo ""
+	fn_printwarningnl "${servicename} is currently running."
+	sleep 1
 	while true; do
-		read -p "Would you like to stop ${servicename} while running the backup? [y/N]" yn
+		read -p "Stop ${servicename} while running the backup? [y/N]" yn
 		case $yn in
 		[Yy]* ) fn_stopserver; break;;
 		[Nn]* ) break;;
@@ -35,14 +40,22 @@ if [ "${tmuxwc}" -eq 1 ]; then
 	esac
 	done
 fi
-fn_printdots "Starting backup ${servicename}: ${servername}"
+fn_scriptlog "Started"
+echo -en "starting backup.\r"
+sleep 1
+echo -en "starting backup..\r"
 sleep 1
-fn_printok "Starting backup ${servicename}: ${servername}"
-fn_scriptlog "Backup started"
+echo -en "starting backup...\r"
 sleep 1
 echo -en "\n"
 cd "${rootdir}"
 mkdir -pv "${backupdir}" > /dev/null 2>&1
 tar -cvzf "${backupdir}/${backupname}.tar.gz" --exclude "${backupdir}" ./*
-echo -en "\r\033[K${servicename} Backup complete"
-fn_scriptlog "Backup complete"
+echo ""
+echo "Backup created: ${backupdir}/${backupname}.tar.gz"
+fn_scriptlog "Created: ${backupdir}/${backupname}.tar.gz"
+sleep 1
+echo ""
+fn_printcompletenl "Complete."
+fn_scriptlog "Complete"
+echo ""

+ 11 - 7
functions/fn_console

@@ -2,16 +2,19 @@
 # LGSM fn_console function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 010115
 
+# Description: Gives access to the server tmux console.
+
+local modulename="Console"
 fn_rootcheck
 fn_syscheck
 echo ""
 echo "${gamename} Console"
 echo "============================"
 echo ""
-echo "Press \"CTRL+b d\" to exit console"
-echo -e "\e[0;31mWARNING!\e[0;39m Do NOT press CTRL+c to exit"
+echo "Press \"CTRL+b d\" to exit console."
+fn_printwarningnl "Do NOT press CTRL+c to exit."
 echo ""
 while true; do
 	read -p "Continue? [y/N]" yn
@@ -21,16 +24,17 @@ while true; do
 	* ) echo "Please answer yes or no.";;
 esac
 done
-fn_printdots "Starting ${servicename} console"
+fn_printdots "Starting"
 sleep 1
 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:")
 if [ "${tmuxwc}" -eq 1 ]; then
-	fn_printoknl "Starting ${servicename} console"
-	fn_scriptlog "Console accessed"
+	fn_printoknl "Starting"
+	fn_scriptlog "accessed"
 	sleep 1
 	tmux attach-session -t ${servicename}
 else
-	fn_printfailnl "Starting ${servicename} console: ${servername} not running"
+	fn_printfailnl "Server not running"
+	fn_scriptlog "Failed to access: Server not running"
 	sleep 1
 	while true; do
 		read -p "Do you want to start the server? [y/N]" yn

+ 11 - 7
functions/fn_csgofix

@@ -2,13 +2,17 @@
 # LGSM fn_csgofix function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 010115
 
+# Description: Resolves various issues with csgo.
+
+# Fixed server not always creating steam_appid.txt file.
 fn_csgoappfix(){
 if [ ! -f "${filesdir}/steam_appid.txt" ]; then
 	fn_printdots "Applying 730 steam_appid.txt Fix."
 	sleep 1
 	fn_printinfo "Applying 730 steam_appid.txt Fix."
+	fn_scriptlog "Applying 730 steam_appid.txt Fix"
 	sleep 1
 	echo -en "\n"
 	echo -n "730" >> "${filesdir}/steam_appid.txt"
@@ -16,8 +20,8 @@ fi
 }
 
 fn_csgofixes(){
-# Fixes the following error
-# Error parsing BotProfile.db - unknown attribute 'Rank"
+# Fixes the following error:
+# Error parsing BotProfile.db - unknown attribute 'Rank".
 if ! grep -q "//Rank" "${systemdir}/botprofile.db" ; then
 	echo "botprofile.db fix removes the following error from appearing on the console:"
 	echo "	Error parsing BotProfile.db - unknown attribute 'Rank"
@@ -31,8 +35,8 @@ if ! grep -q "//Rank" "${systemdir}/botprofile.db" ; then
 	echo ""
 fi
 
-# Fixes errors simular to the following
-# Unknown command "cl_bobamt_vert"
+# Fixes errors simular to the following:
+# Unknown command "cl_bobamt_vert".
 if ! grep -q "//exec default" "${servercfgdir}/valve.rc" || ! grep -q "//exec joystick" "${servercfgdir}/valve.rc"; then
 	echo "valve.rc fix removes the following error from appearing on the console:"
 	echo "	Unknown command \"cl_bobamt_vert\""
@@ -47,8 +51,8 @@ if ! grep -q "//exec default" "${servercfgdir}/valve.rc" || ! grep -q "//exec jo
 	echo ""
 fi
 
-# Fixes errors simular to the following
-# http://forums.steampowered.com/forums/showthread.php?t=3170366
+# Fixes errors simular to the following:
+# http://forums.steampowered.com/forums/showthread.php?t=3170366.
 if [ -f "${systemdir}/subscribed_collection_ids.txt" ]||[ -f "${systemdir}/subscribed_file_ids.txt" ]||[ -f "${systemdir}/ugc_collection_cache.txt" ]; then
 	echo "workshopmapfix fixes the following error:"
 	echo "	http://forums.steampowered.com/forums/showthread.php?t=3170366"

+ 13 - 7
functions/fn_debugserver

@@ -2,8 +2,11 @@
 # LGSM fn_debugserver function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 121114
+# Version: 010115
 
+# Description: Runs the server without tmux. Runs direct from the terminal.
+
+local modulename="Debug"
 fn_rootcheck
 fn_syscheck
 fn_autoip
@@ -26,11 +29,10 @@ if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 else
 	echo "${executable} ${parms}"
 fi
-
 echo ""
 echo -e "Use for identifying server issues only!"
-echo -e "Press CTRL+c to drop out of debug mode"
-echo -e "\e[0;31mWARNING!\e[0;39m If ${servicename} is already running it will be stopped"
+echo -e "Press CTRL+c to drop out of debug mode."
+fn_printwarningnl "If ${servicename} is already running it will be stopped."
 echo ""
 while true; do
 	read -p "Continue? [y/N]" yn
@@ -40,12 +42,16 @@ while true; do
 	* ) echo "Please answer yes or no.";;
 esac
 done
+fn_scriptlog "Starting debug"
+fn_printinfonl "Stopping any running servers"
+fn_scriptlog "Stopping any running servers"
+sleep 1
 fn_stopserver
-fn_printdots "Starting debug mode ${servicename}: ${servername}"
+fn_printdots "Starting debug"
 sleep 1
-fn_printok "Starting debug mode ${servicename}: ${servername}"
+fn_printok "Starting debug"
+fn_scriptlog "Started debug"
 sleep 1
-fn_scriptlog "Started debug mode ${servername}"
 echo -en "\n"
 cd "${executabledir}"
 if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then

+ 3 - 1
functions/fn_details

@@ -2,7 +2,9 @@
 # LGSM fn_details function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 231214
+# Version: 291214
+
+# Description: Displays server infomation.
 
 fn_avalanchedetails(){
 fn_autoip

+ 7 - 3
functions/fn_emailnotification

@@ -2,8 +2,12 @@
 # LGSM fn_emailnotification function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 010115
 
+# Description: Sends email notification if monitor picks up a failure.
+
+local modulename="Email"
+fn_printdots "Sending notification to ${email}"
 fn_distro
 fn_uptime
 fn_load
@@ -35,7 +39,7 @@ if [ ! -z "${gamelogdir}" ]; then
 	tail "${gamelogdir}"/*|grep -v "==>"|sed '/^$/d'|tail -25 >> "${emaillog}"
 fi
 mail -s "${subject}" ${email} < "${emaillog}"
-fn_printinfo "Sent email notification to ${email}"
-fn_scriptlog "Sent email notification to ${email}"
+fn_printok "Sending notification to ${email}"
+fn_scriptlog "Sent notification to ${email}"
 sleep 1
 echo -en "\n"

+ 8 - 7
functions/fn_emailtest

@@ -2,19 +2,20 @@
 # LGSM fn_emailtest function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 010115
 
+# Description: Sends a test email notification.
+
+local modulename="Email"
 fn_rootcheck
 fn_syscheck
-fn_scriptlog "Emailing test notification"
 if [ "${emailnotification}" = "on" ]; then
+	fn_scriptlog "Sending test notification"
 	subject="${servicename} Email Test Notification - Testing ${servername}"
 	failurereason="Testing ${servicename} email notification"
 	actiontaken="Sent test email...hello is this thing on?"
 	fn_emailnotification
 else
-	fn_printfailnl "Email notification not enabled"
-	fn_scriptlog "Email notification not enabled"
-fi
-sleep 1
-echo -en "\n"
+	fn_printfailnl "Notifications not enabled"
+	fn_scriptlog "Notifications not enabled"
+fi

+ 1 - 1
functions/fn_functions

@@ -3,7 +3,7 @@
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
 # Version: 241214
-#
+
 # Description: Defines all functions to allow download and execution of functions using fn_runfunction.
 # This function is called first before any other function. Without this file other functions would not load.
 

+ 12 - 7
functions/fn_glibcfix

@@ -2,13 +2,13 @@
 # LGSM fn_glibcfix function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 171214
+# Version: 281214
 
 fn_glibcfixmsg(){
 echo "GLIBC Fix required"
 echo "============================"
 sleep 1
-echo -e "\e[0;31mWARNING!\e[0;39m ${gamename} requires GLIBC_${glibcversion} or above"
+fn_printwarningnl "${gamename} requires GLIBC_${glibcversion} or above"
 sleep 1
 echo ""
 echo -e "Currently installed:\e[0;31m GLIBC_$(ldd --version |grep ldd|awk '{print $NF}')\e[0;39m"
@@ -19,16 +19,21 @@ echo "The installer will now detect and download the required files to allow ${g
 echo "note: This will NOT upgrade GLIBC on your system."
 sleep 1
 echo ""
-echo "loading required files..."
+echo -en "loading required files.\r"
 sleep 1
+echo -en "loading required files..\r"
+sleep 1
+echo -en "loading required files...\r"
+sleep 1
+echo -en "\n"
 }
 
 # if ldd command not detected
 if [ -z $(command -v ldd) ]; then
 	echo ""
-	echo -e "\r\033[K\e[0;31mFAIL\e[0;39m GLIBC is not detected."
+	fn_printfailurenl "GLIBC is not detected"
 	sleep 1
-	echo "Install GLIBC and retry installation"
+	echo "Install GLIBC and retry installation."
 	sleep 1
 	echo ""
 	while true; do
@@ -101,10 +106,10 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215
 			fn_glibcfixmsg
 			cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/Bin/libstdc++.so.6"
 		else
-			echo "error: Unable to detect game. Fix not applied"
+			fn_printfailurenl "Unable to detect game. Fix not applied"
 		fi
 	else
-		echo "error: Unable to detect game. Fix not applied"
+		fn_printfailurenl "Unable to detect game. Fix not applied"
 	fi
 fi
 sleep 1

+ 9 - 6
functions/fn_logmanager

@@ -2,17 +2,20 @@
 # LGSM fn_logmanager function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 010115
 
+# Description: Acts as a log rotater, removing old logs.
+
+local modulename="Log Manager"
 if [ ! -e "${consolelog}" ]; then
 	touch "${consolelog}"
 fi
 # log manager will active if finds logs older than ${logdays}
 if [ $(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) -ne "0" ]; then
-	fn_printdots "Starting log cleaner"
+	fn_printdots "Starting"
 	sleep 1
-	fn_printok "Starting log cleaner"
-	fn_scriptlog "Starting log cleaner"
+	fn_printok "Starting"
+	fn_scriptlog "Starting"
 	sleep 1
 	echo -en "\n"
 	fn_printinfo "Removing logs older than ${logdays} days"
@@ -40,8 +43,8 @@ if [ $(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) -ne "0" ]; then
 	fi
 	find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \;
 	find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \;
-	fn_printok "Log cleaner removed ${count} log files"
-	fn_scriptlog "Log cleaner removed ${count} log files"
+	fn_printok "Removed ${count} log files"
+	fn_scriptlog "Removed ${count} log files"
 	sleep 1
 	echo -en "\n"
 fi

+ 80 - 14
functions/fn_messages

@@ -2,53 +2,119 @@
 # LGSM fn_messages function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 241214
-#
-# Description: Defines on-screen messages such as and now script logs look
+# Version: 010115
 
-# Displays date and servicename for log files
+# Description: Defines on-screen messages such as [  OK  ] and how script logs look.
+
+# Date and servicename for log files.
 fn_scriptlog(){
-	echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}"
+    if [ ! -z ${modulename} ]; then
+        echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ${1}" >> "${scriptlog}"
+    else
+        echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}"
+    fi
 }
 
 # [ FAIL ]
 fn_printfail(){
-    echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@"
+    else
+        echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@"
+    fi
 }
 
 fn_printfailnl(){
-    echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -e "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@"
+    else
+        echo -e "\r\033[K[\e[0;31m FAIL \e[0m] $@"
+    fi
 }
 
 # [  OK  ]
 fn_printok(){
-    echo -en "\r\033[K[\e[0;32m  OK  \e[0;39m] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -en "\r\033[K[\e[0;32m  OK  \e[0m] ${modulename} ${servicename}: $@"
+    else
+        echo -en "\r\033[K[\e[0;32m  OK  \e[0m] $@"
+    fi
 }
 
 fn_printoknl(){
-    echo -e "\r\033[K[\e[0;32m  OK  \e[0;39m] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -e "\r\033[K[\e[0;32m  OK  \e[0m] ${modulename} ${servicename}: $@"
+    else
+        echo -e "\r\033[K[\e[0;32m  OK  \e[0m] $@"
+    fi
 }
 
 # [ INFO ]
 fn_printinfo(){
-    echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@"
+    else
+        echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@"
+    fi
 }
 
 fn_printinfonl(){
-    echo -e "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -e "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@"
+    else
+        echo -e "\r\033[K[\e[0;36m INFO \e[0m] $@"
+    fi
 }
 
 # [ WARN ]
 fn_printwarn(){
-	echo -en "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@"
+    else
+        echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@"
+    fi
 }
 
 fn_printwarnnl(){
-	echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -e "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@"
+    else
+        echo -e "\r\033[K[\e[1;33m WARN \e[0m] $@"
+    fi
 }
 
 # [ .... ]
 fn_printdots(){
-    echo -en "\r\033[K[ .... ] $@"
+    if [ ! -z ${modulename} ]; then
+        echo -en "\r\033[K[ .... ] ${modulename} ${servicename}: $@"
+    else
+        echo -en "\r\033[K[ .... ] $@"
+    fi
+}
+
+# Complete!
+fn_printcomplete(){
+    echo -en "\e[0;32mComplete!\e[0m $@"
+}
+
+fn_printcompletenl(){
+    echo -e "\e[0;32mComplete!\e[0m $@"
+}
+
+# Warning!
+fn_printwarning(){
+    echo -en "\e[0;33mWarning!\e[0m $@"
+}
+
+fn_printwarningnl(){
+    echo -e "\e[0;33mWarning!\e[0m $@"
+}
+
+# Failure!
+fn_printfailure(){
+    echo -en "\e[0;31mFailure!\e[0m $@"
 }
 
+fn_printfailurenl(){
+    echo -e "\e[0;31mFailure!\e[0m $@"
+}

+ 16 - 12
functions/fn_monitorserver

@@ -2,17 +2,21 @@
 # LGSM fn_monitorserver function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 010115
 
+# Description: Monitors server by checking for running proccesses
+# then passes to fn_serverquery.
+
+local modulename="Monitor"
 fn_rootcheck
 fn_syscheck
 fn_autoip
-fn_printdots "Monitoring ${servicename}: ${servername}"
-fn_scriptlog "Monitoring ${servername}"
+fn_printdots "${servername}"
+fn_scriptlog "${servername}"
 sleep 1
 if [ ! -f "${lockselfname}" ]; then
-	fn_printinfo "Monitoring ${servicename}: Monitor disabled: No lock file found"
-	fn_scriptlog "Monitor disabled: No lock file found"
+	fn_printinfo "Disabled: No lock file found"
+	fn_scriptlog "Disabled: No lock file found"
 	sleep 1
 	echo -en "\n"
 	echo "To enable monitor run ${selfname} start"
@@ -20,19 +24,19 @@ if [ ! -f "${lockselfname}" ]; then
 fi
 updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)
 if [ "${updatecheck}" = "0" ]; then
-	fn_printdots "Monitoring ${servicename}: Checking session: CHECKING"
+	fn_printdots "Checking session: CHECKING"
 	fn_scriptlog "Checking session: CHECKING"
 	sleep 1
 	tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
 	if [ "${tmuxwc}" -eq 1 ]; then
-		fn_printok "Monitoring ${servicename}: Checking session: OK"
+		fn_printok "Checking session: OK"
 		fn_scriptlog "Checking session: OK"
 		sleep 1
 		echo -en "\n"
 		fn_serverquery
 		exit
 	else
-		fn_printfail "Monitoring ${servicename}: Checking session: FAIL"
+		fn_printfail "Checking session: FAIL"
 		fn_scriptlog "Checking session: FAIL"
 		sleep 1
 		echo -en "\n"
@@ -46,10 +50,10 @@ if [ "${updatecheck}" = "0" ]; then
 		fn_startserver
 	fi
 else
-	fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates"
-	fn_scriptlog "Detected SteamCMD is checking for updates"
+	fn_printinfonl "SteamCMD is currently checking for updates"
+	fn_scriptlog "SteamCMD is currently checking for updates"
 	sleep 1
-	fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
-	fn_scriptlog "When updates complete ${servicename} will start"
+	fn_printinfonl "When update is complete ${servicename} will start"
+	fn_scriptlog "When update is complete ${servicename} will start"
 	sleep 1
 fi

+ 1 - 1
functions/fn_serverconfig

@@ -116,7 +116,7 @@ echo "setting WebAdmin username and password."
 sed -i 's/AdminName=/AdminName=admin/g' "${systemdir}/${ini}"
 sed -i 's/AdminPassword=/AdminPassword=admin/g' "${systemdir}/${ini}"
 sleep 1
-echo "enabling WebAdmin"
+echo "enabling WebAdmin."
 sed -i 's/bEnabled=False/bEnabled=True/g' "${systemdir}/${ini}"
 if [ "${gamename}" == "Unreal Tournament 2004" ]; then
 	sleep 1

+ 2 - 2
functions/fn_serverdirectory

@@ -2,7 +2,7 @@
 # LGSM fn_serverdirectory function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 241214
+# Version: 010115
 
 echo ""
 echo "Server Directory"
@@ -11,7 +11,7 @@ echo ""
 pwd
 echo ""
 if [ -d "${filesdir}" ]; then
-	echo -e "\e[0;31mWARNING!\e[0;39m A server is already installed here"
+	fn_printwarningnl "A server is already installed here."
 fi
 while true; do
 	read -p "Continue [y/N]" yn

+ 16 - 14
functions/fn_serverquery

@@ -2,10 +2,12 @@
 # LGSM fn_serverquery function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 231214
+# Version: 010115
 
-# uses gsquery.py to directly query the server
-# detects if the server locks up
+# Description: uses gsquery.py to directly query the server.
+# Detects if the server has frozen.
+
+local modulename="Monitor"
 if [ -f gsquery.py ]; then
 	if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
 		gameport=$(grep Port= "${systemdir}/${ini}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd [:digit:])
@@ -19,21 +21,21 @@ if [ -f gsquery.py ]; then
 		gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd [:digit:])
 		port=$((${gameport} + 1))
 	fi
-	fn_printinfo "Monitoring ${servicename}: Detected gsquery.py"
+	fn_printinfo "Detected gsquery.py"
 	fn_scriptlog "Detected gsquery.py"
 	sleep 1
-	fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port} : QUERYING"
+	fn_printdots "Querying port: ${ip}:${port} : QUERYING"
 	fn_scriptlog "Querying port: ${ip}:${port} : QUERYING"
 	sleep 1
 	serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1)
 	exitcode=$?
 	if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then
-		fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port} : ${serverquery}"
+		fn_printfail "Querying port: ${ip}:${port} : ${serverquery}"
+		fn_scriptlog "Querying port: ${ip}:${port} : ${serverquery}"
 		sleep 1
 		echo -en "\n"
-		fn_scriptlog "Querying port: ${ip}:${port} : ${serverquery}"
 		if [[ -z "${secondquery}" ]]; then
-			fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query"
+			fn_printinfo "Waiting 30 seconds to re-query"
 			fn_scriptlog "Waiting 30 seconds to re-query"
 			sleep 30
 			secondquery=1
@@ -48,14 +50,14 @@ if [ -f gsquery.py ]; then
 		fn_restartserver
 		exit
 	elif [ "${exitcode}" == "0" ]; then
-		fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port} : OK"
+		fn_printok "Querying port: ${ip}:${port} : OK"
 		fn_scriptlog "Querying port: ${ip}:${port} : OK"
 		sleep 1
 		echo -en "\n"
 		exit
 	elif [ "${exitcode}" == "126" ]; then
-		fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port} : ERROR: ./gsquery.py: Permission denied"
-		fn_scriptlog "Querying port: ${ip}:${port} : ./gsquery.py: Permission denied"
+		fn_printfail "Querying port: ${ip}:${port} : ERROR: ./gsquery.py: Permission denied"
+		fn_scriptlog "Querying port: ${ip}:${port} : ERROR: ./gsquery.py: Permission denied"
 		sleep 1
 		echo -en "\n"
 		echo "Attempting to resolve automatically"
@@ -64,15 +66,15 @@ if [ -f gsquery.py ]; then
 		if [ "${exitcode}" == "0" ]; then
 			fn_serverquery
 		else
-			echo -en "\nUnable to resolve automatically. Please manually fix permissions\n"
+			fn_printfailure "Unable to resolve automatically. Please manually fix permissions.\n"
 			owner=$(ls -al gsquery.py|awk '{ print $3 }')
-			echo "As user ${owner} or root run the following command"
+			echo "As user ${owner} or root run the following command."
 			whoami=$(whoami)
 			echo -en "\nchown ${whoami}:${whoami} gsquery.py\n\n"
 		exit
 		fi
 	else
-		fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port} : UNKNOWN ERROR"
+		fn_printfail "Querying port: ${ip}:${port} : UNKNOWN ERROR"
 		fn_scriptlog "Querying port: ${ip}:${port} : UNKNOWN ERROR"
 		sleep 1
 		echo -en "\n"

+ 10 - 7
functions/fn_startserver

@@ -2,8 +2,11 @@
 # LGSM fn_startserver function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 071214
+# Version: 010115
 
+# Description: Starts the server.
+
+modulename="Starting"
 fn_rootcheck
 fn_syscheck
 fn_autoip
@@ -22,11 +25,11 @@ if [ "${tmuxwc}" -eq 0 ]; then
 	mv "${scriptlog}" "${scriptlogdate}"
 	mv "${consolelog}" "${consolelogdate}"
 fi
-fn_printdots "Starting ${servicename}: ${servername}"
-fn_scriptlog "Starting ${servername}"
+fn_printdots "${servername}"
+fn_scriptlog "${servername}"
 sleep 1
 if [ "${tmuxwc}" -eq 1 ]; then
-	fn_printinfo "Starting ${servicename}: ${servername} is already running"
+	fn_printinfo "${servername} is already running"
 	fn_scriptlog "${servername} is already running"
 	sleep 1
 	echo -en "\n"
@@ -46,15 +49,15 @@ fi
 sleep 1
 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
 if [ "${tmuxwc}" -eq 0 ]; then
-	fn_printfailnl "Starting ${servicename}: Failed to start ${servername}"
+	fn_printfailnl "Unable to start ${servername}"
+	fn_scriptlog "Unable to start ${servername}"
 	echo -en "	Check log files: ${rootdir}/log"
-	fn_scriptlog "failed to start ${servername}"
 	if [ -a "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then
 		fn_scriptlog "tmux returned the following error"
 		cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" >> "${scriptlog}"
 	fi
 else
-	fn_printok "Starting ${servicename}: ${servername}"
+	fn_printok "${servername}"
 	fn_scriptlog "Started ${servername}"
 fi
 rm "${scriptlogdir}/.${servicename}-tmux-error.tmp"

+ 3 - 3
functions/fn_steaminstall

@@ -2,7 +2,7 @@
 # LGSM fn_steaminstall function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 241214
+# Version: 281214
 
 fn_steaminstallcommand(){
 echo "0x402" > .fn_steaminstall.tmp
@@ -10,11 +10,11 @@ while [ "$(grep -c 0x402 .fn_steaminstall.tmp)" -ge "1" ]; do
 	counter=$((counter+1))
 	if [ "${counter}" -le "10" ]; then
 		if [ "${counter}" -ge "2" ]; then
-			echo -e "\e[0;31mWarning!\e[0;39m SteamCMD did not complete the download, retrying: Attempt ${counter}"
+			fn_printwarningnl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
 		fi
 		./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit |tee .fn_steaminstall.tmp
 	elif [ "${counter}" -ge "11" ]; then
-		echo -e "\e[0;31mFailure!\e[0;39m SteamCMD did not complete the download, too many retrys"
+		fn_printfailurenl "SteamCMD did not complete the download, too many retrys"
 		break
 	fi
 done

+ 8 - 5
functions/fn_stopserver

@@ -2,20 +2,23 @@
 # LGSM fn_stopserver function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 011214
+# Version: 010115
 
+# Description: Stops the server.
+
+modulename="Stopping"
 fn_rootcheck
 fn_syscheck
 pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
-fn_printdots "Stopping ${servicename}: ${servername}"
-fn_scriptlog "Stopping ${servername}"
+fn_printdots "${servername}"
+fn_scriptlog "${servername}"
 sleep 1
 if [ "${pid}" == "0" ]; then
-	fn_printfail "Stopping ${servicename}: ${servername} is already stopped"
+	fn_printfail "${servername} is already stopped"
 	fn_scriptlog "${servername} is already stopped"
 else
 	tmux kill-session -t ${servicename}
-	fn_printok "Stopping ${servicename}: ${servername}"
+	fn_printok "${servername}"
 	fn_scriptlog "Stopped ${servername}"
 fi
 # Remove lock file

+ 7 - 4
functions/fn_updateserver

@@ -2,15 +2,18 @@
 # LGSM fn_updateserver function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 241214
+# Version: 010115
 
+# Description: Runs a server update.
+
+local modulename="Update"
 fn_rootcheck
 fn_syscheck
-fn_printdots "Updating ${servicename}: ${servername}"
-sleep 1
-fn_printok "Updating ${servicename}: ${servername}"
+fn_printdots "Updating ${servername}"
 sleep 1
+fn_printok "Updating ${servername}"
 fn_scriptlog "Updating ${servername}"
+sleep 1
 cd "${rootdir}"
 cd "steamcmd"
 ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit|tee -a "${scriptlog}"

+ 8 - 4
functions/fn_validateserver

@@ -2,8 +2,11 @@
 # LGSM fn_validateserver function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 241214
+# Version: 010115
 
+# Description: Runs a server validation.
+
+local modulename="Validate"
 fn_rootcheck
 fn_syscheck
 fn_printwarn "Validating may overwrite some customised files."
@@ -12,11 +15,12 @@ echo -en "\n"
 echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate"
 sleep 5
 echo -en "\n"
-fn_printdots "Validating ${servicename}: ${servername}"
+fn_printdots "Checking server files"
 sleep 1
-fn_printok "Validating ${servicename}: ${servername}"
+fn_printok "Checking server files"
+fn_scriptlog "Checking server files"
 sleep 1
-fn_scriptlog "Validating ${servername}"
 cd "${rootdir}"
 cd "steamcmd"
 ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit|tee -a "${scriptlog}"
+fn_scriptlog "Checking complete"

+ 50 - 30
functions/fn_versioncheck

@@ -2,37 +2,49 @@
 # LGSM fn_versioncheck function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 231214
+# Version: 010115
+
+# Description: Checks if a server update is available.
+
+modulename="Update"
 
 fn_steamcmdcheck(){
 # Checks for server update from SteamCMD
-fn_printdots "Checking ${servicename}: Checking for updates via SteamCMD"
+fn_printdots "Checking for update: SteamCMD"
+fn_scriptlog "Checking for update: SteamCMD"
 installedversion=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
 availableversion=$(steamcmd/steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_print ${appid} +app_info_print ${appid} +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"public\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
 sleep 1
 if [ -z "${availableversion}" ]; then
-	fn_printfail "Checking ${servicename}: Checking for updates via SteamCMD"
+	fn_printfail "Checking for update: SteamCMD"
+	fn_scriptlog "Failure! Checking for update: SteamCMD"
 	sleep 1
-	fn_printfail "Checking ${servicename}: SteamCMD is not returning version info"
+	fn_printfail "Checking for update: SteamCMD: Not returning version info"
+	fn_scriptlog "Failure! Checking for update: SteamCMD: Not returning version info"
 	sleep 2
 else
-	fn_printok "Checking ${servicename}: Checking for updates via SteamCMD"
+	fn_printok "Checking for update: SteamCMD"
+	fn_scriptlog "Success! Checking for update: SteamCMD"
 	sleep 1
 fi
 
 if [ -z "${availableversion}" ]; then
 	# Checks for server update from SteamDB.info if SteamCMD fails
 	echo ""
-	fn_printdots "Checking ${servicename}: Checking for updates via SteamDB.info"
+	fn_printdots "Checking for update: SteamDB.info"
+	fn_scriptlog "Checking for update: SteamDB.info"
 	availableversion=$(wget -qO- "http://steamdb.info/api/GetRawDepots/?appid=${appid}" | sed 's/\\n/\n/g' | grep -EA 1000 "^\s+\[branches\]" | grep -EA 5 "^\s+\[public\]" | grep -m 1 -EB 10 "^\s+\)$" | grep -E "^\s+\[buildid\]\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f4)
 	sleep 1
 	if [ -z "${availableversion}" ]; then
-		fn_printfail "Checking ${servicename}: Checking for updates via SteamDB.info"
+		fn_printfail "Checking for update: SteamDB.info"
+		fn_scriptlog "Failure! Checking for update: SteamDB.info"
 		sleep 1
-		fn_printfail "Checking ${servicename}: SteamDB.info is not returning version info"
+		fn_printfail "Checking for update: SteamDB.info: Not returning version info"
+		fn_scriptlog "Failure! Checking for update: SteamDB.info: Not returning version info"
 		sleep 2
 	else
-		fn_printok "Checking ${servicename}: Checking for updates via SteamDB.info"
+		fn_printok "Checking for update via SteamDB.info"
+		fn_scriptlog "Success! Checking for update: SteamDB.info"
 		sleep 1
 	fi
 fi
@@ -50,13 +62,14 @@ if [ "${installedversion}" -ne "${availableversion}" ]; then
 	echo -e "	https://steamdb.info/app/${appid}/"
 	sleep 1
 	echo ""
-	echo -ne "Applying update.\r"
+	echo -en "Applying update.\r"
 	sleep 1
-	echo -ne "Applying update..\r"
+	echo -en "Applying update..\r"
 	sleep 1
-	echo -ne "Applying update...\r"
+	echo -en "Applying update...\r"
 	sleep 1
-	echo -ne "\n"
+	echo -en "\n"
+	fn_scriptlog "Update available"
 	if [ ! -z "${norestart}" ]; then
 		fn_updateserver
 	else
@@ -71,19 +84,22 @@ else
 	echo -e "	Available version: \e[0;32m${availableversion}\e[0;39m"
 	echo -e "	https://steamdb.info/app/${appid}/"
 	echo -e ""
+	fn_printok "No update available"
+	fn_scriptlog "No update available"
 fi
 }
 
 fn_logupdaterequest(){
-# Checks for server update requiests from server logs.
+# Checks for server update requests from server logs.
 echo ""
-fn_printdots "Checking ${servicename}: Checking server logs for update requests"
-requestrestart=$(grep -sc "MasterRequestRestart" "${consolelog}")
+fn_printdots "Checking server logs for update requests"
+sleep 1
+fn_printok "Checking server logs for update requests"
+fn_scriptlog "Checking server logs for update requests"
 sleep 1
+requestrestart=$(grep -sc "MasterRequestRestart" "${consolelog}")
 if [ "${requestrestart}" -ge "1" ]; then
-	fn_printok "Checking ${servicename}: Checking server logs for update requests"
-	sleep 1
-	fn_printoknl "Checking ${servicename}: Server requesting update"
+	fn_printoknl "Server requesting update"
 	sleep 1
 	echo ""
 	echo -ne "Applying update.\r"
@@ -101,9 +117,7 @@ if [ "${requestrestart}" -ge "1" ]; then
 		fn_startserver
 	fi
 else
-	fn_printok "Checking ${servicename}: Checking logs for update requests"
-	sleep 1
-	fn_printok "Checking ${servicename}: No update request detected"
+	fn_printok "No update request detected"
 	sleep 1
 fi
 echo ""
@@ -122,9 +136,10 @@ fn_appmanifestinfo
 # This is an error is corrected below if required.
 if [ "${appmanifestfilewc}" -ge "2" ]; then
 	sleep 1
-	fn_printwarn "Checking ${servicename}: Multiple appmanifest_${appid}.acf files found"
+	fn_printwarn "Multiple appmanifest_${appid}.acf files found"
+	fn_scriptlog "Warning! Multiple appmanifest_${appid}.acf files found"
 	sleep 2
-	fn_printdots "Checking ${servicename}: Removing x${appmanifestfilewc} appmanifest_${appid}.acf files"
+	fn_printdots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files"
 	sleep 1
 	for appfile in ${appmanifestfile}; do
 		rm "${appfile}"
@@ -132,7 +147,8 @@ if [ "${appmanifestfilewc}" -ge "2" ]; then
 	appmanifestfilewc1="${appmanifestfilewc}"
 	fn_appmanifestinfo
 	if [ "${appmanifestfilewc}" -ge "2" ]; then
-		fn_printfail "Checking ${servicename}: Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
+		fn_printfail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
+		fn_scriptlog "Failure! Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
 		sleep 1
 		echo ""
 		echo "	Check user permissions"
@@ -142,23 +158,27 @@ if [ "${appmanifestfilewc}" -ge "2" ]; then
 		exit
 	else
 		sleep 1
-		fn_printok "Checking ${servicename}: Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
+		fn_printok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
+		fn_scriptlog "Success! Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
 		sleep 1
-		fn_printinfonl "Checking ${servicename}: Forcing update to correct issue"
+		fn_printinfonl "Forcing update to correct issue"
+		fn_scriptlog "Forcing update to correct issue"
 		sleep 1
 		fn_updateserver
 		fn_versioncheck
 	fi
 elif [ "${appmanifestfilewc}" -eq "0" ]; then
-	fn_printwarn "Checking ${servicename}: No appmanifest_${appid}.acf found"
+	fn_printwarn "No appmanifest_${appid}.acf found"
+	fn_scriptlog "Warning! No appmanifest_${appid}.acf found"
 	sleep 2
-	fn_printinfonl "Checking ${servicename}: Forcing update to correct issue"
+	fn_printinfonl "Forcing update to correct issue"
+	fn_scriptlog "Forcing update to correct issue"
 	sleep 1
 	fn_updateserver
 	fn_logupdaterequest
 fi
 }
 
-fn_printdots "Checking ${servicename}: Checking for updates"
+fn_printdots "Checking for update"
 fn_appmanifestcheck
 fn_steamcmdcheck