update-ngxblocker: detect /bin/mail in centos / add -m cmd line switch for mail

* also detect /bin/mail in centos

* adds -m command line switch to specify an email address (to avoid confusion with
  -e used in setup-ngxblocker to specify vhost file extensions)

  -e can still be used to specify an email address to avoid breakage with current
  cron jobs
This commit is contained in:
Stuart Cardall 2017-09-20 13:36:15 +00:00
parent 7ae8dbce1c
commit af197cb559
No known key found for this signature in database
GPG key ID: AEB857F1C891D0C6

View file

@ -53,7 +53,7 @@ Usage: $script [OPTIONS]
[ -b ] : NGINX bots directory (default: $BOTS_DIR)
[ -i ] : Change installer path (default: $INSTALLER)
[ -r ] : Change repo url (default: $REPO)
[ -e ] : Change email address (default: $EMAIL)
[ -m ] : Change email address (default: $EMAIL)
[ -n ] : Do not send email report (default: $SEND_EMAIL)
[ -v ] : Print blacklist version
[ -h ] : this help message
@ -194,8 +194,8 @@ check_args() {
}
check_mail_depends() {
if [ ! -f /usr/bin/mail ]; then # mailx + ssmtp are enough to send emails
printf "${BOLDYELLOW}WARN${RESET}: missing /usr/bin/mail => ${BOLDWHITE}disabling emails${RESET}.\n\n"
if [ ! -f /usr/bin/mail ] && [ ! -f /bin/mail ]; then # mailx + ssmtp are enough to send emails
printf "${BOLDYELLOW}WARN${RESET}: missing mail command => ${BOLDWHITE}disabling emails${RESET}.\n\n"
SEND_EMAIL="N"
fi
}
@ -223,7 +223,7 @@ check_depends() {
get_options() {
local arg= opts=
while getopts :c:b:u:r:e:nvh opts "$@"
while getopts :c:b:u:r:e:m:nvh opts "$@"
do
if [ -n "${OPTARG}" ]; then
case "$opts" in
@ -239,6 +239,7 @@ get_options() {
i) INSTALLER=$arg; check_args $opts script $arg ;;
r) REPO=$arg; check_args $opts url $arg ;;
e) EMAIL=$arg; check_args $opts email $arg ;;
m) EMAIL=$arg; check_args $opts email $arg ;;
n) SEND_EMAIL=N ;;
v) check_depends; check_version ;;
h) usage ;;