From f1c6ab699b84b1bd62cde4ce04510316ea02e62b Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Wed, 20 Jan 2010 17:14:16 +0100 Subject: [PATCH] [email_account] Ask about restart after sudoing Ask if the user is ready to restart only after performing the eventual sudo --- email_account/email_account | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/email_account/email_account b/email_account/email_account index 2e4e4a5..42e6254 100755 --- a/email_account/email_account +++ b/email_account/email_account @@ -62,7 +62,7 @@ ask_user_default_no () # Test number of argument is correct and their value are correct also. test_args () { - local - user domain first_ask next_ask + local - user domain if [ \( $# -ge 1 -a "$1" = "-h" -a $# -gt 1 \) -o $# -gt 2 ] then echo "Error! Too many arguments." >&2 @@ -89,14 +89,6 @@ test_args () fi fi fi - first_ask="Be aware that you'll need to restart cyrus twice and postfix once. Are you ready?" - next_ask="Incorrect answer. Are you ready to restart cyrus and postfix?" - ask_user_default_no "$first_ask" "$next_ask" - if [ $? -eq 1 ] - then - echo "Ok, exiting…" - exit 1 - fi } # Are we root? @@ -122,6 +114,21 @@ try_sudo () exit $ret } +# Warn user that cyrus will need to restart twice and postfix will have +# to reload its configuration once and ask him if he is ok for that +test_ready_for_restarts () +{ + local - first_ask next_ask + first_ask="Be aware that you'll need to restart cyrus twice and to make postfix reload its configuration once. Are you ready?" + next_ask="Incorrect answer. Are you ready to restart cyrus and make postfix reload its configuration?" + ask_user_default_no "$first_ask" "$next_ask" + if [ $? -eq 1 ] + then + echo "Ok, exiting…" + exit 1 + fi +} + # Test cyrus password is OK. test_cyrus_admin () { @@ -377,6 +384,7 @@ main () then try_sudo "$@" fi + test_ready_for_restarts test_cyrus_admin save_cyrus_state_and_become_cyradm_ready if [ $? -eq 0 ]