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

Merged feature/alertperms into develop

Daniel Gibbs 9 лет назад
Родитель
Сommit
3acedcc7ce

+ 11 - 3
lgsm/functions/alert.sh

@@ -31,14 +31,22 @@ fn_alert_update(){
 	alertbody="${servicename} received update"
 }
 
-if [ "${alert}" == "restart" ]; then
+fn_alert_permissions(){
+	fn_script_log_info "Sending permissions error alert"
+	alertsubject="LinuxGSM - Error - ${servername}"
+	alertbody="${servicename} has permissions issues."
+}
+
+if [ "${alert}" == "permissions" ]; then
+	fn_alert_permissions
+elif [ "${alert}" == "restart" ]; then
 	fn_alert_restart
 elif [ "${alert}" == "restartquery" ]; then
 	fn_alert_restart_query
-elif [ "${alert}" == "update" ]; then
-	fn_alert_update
 elif [ "${alert}" == "test" ]; then
 	fn_alert_test
+elif [ "${alert}" == "update" ]; then
+	fn_alert_update
 fi
 
 if [ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then

+ 4 - 1
lgsm/functions/check.sh

@@ -12,7 +12,10 @@ local commandname="CHECK"
 
 check_root.sh
 check_tmuxception.sh
-check_permissions.sh
+
+if [ "${function_selfname}" != "command_monitor.sh" ];then
+	check_permissions.sh
+fi
 
 if [ "${function_selfname}" != "command_install.sh" ]&&[ "${function_selfname}" != "command_update_functions.sh" ]; then
 	check_system_dir.sh

+ 21 - 2
lgsm/functions/check_permissions.sh

@@ -6,7 +6,6 @@
 # Description: Checks ownership & permissions of scripts, files and directories.
 
 local commandname="CHECK"
-local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_check_ownership(){
 	if [ -f "${rootdir}/${selfname}" ]; then
@@ -43,8 +42,12 @@ fn_check_ownership(){
 
 		} | column -s $'\t' -t | tee -a "${scriptlog}"
 		echo ""
-		fn_print_information_nl "For more information, please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-ownership-issues-found"
+		fn_print_information_nl "please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-ownership-issues-found"
 		fn_script_log "For more information, please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-ownership-issues-found"
+		if [ "${monitorflag}" == 1 ]; then
+			alert="permissions"
+			alert.sh
+		fi
 		core_exit.sh
 	fi
 }
@@ -60,6 +63,10 @@ fn_check_permissions(){
 				echo -e "File\n"
 				find "${functionsdir}" -type f -not -executable -printf "%p\n"
 			} | column -s $'\t' -t | tee -a "${scriptlog}"
+			if [ "${monitorflag}" == 1 ]; then
+				alert="permissions"
+				alert.sh
+			fi
 			core_exit.sh
 		fi
 	fi
@@ -78,6 +85,10 @@ fn_check_permissions(){
 			fn_script_log_info "The following directory does not have the correct permissions:"
 			fn_script_log_info "${rootdir}"
 			ls -l "${rootdir}"
+			if [ "${monitorflag}" == 1 ]; then
+				alert="permissions"
+				alert.sh
+			fi
 			core_exit.sh
 		fi
 	fi
@@ -118,6 +129,10 @@ fn_check_permissions(){
 					ls -l "${executabledir}/${execname}"
 					fn_script_log_warn "The following file could not be set executable:"
 					fn_script_log_info "${executabledir}/${execname}"
+					if [ "${monitorflag}" == 1 ]; then
+						alert="permissions"
+						alert.sh
+					fi
 					core_exit.sh
 					fi
 				fi
@@ -157,6 +172,10 @@ fn_sys_perm_fix_manually_msg(){
 	echo "	  chmod a+rx /sys /sys/class /sys/class/net"
 	fn_script_log "chmod a+rx /sys /sys/class /sys/class/net"
 	sleep 1
+	if [ "${monitorflag}" == 1 ]; then
+		alert="permissions"
+		alert.sh
+	fi
 	core_exit.sh
 }
 

+ 1 - 0
lgsm/functions/command_monitor.sh

@@ -98,6 +98,7 @@ fn_monitor_tmux(){
 	fi
 }
 
+monitorflag=1
 fn_print_dots "${servername}"
 sleep 1
 check.sh