#!/bin/sh #------------------------------------------------------------------------------ # /var/install/config.d/automx-check-mail-config - check automx mail config # # Copyright (c) 2015-2021 The Eisfair Team, team(at)eisfair(dot)org # # Creation : 2017-11-03 jed # Last Update: $Id$ # # Usage: automx-check-mail-account.sh email-address - return login account # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #------------------------------------------------------------------------------ # read eislib etc. . /var/install/include/eislib . /var/install/include/jedlib # debug mode: true/false #debug=true if ${debug:-false} then exec 2>/tmp/$(basename ${0})-trace$$.log set -x ask_debug=true export ask_debug fi pgmname=`basename $0` module_name=`echo "${pgmname}" | cut -d- -f1` tmpfile=/var/run/${pgmname}-tmp.$$ interactive=0 if [ $# -eq 0 ] then clrhome mecho --info "Check automx email configuration" mecho _ask_file=$(/bin/mktemp -t ${pgmname}-ask.XXXXXXXXX) /var/install/bin/ask "Enter valid email address, ENTER=Return, 0=Exit)" "" "*" > ${_ask_file} rc=$? email_addr="`cat ${_ask_file} | head -n1 | sed 's/\/$//' | tr '[:upper:]' '[:lower:]'`" rm -f ${_ask_file} if [ ${rc} = 255 ] then exit 4 fi case "${email_addr}" in '' ) # quit program exit 0 ;; 0 ) exit 3 ;; * ) # go on... echo ;; esac else email_addr="`echo "$1" | tr '[:upper:]' '[:lower:]'`" fi # extract local part local.part@domain.lan echo "${email_addr}" | grep -q '@' if [ $? -eq 0 ] then rm -f ${tmpfile} { echo "Checking email address: ${email_addr}" echo "---------------------------------------------------------------------------" /usr/bin/automx-test ${email_addr} exit_code=$? echo "---------------------------------------------------------------------------" echo "EXIT:${exit_code}" } >> ${tmpfile} 2>> ${tmpfile} if [ ${exit_code} -ne 0 ] then mecho --error "Error executing command '/usr/bin/automx-test'. Check results!" anykey fi if [ -s ${tmpfile} ] then /var/install/bin/show-doc.cui ${color} ${frame} --title "Show automx configuration check results" ${tmpfile} fi rm -f ${tmpfile} else # error exit_code=2 echo "Error: Invalid email address given!" fi exit ${exit_code}