[email_account] Redirect error messages to stderr
This commit is contained in:
parent
16960f727c
commit
779c586029
|
@ -25,13 +25,13 @@ test_email ()
|
|||
user=$(echo "$1" | cut -d '@' -f 1)
|
||||
if [ -z "$user" ]
|
||||
then
|
||||
echo "Error! Missing user in email account."
|
||||
echo "Error! Missing user in email account." >&2
|
||||
exit 1
|
||||
fi
|
||||
domain=$(echo "$1" | cut -d '@' -f 2)
|
||||
if echo "$domain" | grep -E -v "^([[:alnum:]]+\.)+[[:alnum:]]+$" > /dev/null
|
||||
then
|
||||
echo "Error! Invalid domain for email account."
|
||||
echo "Error! Invalid domain for email account." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ test_args ()
|
|||
local - user domain first_ask next_ask
|
||||
if [ \( $# -ge 1 -a "$1" = "-h" -a $# -gt 1 \) -o $# -gt 2 ]
|
||||
then
|
||||
echo "Error! Too many arguments."
|
||||
echo "Error! Too many arguments." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ $# -eq 0 -o "$1" = "-h" -o "$1" = "-help" ]
|
||||
|
@ -84,7 +84,7 @@ test_args ()
|
|||
aliasdomain="$domain"
|
||||
if [ "$emaildomain" != "$aliasdomain" ]
|
||||
then
|
||||
echo "Error! Domain of the alias must be identical to the domain of the email account."
|
||||
echo "Error! Domain of the alias must be identical to the domain of the email account." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -117,7 +117,7 @@ try_sudo ()
|
|||
ret=$?
|
||||
if [ ! $ret -eq 0 ]
|
||||
then
|
||||
echo "Error! You must be root or being able to become root by sudo without password to create an email account or add an email alias."
|
||||
echo "Error! You must be root or being able to become root by sudo without password to create an email account or add an email alias." >&2
|
||||
fi
|
||||
exit $ret
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ test_cyrus_admin ()
|
|||
local -
|
||||
cyruser=$(grep -E "^[[:space:]]*admins:" /etc/imapd.conf | cut -d ':' -f 2- | sed -r "s/[[:alnum:]]+@[[:alnum:].]+//g" | tr -d ' ')
|
||||
cyrpwd=$(cat /root/cyrus_main_admin_password)
|
||||
testsaslauthd -u $cyruser -p $cyrpwd > /dev/null || { echo "Error! Password for main cyrus admin has changed but has not been modified in /root/" && exit 1 ; }
|
||||
testsaslauthd -u $cyruser -p $cyrpwd > /dev/null || { echo "Error! Password for main cyrus admin has changed but has not been modified in /root/" >&2 && exit 1 ; }
|
||||
}
|
||||
|
||||
# Save cyrus state and make it cyradm ready, that is save and change
|
||||
|
@ -143,8 +143,8 @@ save_cyrus_state_and_become_cyradm_ready ()
|
|||
invoke-rc.d cyrus2.2 restart
|
||||
if [ ! $? -eq 0 ]
|
||||
then
|
||||
echo "Error! Restarting cyrus failed. The requested action coudn't be performed."
|
||||
echo "Look at the logs and restart Cyrus manually."
|
||||
echo "Error! Restarting cyrus failed. The requested action coudn't be performed." >&2
|
||||
echo "Look at the logs and restart Cyrus manually." >&2
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
|
@ -343,13 +343,13 @@ restore_cyrus_state ()
|
|||
invoke-rc.d --quiet cyrus2.2 restart
|
||||
if [ ! $? -eq 0 ]
|
||||
then
|
||||
echo "Error! Restarting cyrus failed."
|
||||
echo "Error! Restarting cyrus failed." >&2
|
||||
exit 1
|
||||
fi
|
||||
invoke-rc.d --quiet postfix reload
|
||||
if [ ! $? -eq 0 ]
|
||||
then
|
||||
echo "Error! Reloading postfix failed."
|
||||
echo "Error! Reloading postfix failed." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue