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

Merged update-restart and validate-restart

Update restart requirement detection - This will merge "update" and
"update-restart". If the server is online and an update is required the
server will restart during update. If there is an update but the server
is offline there is no requirement to restart.
Daniel Gibbs 11 лет назад
Родитель
Сommit
904df3a3b9
3 измененных файлов с 30 добавлено и 28 удалено
  1. 3 17
      functions/fn_getopt
  2. 10 7
      functions/fn_update_check
  3. 17 4
      functions/fn_validate

+ 3 - 17
functions/fn_getopt

@@ -2,7 +2,7 @@
 # LGSM fn_getopt function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 150314
+# Version: 150414
 
 # Description: getopt arguments.
 
@@ -15,16 +15,9 @@ case "$getopt" in
 	restart)
 		fn_restart;;
 	update)
-		norestart=1;
-		fn_update_check;;
-	update-restart)
 		fn_update_check;;
 	validate)
 		fn_validate;;
-	validate-restart)
-		fn_stop
-		fn_validate
-		fn_start;;
 	monitor)
 		fn_monitor;;
 	email-test)
@@ -42,7 +35,7 @@ case "$getopt" in
 	auto-install)
 		fn_autoinstall;;
 	*)
-	echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install}"
+	echo "Usage: $0 {start|stop|restart|update|validate|monitor|email-test|details|backup|console|debug|install|auto-install}"
 	exit 1;;
 esac
 exit
@@ -116,16 +109,9 @@ case "$getopt" in
 	restart)
 		fn_restart;;
 	update)
-		norestart=1;
-		fn_update_check;;
-	update-restart)
 		fn_update_check;;
 	validate)
 		fn_validate;;
-	validate-restart)
-		fn_stop
-		fn_validate
-		fn_start;;
 	monitor)
 		fn_monitor;;
 	email-test)
@@ -145,7 +131,7 @@ case "$getopt" in
 	map-compressor)
 		fn_compress_unreal2maps;;
 	*)
-	echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}"
+	echo "Usage: $0 {start|stop|restart|update|validate|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}"
 	exit 1;;
 esac
 exit

+ 10 - 7
functions/fn_update_check

@@ -2,7 +2,7 @@
 # LGSM fn_update_check function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 150315
+# Version: 150415
 
 # Description: Checks if a server update is available.
 
@@ -84,12 +84,13 @@ if [ "${requestrestart}" -ge "1" ]; then
 	echo -ne "Applying update...\r"
 	sleep 1
 	echo -ne "\n"
-	if [ ! -z "${norestart}" ]; then
-		fn_update_dl
-	else
+	tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
+	if [ "${tmuxwc}" -eq 1 ]; then
 		fn_stop
 		fn_update_dl
 		fn_start
+	else
+		fn_update_dl
 	fi
 else
 	fn_printok "Checking for update: Server logs: No update requested"
@@ -145,12 +146,14 @@ if [ "${currentbuild}" -ne "${availablebuild}" ]; then
 	fn_scriptlog "Current build: ${currentbuild}"
 	fn_scriptlog "Available build: ${availablebuild}"
 	fn_scriptlog "${currentbuild} > ${availablebuild}"
-	if [ ! -z "${norestart}" ]; then
-		fn_update_dl
-	else
+
+	tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
+	if [ "${tmuxwc}" -eq 1 ]; then
 		fn_stop
 		fn_update_dl
 		fn_start
+	else
+		fn_update_dl
 	fi
 else
 	echo -e "\n"

+ 17 - 4
functions/fn_validate

@@ -2,13 +2,13 @@
 # LGSM fn_validate function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 210115
+# Version: 150415
 
 # Description: Runs a server validation.
 
 local modulename="Validate"
-fn_check_root
-fn_check_systemdir
+
+fn_validation(){
 fn_printwarn "Validating may overwrite some customised files."
 sleep 1
 echo -en "\n"
@@ -23,4 +23,17 @@ sleep 1
 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"
+fn_scriptlog "Checking complete"
+}
+
+
+fn_check_root
+fn_check_systemdir
+tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
+if [ "${tmuxwc}" -eq 1 ]; then
+	fn_stop
+	fn_validation
+	fn_start
+else
+	fn_validation
+fi