فهرست منبع

converted fn_debugserver and fn_details

Coverted the following functions to the new function file method
fn_debugserver
fn_details
fn_steamfix

fn_details added the parms to the details.
fn_debug mode minor change to how parms are displayed
Daniel Gibbs 11 سال پیش
والد
کامیت
a2c88738b3
2فایلهای تغییر یافته به همراه85 افزوده شده و 202 حذف شده
  1. 47 110
      GarrysMod/gmodserver
  2. 38 92
      NoMoreRoomInHell/nmrihserver

+ 47 - 110
GarrysMod/gmodserver

@@ -3,7 +3,7 @@
 # Server Management Script
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 021114
+# Version: 121114
 
 #### Variables ####
 
@@ -205,46 +205,11 @@ fi
 }
 
 fn_debugserver(){
-fn_rootcheck
-fn_syscheck
-fn_autoip
-fn_distro
-fn_uptime
-fn_load
-fn_parms
-echo ""
-echo "${gamename} Debug"
-echo "============================"
-echo ""
-echo -e "Distro: ${os}"
-echo -e "Arch: ${arch}"
-echo -e "Kernel: ${kernel}"
-echo -e "Hostname: $HOSTNAME"
-echo ""
-echo "Start parameters:"
-echo ${parms}
-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 ""
-while true; do
-	read -p "Continue? [y/N]" yn
-	case $yn in
-	[Yy]* ) break;;
-	[Nn]* ) echo Exiting; return 1;;
-	* ) echo "Please answer yes or no.";;
-esac
-done
-fn_stopserver
-fn_printdots "Starting debug mode ${servicename}: ${servername}"
-sleep 1
-fn_printok "Starting debug mode ${servicename}: ${servername}"
-sleep 1
-fn_scriptlog "Started debug mode ${servername}"
-echo -en "\n"
-cd "${executabledir}"
-${executable} ${parms} -debug
+if [ ! -f functions/fn_debugserver ]; then
+	functionfile="fn_debugserver"
+	fn_fninstall
+fi
+source functions/fn_debugserver
 }
 
 fn_console(){
@@ -649,38 +614,27 @@ echo -en "\n"
 }
 
 fn_details(){
-fn_autoip
-servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
-rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')
-pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
-echo ""
-echo "${gamename} Server Details"
-echo "============================"
-echo "Server name: ${servername}"
-echo "Server IP: ${ip}:${port}"
-echo "RCON password: ${rcon}"
-echo "Config file: ${servercfgfullpath}"
-echo ""
-echo "${servername} Ports"
-echo "============================"
-echo "Ports the server is currently using."
-echo ""
-echo "DIRECTION	DESCRIPTION		PORT"
-echo "INBOUND		Game/RCON port		${port}"
-if [ ! -z ${sourcetvport} ]; then
-	echo "INBOUND		SourceTV port		${sourcetvport}"
+if [ ! -f functions/fn_details ]; then
+	functionfile="fn_details"
+	fn_fninstall
 fi
-echo "OUTBOUND	Client port		${clientport}"
-echo ""
-echo "You can change ports by editing the"
-echo "start parameters in ${selfname}."
-echo ""
-if [ "${pid}" == "0" ]; then
-	echo -e "Status:\e[0;31m OFFLINE\e[0;39m"
-else
-	echo -e "Status:\e[0;32m ONLINE\e[0;39m"
+source functions/fn_details
+}
+
+fn_fninstall(){
+cd ${rootdir}	
+if [ ! -d "functions" ]; then
+	mkdir functions
 fi
 echo ""
+echo "Downloading ${functionfile}"
+echo "================================="
+cd functions
+wget -nv -N https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile}
+chmod +x ${functionfile}
+cd ${rootdir}
+sleep 1
+echo ""
 }
 
 #
@@ -688,20 +642,13 @@ echo ""
 #
 
 fn_glibcfix(){
+if [ ! -f functions/fn_glibcfix ]; then
+	functionfile="fn_glibcfix"
+	fn_fninstall
+fi	
 source functions/fn_glibcfix
 }
 
-fn_libsteamfix(){
-	echo "Applying libsteam.so fix"
-	echo "================================="
-	sleep 1
-	mkdir -pv "${HOME}/.steam"
-	mkdir -pv "${HOME}/.steam/sdk32"
-	cp -v "${filesdir}/bin/libsteam.so" "${HOME}/.steam/sdk32/libsteam.so"
-	sleep 1
-	echo ""
-}
-
 fn_header(){
 clear
 echo "================================="
@@ -713,14 +660,6 @@ echo "================================="
 echo ""
 }
 
