فهرست منبع

refactor: improve logging and error handling in install_config.sh

- Refactored the code to use more descriptive function names.
- Improved logging by using fn_print_ok_eol and fn_print_failure_eol functions.
- Added error handling for copying config files, displaying failure messages if necessary.
- Updated comments for better clarity.
Daniel Gibbs 2 سال پیش
والد
کامیت
e02d2128fa
1فایلهای تغییر یافته به همراه10 افزوده شده و 4 حذف شده
  1. 10 4
      lgsm/modules/install_config.sh

+ 10 - 4
lgsm/modules/install_config.sh

@@ -58,10 +58,10 @@ fn_default_config_remote() {
 			exitcode=$?
 			exitcode=$?
 		fi
 		fi
 		if [ "${exitcode}" != 0 ]; then
 		if [ "${exitcode}" != 0 ]; then
-			fn_print_failure_nl
+			fn_print_failure_eol
 			fn_script_log_fatal "copying config file ${servercfg}."
 			fn_script_log_fatal "copying config file ${servercfg}."
 		else
 		else
-			fn_print_ok_nl
+			fn_print_ok_eol
 			fn_script_log_pass "copying config file ${servercfg}."
 			fn_script_log_pass "copying config file ${servercfg}."
 		fi
 		fi
 	done
 	done
@@ -70,9 +70,15 @@ fn_default_config_remote() {
 
 
 # Copys local default config to server config location.
 # Copys local default config to server config location.
 fn_default_config_local() {
 fn_default_config_local() {
-	echo -e "copying ${servercfgdefault} config file."
+	echo -e "copying config file [ ${servercfgdefault} ]"
 	cp -nv "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
 	cp -nv "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
-	fn_sleep_time
+	if [ "${exitcode}" != 0 ]; then
+		fn_print_failure_eol
+		fn_script_log_fatal "copying config file [ ${servercfgdefault} ]"
+	else
+		fn_print_ok_eol
+		fn_script_log_pass "copying config file [ ${servercfgdefault} ]"
+	fi
 }
 }
 
 
 # Changes some variables within the default configs.
 # Changes some variables within the default configs.