check_sympa_spool_msg_dir.sh: some changes to the script output.

This commit is contained in:
Christoph 2022-10-17 12:27:22 +02:00
parent 67063f7702
commit 57efdc4175

View File

@ -62,7 +62,7 @@ error (){
if $terminal ; then
echo -e " [ \033[31m\033[1mError\033[m ]: $*"
else
echo "[ Error ]: $*"
echo " [ Error ]: $*"
fi
echo ""
}
@ -78,7 +78,7 @@ warn (){
info (){
if $terminal ; then
echo ""
echo -e " [ \033[32m\033[1mInfo\033[m ] $*"
echo -e " [ \033[32m\033[1mInfo\033[m ]: $*"
echo ""
fi
}
@ -361,7 +361,17 @@ if [[ ${#potential_critical_msg_file[@]} -lt 1 ]] ; then
\033[1mAll is fine.\033[m - Script ends here."
if [[ -d "${TMP_SPOOL_MSG_DIR}" ]] ; then
rm -rf "${TMP_SPOOL_MSG_DIR}"
if ! $terminsl ; then
echo ""
echo -e " [ Info ]: No critical message(s) in folder '${SYMPA_SPOOL_MSG_DIR}' found.
."
echo ""
fi
fi
clean_up 0
else
blank_line
@ -420,6 +430,7 @@ if $terminal ; then
echo ""
fi
_found_file_second_time=false
if ! $tmp_spool_msg_folder_exists ; then
for _file in ${potential_critical_msg_file[@]} ; do
echononl "Copy file \033[1m${_file}\033[m into ${TMP_SPOOL_MSG_DIR}.."
@ -433,11 +444,10 @@ if ! $tmp_spool_msg_folder_exists ; then
fi
done
clean_up 0
fi
#clean_up 0
else
_found_file_second_time=false
for _file in ${potential_critical_msg_file[@]} ; do
for _file in ${potential_critical_msg_file[@]} ; do
if containsElement "$_file" "${tmp_potential_critical_msg_file[@]}" ; then
@ -479,27 +489,56 @@ for _file in ${potential_critical_msg_file[@]} ; do
fi
done
done
fi
if ! $_found_file_second_time ; then
# ----------
# - Some post-script tasks ..
# ----------
if $terminal ; then
blank_line
info "Right now there is nothing more to do as the critical files have been found for the first time."
else
echo ""
echo -e " [ Info ]: Right now there is nothing more to do as the critical files have been found
for the first time."
echo ""
fi
if $terminal ; then
else
# ----------
# - Some post-script tasks ..
# ----------
if $terminal ; then
echo ""
echo ""
echo -e " \033[1mDoing some post-script tasks ..\033[m"
echo ""
fi
else
echo ""
echo -e " [ Info ]: Critical files have been removed from the spool directory. '${SYMPA_SPOOL_MSG_DIR}'"
echo ""
fi
# If directory ${TMP_SPOOL_MSG_DIR} is empty remove it.
#
echononl "Remove directory \033[1m${TMP_SPOOL_MSG_DIR}\033[m.."
if $(is_empty_directory "${TMP_SPOOL_MSG_DIR}") ; then
# If directory ${TMP_SPOOL_MSG_DIR} is empty remove it.
#
echononl "Remove directory \033[1m${TMP_SPOOL_MSG_DIR}\033[m.."
if $(is_empty_directory "${TMP_SPOOL_MSG_DIR}") ; then
rmdir "${TMP_SPOOL_MSG_DIR}" > $log_file 2>&1
if [[ $? -lt 1 ]] ; then
echo_done
if $terminal ; then
echononl "Try to (re)start sympa service.."
else
echo ""
echo " [ Info ]: Try restarting sympa service now.."
echo ""
fi
#systemctl restart sympa > $log_file 2>&1
if [[ $? -lt 1 ]] ; then
echo_done
else
@ -507,21 +546,24 @@ if $(is_empty_directory "${TMP_SPOOL_MSG_DIR}") ; then
error "$(cat $log_file)"
fi
else
echo_skipped
warn "Directory \033[1m${TMP_SPOOL_MSG_DIR}\033[m is not empty!"
fi
if $_found_file_second_time ; then
echononl "Try to (ee)start sympa service.."
systemctl restart sympa > $log_file 2>&1
if [[ $? -lt 1 ]] ; then
echo_done
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
if $terminal ; then
warn "Directory \033[1m${TMP_SPOOL_MSG_DIR}\033[m is not empty!"
else
echo ""
echo " [ Warn ]: Directory '${TMP_SPOOL_MSG_DIR}' is not empty.
Now, awaiting next run of this script.."
echo ""
fi
fi
fi