From a95e3cd8f50a22aeda56c552e1a9b35cd8e8b4cd Mon Sep 17 00:00:00 2001 From: "Chang, Chu-Kuan" Date: Fri, 12 Feb 2021 11:38:24 +0800 Subject: [PATCH] add restart redis, use if properly --- emailwiz | 17 +++++++++++++---- mailrestart | 12 +++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/emailwiz b/emailwiz index c4b84a2..146a686 100755 --- a/emailwiz +++ b/emailwiz @@ -433,10 +433,19 @@ doas -u _dkimsign openssl genrsa -out "${dkimkey}" 2048 # for x in 'smtpd' 'dovecot' 'rspamd' 'redis'; do - printf '%s: Enabling %s...' "${progname}" "${x}" - rcctl enable "${x}" 2>&1 > /dev/null && printf ' Done\n' || printf ' Failed\n' - printf '%s: Restarting %s...' "${progname}" "${x}" - rcctl restart "${x}" 2>&1 > /dev/null && printf ' Done\n' || printf ' Failed\n' + printf '%s: Enabling %s...' "${progname}" "$x" + if rcctl enable "$x" 2>&1 > /dev/null; then + printf ' Done\n' + else + printf ' Failed\n' + fi + + printf '%s: Restarting %s...' "${progname}" "$x" + if rcctl restart "$x" 2>&1 > /dev/null; then + printf ' Done\n' + else + printf ' Failed\n' + fi done # diff --git a/mailrestart b/mailrestart index 9a71413..d643384 100755 --- a/mailrestart +++ b/mailrestart @@ -14,9 +14,11 @@ if test "$(id -u)" != '0'; then exit 1 fi -for x in 'smtpd' 'dovecot' 'rspamd'; do - printf '%s: Restarting %s...' "${progname}" "${x}" - rcctl restart "${x}" 2>&1 > /dev/null \ - && printf ' Done\n' \ - || printf ' Failed\n' +for x in 'smtpd' 'dovecot' 'rspamd' 'redis'; do + printf '%s: Restarting %s...' "${progname}" "$x" + if rcctl restart "$x" 2>&1 > /dev/null; then + printf ' Done\n' + else + printf ' Failed\n' + fi done