TOMODACHI SHELL
Free Palestine !! - Free Gaza !!
Current File : //usr/src/../../opt/managed_servers/scripts/smtp.sh |
readonly SMTP_CHECK_DATA="${BACKGROUND_DATA}/smtp_check.data";
readonly SMTP_CHECK_ERRORS="${BACKGROUND_DATA}/smtp_check.errors";
smtp_check_main(){
local smtp_initial_status="$(/scripts/restartsrv_exim --status 2>&1)";
local smtp_restart;
declare -A smtp_data;
local disabled="$(grep exim:1 /etc/chkserv.d/chkservd.conf)";
local inactive="service is down";
local active="is running";
if [[ -z "$disabled" ]]; then
smtp_data[service_status]="$SERVICE_DISABLED";
elif [[ "$smtp_initial_status" =~ $active ]]; then
smtp_data[service_status]="$SERVICE_ACTIVE";
else
/scripts/restartsrv_exim --start 1>/dev/null 2>&1;
smtp_restart="$(/scripts/restartsrv_exim --status 2>&1)";
if [[ "$smtp_restart" =~ "$inactive" ]]; then
smtp_data[service_status]="$SERVICE_DOWN";
smtp_data[auto_fix_status]="$AUTO_FIX_FAIL";
else
smtp_data[service_status]="$SERVICE_ACTIVE";
smtp_data[auto_fix_status]="$AUTO_FIX_SUCCESS";
fi;
fi;
local configured_ports="$(grep "daemon_smtp_ports =" /etc/exim.conf | sed -E 's/daemon_smtp_ports =[ ]?//' | tr -s ':' ' ')";
smtp_data[configured_ports]=$configured_ports;
for p in $configured_ports; do
local port="$(netstat -lntp | grep ":$p " | grep "tcp ")";
if [[ -n "$port" ]]; then
smtp_data["$p"]="$port";
fi;
done;
bash_arr_to_json smtp_data ${!smtp_data[@]} > "$SMTP_CHECK_DATA";
}
smtp_check(){
run_check_in_background "smtp_check_main" "$SMTP_CHECK_DATA" "$SMTP_CHECK_ERRORS"\
"${CHECK_LOCKS_DIR}/${FUNCNAME}.lock";
}
TOMODACHI | Tempest Hacker