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

Merge pull request #349 from chriskoepf/master

SDTD custom code
Daniel Gibbs 11 лет назад
Родитель
Сommit
54636df8c9
3 измененных файлов с 81 добавлено и 17 удалено
  1. 19 3
      7DaysToDie/sdtdserver
  2. 35 13
      functions/fn_stop
  3. 27 1
      functions/fn_validate

+ 19 - 3
7DaysToDie/sdtdserver

@@ -13,11 +13,27 @@ emailnotification="off"
 email="email@example.com"
 
 # Steam login
-steamuser="username"
-steampass="password"
+steamuser="username"  # 7 Days requires a registered user for downloads
+steampass="password"  # enter your password
 
 # Start Variables
-ip="0.0.0.0"
+ip="0.0.0.0"  # can leave to answer on any IP
+
+# Telnet Variables - used for graceful shutdown
+telnetip="127.0.0.1"  # if 127.0.0.1 doesn't work, enter your public IP
+telnetport="8081"     # change to your customized port number
+telnetpass="password" # set for your telnet password
+
+# Mod Variables
+
+# If you are using or want to use Alloc's Server Fixes,
+# uncomment the variable below
+# *****Note: It has happened where the core gets updated, but
+# Alloc's fixes weren't updated yet. If this happens
+# you may need to comment out or set to false temporarily
+# until Alloc's patch is updated.  Please see 7 Days To Die
+# forum for details.  Many people use this patch.
+allocsfixes=true  # set to true if you want installed, false or comment if not
 
 # http://7daystodie.gamepedia.com/Server
 fn_parms(){

+ 35 - 13
functions/fn_stop

@@ -37,23 +37,45 @@ fn_printdots "${servername}"
 fn_scriptlog "${servername}"
 sleep 1
 fn_check_tmux
-pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
-if [ "${pid}" == "0" ]; then
-	fn_printfail "${servername} is already stopped"
-	fn_scriptlog "${servername} is already stopped"
+
+if [ "${gamename}" == "7 Days To Die" ] ; then
+        # if game is 7 Days To Die, we need special, graceful shutdown via telnet connection.
+        # Set below variable to be called for expect to operate correctly..
+
+                sdtdshutdown=$( expect -c '
+                proc abort {} {
+                        puts "Timeout or EOF\n"
+                        exit 1
+                }
+                spawn telnet '"${telnetip}"' '"${telnetport}"'
+                expect {
+                        "password:"     { send "'"${telnetpass}"'\r" }
+                        default         abort
+                }
+                expect {
+                        "session."  { send "shutdown\r" }
+                        default         abort
+                }
+                expect { eof }
+                puts "Completed.\n"
+                ')
+                echo -en "\n ${sdtdshutdown}"
+                fn_printok "${servername}"
+                fn_scriptlog "Performmed graceful shutdown of ${servername}"
 else
-	tmux kill-session -t ${servicename}
-	fn_printok "${servername}"
-	fn_scriptlog "Stopped ${servername}"
+    	pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
+        if [ "${pid}" == "0" ]; then
+                fn_printfail "${servername} is already stopped"
+                fn_scriptlog "${servername} is already stopped"
+        else
+            	tmux kill-session -t ${servicename}
+                fn_printok "${servername}"
+                fn_scriptlog "Stopped ${servername}"
+        fi
 fi
-# Remove lock file
-rm -f "${rootdir}/${lockselfname}"
-sleep 1
-echo -en "\n"
-}
 
 if [ "${gamename}" == "Teamspeak 3" ]; then
 	fn_stop_teamspeak3
 else
 	fn_stop_tmux
-fi
+fi

+ 27 - 1
functions/fn_validate

@@ -24,8 +24,34 @@ 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"
-}
 
+# addition for 7 Days to Die - very popular server addon run on most dedicated servers
+# file validation breaks this addon and it requires re-installation each time.
+if [ "${allocsfixes}" = true ]; then
+        sleep 5
+        fn_scriptlog "Installing Alloc's Server Fixes"
+        echo -en "\n"
+        sleep 5
+        echo -en "Installing Alloc's Server Fixes\n"
+        cd "${rootdir}"/serverfiles/
+        rm -rf server_fixes.tar.gz
+        wget http://illy.bz/fi/7dtd/server_fixes.tar.gz
+        if [ -f "server_fixes.tar.gz" ]; then
+                tar -xzf server_fixes.tar.gz
+                rm -rf server_fixes.tar.gz
+                fn_scriptlog "Server Fixes Installed"
+                echo -en "Alloc's Server Fixes have been installed.\n"
+        else
+            	if [ ! -f "server_fixes.tar.gz" ]; then
+                        fn_scriptlog "Error downloading Server Fixes!"
+                fi
+                echo -en "There was a problem installing Alloc's Server Fixes!"
+        fi
+
+	fn_scriptlog "Alloc's Server Fixes installed."
+        echo -en "FAlloc's Server Fixes installed.\n"
+fi
+}
 
 fn_check_root
 fn_check_systemdir