Bladeren bron

feat: bypass termbin if site is down

Daniel Gibbs 1 jaar geleden
bovenliggende
commit
64980655f4
1 gewijzigde bestanden met toevoegingen van 19 en 10 verwijderingen
  1. 19 10
      lgsm/modules/command_postdetails.sh

+ 19 - 10
lgsm/modules/command_postdetails.sh

@@ -58,18 +58,27 @@ else
 fi
 
 fn_print_dots "termbin.com"
-link=$(cat "${postdetailslog}" | nc termbin.com 9999 | tr -d '\n\0')
-fn_print_ok_nl "termbin.com for 30D"
-fn_script_log_pass "termbin.com for 30D"
-pdurl="${link}"
+link=$(cat "${postdetailslog}" | {
+	nc -w 3 termbin.com 9999
+	echo $? > /tmp/nc_exit_status
+} | tr -d '\n\0')
+nc_exit_status=$(cat /tmp/nc_exit_status)
+if [ "${nc_exit_status}" -ne 0 ]; then
+	fn_print_error_nl "Failed to post to termbin.com"
+	fn_script_log_error "Failed to post to termbin.com"
+else
+	fn_print_ok_nl "termbin.com for 30D"
+	fn_script_log_pass "termbin.com for 30D"
+	pdurl="${link}"
 
-if [ "${firstcommandname}" == "POST-DETAILS" ]; then
-	echo -e ""
-	echo -e "Please share the following url for support: "
-	echo -e "${italic}${pdurl}${default}"
+	if [ "${firstcommandname}" == "POST-DETAILS" ]; then
+		echo -e ""
+		echo -e "Please share the following url for support: "
+		echo -e "${italic}${pdurl}${default}"
+	fi
+	fn_script_log_info "${pdurl}"
+	alerturl="${pdurl}"
 fi
-fn_script_log_info "${pdurl}"
-alerturl="${pdurl}"
 
 if [ -z "${exitbypass}" ]; then
 	core_exit.sh