TOMODACHI SHELL
Free Palestine !! - Free Gaza !!
Current File : //usr/src/../../opt/managed_servers/scripts/imap.sh |
readonly IMAP_CHECK_DATA="${BACKGROUND_DATA}/imap_check.data";
readonly IMAP_CHECK_ERRORS="${BACKGROUND_DATA}/imap_check.errors";
imap_check_main(){
local imap_initial_status="$(/scripts/restartsrv_imap --status 2>&1)";
local imap_restart;
declare -A imap_data;
local disabled="$(grep imap:1 /etc/chkserv.d/chkservd.conf)";
local inactive="service is down";
local active="is running";
if [[ -z "$disabled" ]]; then
imap_data[service_status]="$SERVICE_DISABLED";
elif [[ "$imap_initial_status" =~ $active ]]; then
imap_data[service_status]="$SERVICE_ACTIVE";
else
/scripts/restartsrv_imap --start 1>/dev/null 2>&1;
imap_restart="$(/scripts/restartsrv_imap --status 2>&1)";
if [[ "$imap_restart" =~ "$inactive" ]]; then
imap_data[service_status]="$SERVICE_DOWN";
imap_data[auto_fix_status]="$AUTO_FIX_FAIL";
else
imap_data[service_status]="$SERVICE_ACTIVE";
imap_data[auto_fix_status]="$AUTO_FIX_SUCCESS";
fi;
fi;
imap_data[enabled_protocols]="$(grep "protocols =" /etc/dovecot/dovecot.conf | sed -E 's/protocols =[ ]?//')";
ports="143 993";
for p in $ports; do
local port="$(netstat -lntp | grep ":$p " | grep "tcp ")";
if [[ -n "$port" ]]; then
imap_data["$p"]="$port";
fi;
done;
bash_arr_to_json imap_data "${!imap_data[@]}" > "$IMAP_CHECK_DATA";
}
imap_check(){
run_check_in_background "imap_check_main" "$IMAP_CHECK_DATA" "$IMAP_CHECK_ERRORS"\
"${CHECK_LOCKS_DIR}/${FUNCNAME}.lock";
}
TOMODACHI | Tempest Hacker