4
0
Эх сурвалжийг харах

refactor: improve logging and error handling in command_update_linuxgsm.sh

- Refactored log messages for better clarity and readability.
- Improved error handling by checking the return value of curl command.
- Updated backup location log message to include brackets.
Daniel Gibbs 2 жил өмнө
parent
commit
ce0fad562c

+ 10 - 10
lgsm/modules/command_update_linuxgsm.sh

@@ -36,7 +36,7 @@ else
 fi
 fi
 
 
 # Check linuxsm.sh
 # Check linuxsm.sh
-echo -en "checking ${remotereponame} [ linuxgsm.sh ]\c"
+echo -en "checking ${remotereponame} script [ linuxgsm.sh ]\c"
 if [ "${remotereponame}" == "GitHub" ]; then
 if [ "${remotereponame}" == "GitHub" ]; then
 	curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
 	curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
 else
 else
@@ -44,7 +44,7 @@ else
 fi
 fi
 if [ $? != "0" ]; then
 if [ $? != "0" ]; then
 	fn_print_fail_eol_nl
 	fn_print_fail_eol_nl
-	fn_script_log_fatal "Checking ${remotereponame} linuxgsm.sh"
+	fn_script_log_fatal "Checking ${remotereponame} script linuxgsm.sh"
 	fn_script_log_fatal "Curl returned error: $?"
 	fn_script_log_fatal "Curl returned error: $?"
 	core_exit.sh
 	core_exit.sh
 fi
 fi
@@ -57,37 +57,37 @@ fi
 
 
 if [ "${tmp_script_diff}" != "" ]; then
 if [ "${tmp_script_diff}" != "" ]; then
 	fn_print_update_eol_nl
 	fn_print_update_eol_nl
-	fn_script_log "Checking ${remotereponame} linuxgsm.sh"
+	fn_script_log "Checking ${remotereponame} script linuxgsm.sh"
 	rm -f "${tmpdir:?}/linuxgsm.sh"
 	rm -f "${tmpdir:?}/linuxgsm.sh"
 	fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "nochmodx" "norun" "noforcedl" "nohash"
 	fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "nochmodx" "norun" "noforcedl" "nohash"
 else
 else
 	fn_print_update_eol_nl
 	fn_print_update_eol_nl
-	fn_script_log_pass "Checking ${remotereponame} linuxgsm.sh"
+	fn_script_log_pass "Checking ${remotereponame} script linuxgsm.sh"
 fi
 fi
 
 
 # Check gameserver.sh
 # Check gameserver.sh
 # Compare gameserver.sh against linuxgsm.sh in the tmp dir.
 # Compare gameserver.sh against linuxgsm.sh in the tmp dir.
 # Ignoring server specific vars.
 # Ignoring server specific vars.
-echo -en "checking [ ${selfname} ]\c"
+echo -en "checking script [ ${selfname} ]\c"
 fn_script_log_info "Checking ${selfname}"
 fn_script_log_info "Checking ${selfname}"
 script_diff=$(diff <(sed '\/shortname/d;\/gameservername/d;\/gamename/d;\/githubuser/d;\/githubrepo/d;\/githubbranch/d' "${tmpdir}/linuxgsm.sh") <(sed '\/shortname/d;\/gameservername/d;\/gamename/d;\/githubuser/d;\/githubrepo/d;\/githubbranch/d' "${rootdir}/${selfname}"))
 script_diff=$(diff <(sed '\/shortname/d;\/gameservername/d;\/gamename/d;\/githubuser/d;\/githubrepo/d;\/githubbranch/d' "${tmpdir}/linuxgsm.sh") <(sed '\/shortname/d;\/gameservername/d;\/gamename/d;\/githubuser/d;\/githubrepo/d;\/githubbranch/d' "${rootdir}/${selfname}"))
 if [ "${script_diff}" != "" ]; then
 if [ "${script_diff}" != "" ]; then
 	fn_print_update_eol_nl
 	fn_print_update_eol_nl
-	fn_script_log "Checking ${selfname}"
+	fn_script_log "Checking script ${selfname}"
 	echo -en "backup ${selfname}\c"
 	echo -en "backup ${selfname}\c"
-	fn_script_log_info "Backup ${selfname}"
+	fn_script_log_info "Backup script ${selfname}"
 	if [ ! -d "${backupdir}/script" ]; then
 	if [ ! -d "${backupdir}/script" ]; then
 		mkdir -p "${backupdir}/script"
 		mkdir -p "${backupdir}/script"
 	fi
 	fi
 	cp "${rootdir}/${selfname}" "${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak"
 	cp "${rootdir}/${selfname}" "${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak"
 	if [ $? != 0 ]; then
 	if [ $? != 0 ]; then
 		fn_print_fail_eol_nl
 		fn_print_fail_eol_nl
-		fn_script_log_fatal "Backup ${selfname}"
+		fn_script_log_fatal "Backup script ${selfname}"
 		core_exit.sh
 		core_exit.sh
 	else
 	else
 		fn_print_ok_eol_nl
 		fn_print_ok_eol_nl
-		fn_script_log_pass "Backup ${selfname}"
-		echo -e "backup location ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak"
+		fn_script_log_pass "Backup script${selfname}"
+		echo -e "backup location [ ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak ]"
 		fn_script_log_pass "Backup location ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak"
 		fn_script_log_pass "Backup location ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak"
 	fi
 	fi