-fn_fninstall(){
-mkdir functions
-cd functions
-wget -nv -N https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/fn_fninstall
-cd ${rootdir}
-source functions/fn_fninstall
-}
-
 fn_steamdl(){
 echo "Installing SteamCMD"
 echo "================================="
@@ -763,14 +702,11 @@ echo ""
 }
 
 fn_steamfix(){
-echo "Applying steamclient.so fix"
-echo "================================="
-sleep 1
-mkdir -pv "${HOME}/.steam"
-mkdir -pv "${HOME}/.steam/sdk32"
-cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so"
-sleep 1
-echo ""
+if [ ! -f functions/fn_steamfix ]; then
+	functionfile="fn_steamfix"
+	fn_fninstall
+fi	
+source functions/fn_steamfix
 }
 
 fn_loginstall(){
@@ -844,11 +780,9 @@ while true; do
 	esac
 done
 fn_header
-fn_fninstall
 fn_steamdl
 fn_steaminstall
 fn_steamfix
-fn_libsteamfix
 fn_loginstall
 fn_getquery
 fn_glibcfix
@@ -865,12 +799,23 @@ echo "================================="
 	echo "Creating ${servicename}.cfg config file."
 	touch "${servercfgfullpath}"
 	{
-		echo -e "// Server Info"
+		echo -e "// Server Name"
 		echo -e "hostname \"${servername}\""
-		echo -e "sv_password \"\""
 		echo -e ""
-		echo -e "// RCON Settings"
+		echo -e "// RCON Password"
 		echo -e "rcon_password \"${rconpass}\""
+		echo -e ""
+		echo -e "// Server Password"
+		echo -e "sv_password \"\""
+		echo -e ""
+		echo -e "// Server Logging"
+		echo -e "log on"
+		echo -e "sv_logbans 1"
+		echo -e "sv_logecho 1"
+		echo -e "sv_logfile 1"
+		echo -e "sv_log_onefile 0"
+		echo -e "lua_log_sv 0"
+
 		echo -e "sv_rcon_banpenalty 0"
 		echo -e "sv_rcon_maxfailures 20"
 		echo -e "sv_rcon_minfailures 20"
@@ -938,14 +883,6 @@ echo "================================="
 		echo -e "sbox_maxspawners 0"
 		echo -e "sbox_maxturrets 0"
 		echo -e ""
-		echo -e "// Logging"
-		echo -e "log on"
-		echo -e "sv_logbans 1"
-		echo -e "sv_logecho 1"
-		echo -e "sv_logfile 1"
-		echo -e "sv_log_onefile 0"
-		echo -e "lua_log_sv 0"
-		echo -e ""
 		echo -e "// Misc Config"
 		echo -e "exec banned_user.cfg"
 		echo -e "exec banned_ip.cfg"

+ 38 - 92
NoMoreRoomInHell/nmrihserver

@@ -3,7 +3,7 @@
 # Server Management Script
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 041114
+# Version: 121114
 
 #### Variables ####
 
@@ -26,7 +26,7 @@ ip="0.0.0.0"
 
 # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
 fn_parms(){
-parms="-game nmrih -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
+parms="-game nmrih -insecure -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
 }
 
 #### Advanced Variables ####
@@ -200,46 +200,11 @@ fi
 }
 
 fn_debugserver(){
-fn_rootcheck
-fn_syscheck
-fn_autoip
-fn_distro
-fn_uptime
-fn_load
-fn_parms
-echo ""
-echo "${gamename} Debug"
-echo "============================"
-echo ""
-echo -e "Distro: ${os}"
-echo -e "Arch: ${arch}"
-echo -e "Kernel: ${kernel}"
-echo -e "Hostname: $HOSTNAME"
-echo ""
-echo "Start parameters:"
-echo ${parms}
-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 ""
-while true; do
-	read -p "Continue? [y/N]" yn
-	case $yn in
-	[Yy]* ) break;;
-	[Nn]* ) echo Exiting; return 1;;
-	* ) echo "Please answer yes or no.";;
-esac
-done
-fn_stopserver
-fn_printdots "Starting debug mode ${servicename}: ${servername}"
-sleep 1
-fn_printok "Starting debug mode ${servicename}: ${servername}"
-sleep 1
-fn_scriptlog "Started debug mode ${servername}"
-echo -en "\n"
-cd "${executabledir}"
-${executable} ${parms} -debug -insecure
+if [ ! -f functions/fn_debugserver ]; then
+	functionfile="fn_debugserver"
+	fn_fninstall
+fi
+source functions/fn_debugserver
 }
 
 fn_console(){
@@ -644,38 +609,27 @@ echo -en "\n"
 }
 
 fn_details(){
-fn_autoip
-servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
-rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')
-pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
-echo ""
-echo "${gamename} Server Details"
-echo "============================"
-echo "Server name: ${servername}"
-echo "Server IP: ${ip}:${port}"
-echo "RCON password: ${rcon}"
-echo "Config file: ${servercfgfullpath}"
-echo ""
-echo "${servername} Ports"
-echo "============================"
-echo "Ports the server is currently using."
-echo ""
-echo "DIRECTION	DESCRIPTION		PORT"
-echo "INBOUND		Game/RCON port		${port}"
-if [ ! -z ${sourcetvport} ]; then
-	echo "INBOUND		SourceTV port		${sourcetvport}"
+if [ ! -f functions/fn_details ]; then
+	functionfile="fn_details"
+	fn_fninstall
 fi
-echo "OUTBOUND	Client port		${clientport}"
-echo ""
-echo "You can change ports by editing the"
-echo "start parameters in ${selfname}."
-echo ""
-if [ "${pid}" == "0" ]; then
-	echo -e "Status:\e[0;31m OFFLINE\e[0;39m"
-else
-	echo -e "Status:\e[0;32m ONLINE\e[0;39m"
+source functions/fn_details
+}
+
+fn_fninstall(){
+cd ${rootdir}	
+if [ ! -d "functions" ]; then
+	mkdir functions
 fi
 echo ""
+echo "Downloading ${functionfile}"
+echo "================================="
+cd functions
+wget -nv -N https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile}
+chmod +x ${functionfile}
+cd ${rootdir}
+sleep 1
+echo ""
 }
 
 #
