diff options
author | atomlong | 2021-09-14 16:28:06 +0800 |
---|---|---|
committer | atomlong | 2021-09-14 16:33:35 +0800 |
commit | dfee961b787de9a13afbfccd0a5a0c3945a40423 (patch) | |
tree | 160fa67a2a17c5354e1a87cd51fcddf98b879ad3 | |
parent | 02b10f2ad20f3fa538750f237af4f37c4cbe8f8d (diff) | |
download | aur-dfee961b787de9a13afbfccd0a5a0c3945a40423.tar.gz |
send mail via curl.
-rw-r--r-- | .SRCINFO | 9 | ||||
-rw-r--r-- | 0001-Makefile-Support-staged-installs-with-DESTDIR.patch (renamed from destdir.patch) | 13 | ||||
-rw-r--r-- | 0002-send-mail-via-curl-command.patch | 126 | ||||
-rw-r--r-- | PKGBUILD | 12 |
4 files changed, 151 insertions, 9 deletions
@@ -1,16 +1,17 @@ pkgbase = freenom-script pkgdesc = Freenom.com Domain Renewal and Dynamic DNS script. pkgver = 20210824 - pkgrel = 2 + pkgrel = 3 url = https://github.com/mkorthof/freenom-script install = freenom-script.install arch = any license = GPL3 depends = curl - optdepends = postfix: Mail Transfer Agent source = freenom-script::git+https://github.com/mkorthof/freenom-script.git - source = destdir.patch + source = 0001-Makefile-Support-staged-installs-with-DESTDIR.patch + source = 0002-send-mail-via-curl-command.patch md5sums = SKIP - md5sums = 4c4c7f8ee434fe6aad153c6eba8f391a + md5sums = 1747aec87824ab195db8a39803fc8d49 + md5sums = dcd0bb7ae443e9f500744ac9f6c725c0 pkgname = freenom-script diff --git a/destdir.patch b/0001-Makefile-Support-staged-installs-with-DESTDIR.patch index e0dc353aaf3d..4c54579be05c 100644 --- a/destdir.patch +++ b/0001-Makefile-Support-staged-installs-with-DESTDIR.patch @@ -1,3 +1,13 @@ +From e6360fe304fb49dcca4f09028a033eb14d65e887 Mon Sep 17 00:00:00 2001 +From: atomlong <atom.long@hotmail.com> +Date: Tue, 14 Sep 2021 15:07:39 +0800 +Subject: [PATCH 1/2] Makefile: Support staged installs with DESTDIR Use + `DESTDIR` in install related targets to support [*staged installs*][1]. + + make DESTDIR=/tmp/stage install + +[1]: https://www.gnu.org/software/make/manual/html_node/DESTDIR.html +--- Makefile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) @@ -70,3 +80,6 @@ index 6c1dafc..79b19ed 100644 $(info Edit "$(CRONDIR)/freenom" to schedule domain renewals and updates) $(info $() $() * replace example.tk with your domain and uncomment line(s)) $(info See README.md for details) +-- +2.33.0.windows.2 + diff --git a/0002-send-mail-via-curl-command.patch b/0002-send-mail-via-curl-command.patch new file mode 100644 index 000000000000..55688f753ceb --- /dev/null +++ b/0002-send-mail-via-curl-command.patch @@ -0,0 +1,126 @@ +From 510b332dfb96b84f4d4ca24f8d31476527112396 Mon Sep 17 00:00:00 2001 +From: atomlong <atom.long@hotmail.com> +Date: Tue, 14 Sep 2021 16:04:31 +0800 +Subject: [PATCH 2/2] send mail via curl command. MTA is not needed anymore. + +--- + CHANGES.md | 1 + + freenom.conf | 20 +++++++++++++++----- + freenom.sh | 35 ++++++++++++++++++++++------------- + 3 files changed, 38 insertions(+), 18 deletions(-) + +diff --git a/CHANGES.md b/CHANGES.md +index a7667bd..f3c39cf 100644 +--- a/CHANGES.md ++++ b/CHANGES.md +@@ -2,6 +2,7 @@ + + _order: latest/newest on top_ + ++- [**20210914**] send mail via curl command. + - [**20210821**] fix issue [#50](https://github.com/mkorthof/freenom-script/issues/50) + - [**20210618**] added more config checks (PR [#43](https://github.com/mkorthof/freenom-script/issues/43) from nathanfranke) + - [**20210612**] check for uaString and ipCmd settings ([#42](https://github.com/mkorthof/freenom-script/issues/42)) +diff --git a/freenom.conf b/freenom.conf +index 2dea46d..bc47560 100644 +--- a/freenom.conf ++++ b/freenom.conf +@@ -101,15 +101,25 @@ ipCmd+=("dig -4 +short whoami.akamai.net @ns1-1.akamaitech.net") + # MAIL # + ######## + +-# Mail Transfer Agent. A lightweight send-only MTA such as SSMTP should work fine. Or leave empty to disable sending mail. +-# If you do not have a MTA installed you can use "bashmail.sh": https://git.io/JJdto. Default is "/usr/sbin/sendmail" +-MTA="/usr/sbin/sendmail" ++# Mail server address to send notifications ++# Note: If gmail is used, check https://myaccount.google.com/u/1/lesssecureapps?pageId=none ++# to see if you allow for less secure email clients ++#MAILHOST="smtp.gmail.com" ++ ++# Mail server port ++#MAILPORT=587 ++ ++# Mail server username to login ++#MAILUSERNAME="youraccount@gmail.com" ++ ++# Mail server password ++#MAILPASSWD="password" + + # E-mail adress to receive notifications e.g. "admin@example.com". Default is "$freenom_email" +-#RCPTTO="admin@example.com" ++#RCPTTO="$freenom_email" + + # Optional e-mail address from which to sent notifications ("From:"). Default is none +-#MAILFROM="Freenom Script <freenom-script@example.com>" ++#MAILFROM="Freenom Script <${MAILUSERNAME}>" + + ###################### + # Domain name and id # +diff --git a/freenom.sh b/freenom.sh +index 01ed3fe..84dd91c 100755 +--- a/freenom.sh ++++ b/freenom.sh +@@ -159,15 +159,6 @@ if [ -z "$RCPTTO" ]; then + RCPTTO="$freenom_email" + fi + +-if [ ! -x "$MTA" ]; then +- if [ -x "/usr/sbin/sendmail" ]; then +- MTA="/usr/sbin/sendmail" +- else +- MTA="" +- echo "Warning: no MTA found, cant send email" +- fi +-fi +- + # set a few general variables + + c_opts="--connect-timeout 30 --compressed -L -s" +@@ -476,22 +467,40 @@ func_sleep () { + fi + } + ++# Function sleep: send mail ++func_mailto() ++{ ++local ssl_opt smtp_proto ++case ${MAILPORT} in ++ 25) ssl_opt=""; smtp_proto="smtp"; ;; ++ 465) ssl_opt="--ssl-reqd"; smtp_proto="smtps"; ;; ++ 587) ssl_opt="--ssl-reqd"; smtp_proto="smtp"; ;; ++ *) echo "Error: Unknown MAILPORT: ${MAILPORT}."; return 1; ++esac ++curl --silent ${ssl_opt} --login-options AUTH=LOGIN \ ++ --url "${smtp_proto}://${MAILHOST}:${MAILPORT}" \ ++ --mail-from "${MAILUSERNAME}" \ ++ --mail-rcpt "${1}" \ ++ --user "${MAILUSERNAME}:${MAILPASSWD}" \ ++ --upload-file - ++} ++ + # Function mailEvent: send mail + # parameters: $1: event 2: $messages + mailEvent() { +- if [ "$MTA" != "" ] && [ "$RCPTTO" != "" ]; then ++ if [ "$MAILHOST" != "" ] && [ "$MAILPORT" != "" ] && [ "$MAILUSERNAME" != "" ] && [ "$MAILPASSWD" != "" ]; then + if [ "$debug" -ge 1 ]; then +- echo "DEBUG: $(date '+%H:%M:%S') email $pad4 HOSTNAME=$HOSTNAME MTA=$MTA RCPTTO=$RCPTTO 1=$1 2=$2" ++ echo "DEBUG: $(date '+%H:%M:%S') email $pad4 HOSTNAME=$HOSTNAME RCPTTO=$RCPTTO 1=$1 2=$2" + fi + [ "$debug" -ge 3 ] && set -x + HEADER="To: <$RCPTTO>\n"; + if [ "$MAILFROM" ]; then + HEADER+="From: $MAILFROM\n" + fi +- echo -e "${HEADER}Subject: freenom.sh: \"$1\" on \"$HOSTNAME\"\n\nDate: $( date +%F\ %T )\n\n$2" | "$MTA" "$RCPTTO" ++ echo -e "${HEADER}Subject: freenom.sh: \"$1\" on \"$HOSTNAME\"\n\nDate: $( date +%F\ %T )\n\n$2" | func_mailto "$RCPTTO" + EXITCODE="$?" + if [ "$EXITCODE" -ne 0 ]; then +- echo "Error: exit code \"$EXITCODE\" while running $MTA" ++ echo "Error: exit code \"$EXITCODE\" while sending mail." + fi + [ "$debug" -ge 3 ] && set +x + fi +-- +2.33.0.windows.2 + @@ -2,17 +2,18 @@ pkgname=freenom-script pkgver=20210824 -pkgrel=2 +pkgrel=3 pkgdesc="Freenom.com Domain Renewal and Dynamic DNS script." arch=('any') url="https://github.com/mkorthof/freenom-script" license=('GPL3') depends=('curl') -optdepends=('postfix: Mail Transfer Agent') source=("${pkgname}::git+${url}.git" - destdir.patch) + 0001-Makefile-Support-staged-installs-with-DESTDIR.patch + 0002-send-mail-via-curl-command.patch) md5sums=('SKIP' - '4c4c7f8ee434fe6aad153c6eba8f391a') + '1747aec87824ab195db8a39803fc8d49' + 'dcd0bb7ae443e9f500744ac9f6c725c0') install=freenom-script.install pkgver() { @@ -22,7 +23,8 @@ pkgver() { prepare() { cd "${srcdir}/${pkgname}" - patch -Np1 -i "${srcdir}/destdir.patch" + git apply ${srcdir}/0001-Makefile-Support-staged-installs-with-DESTDIR.patch + git apply ${srcdir}/0002-send-mail-via-curl-command.patch } package() { |