@@ -683,6 +637,10 @@ echo ""
 #
 
 fn_glibcfix(){
+if [ ! -f functions/fn_glibcfix ]; then
+	functionfile="fn_glibcfix"
+	fn_fninstall
+fi	
 source functions/fn_glibcfix
 }
 
@@ -697,14 +655,6 @@ echo "================================="
 echo ""
 }
 
-fn_fninstall(){
-mkdir functions
-cd functions
-wget -nv -N https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/fn_fninstall
-cd ${rootdir}
-source functions/fn_fninstall
-}
-
 fn_steamdl(){
 echo "Installing SteamCMD"
 echo "================================="
@@ -747,14 +697,11 @@ echo ""
 }
 
 fn_steamfix(){
-echo "Applying steamclient.so fix"
-echo "================================="
-sleep 1
-mkdir -pv "${HOME}/.steam"
-mkdir -pv "${HOME}/.steam/sdk32"
-cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so"
-sleep 1
-echo ""
+if [ ! -f functions/fn_steamfix ]; then
+	functionfile="fn_steamfix"
+	fn_fninstall
+fi	
+source functions/fn_steamfix
 }
 
 fn_loginstall(){
@@ -828,7 +775,6 @@ while true; do
 	esac
 done
 fn_header
-fn_fninstall
 fn_steamdl
 fn_steaminstall
 fn_steamfix
@@ -848,16 +794,16 @@ echo "================================="
 	echo "Creating ${servicename}.cfg config file."
 	touch "${servercfgfullpath}"
 	{
-		echo -e "// server name"
+		echo -e "// Server Name"
 		echo -e "hostname \"${servername}\""
 		echo -e ""
-		echo -e "// rcon passsword"
+		echo -e "// RCON Password"
 		echo -e "rcon_password \"${rconpass}\""
 		echo -e ""
-		echo -e "// Server password"
+		echo -e "// Server Password"
 		echo -e "sv_password \"\""
 		echo -e ""
-		echo -e "// server logging"
+		echo -e "// Server Logging"
 		echo -e "log on"
 		echo -e "sv_logbans 1"
 		echo -e "sv_logecho 1"