From 96ebf2756611aeb7428bc48a07cc4ccd3383bc13 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 10 Aug 2022 11:05:15 -0500 Subject: [PATCH] Include all required scripts for notifying the admin of Gitea new users --- checkregistration.sh | 10 ++++++++++ notifyregistration.sh | 14 ++++++++++++++ registeredusers.data | 1 + 3 files changed, 25 insertions(+) create mode 100755 checkregistration.sh create mode 100755 notifyregistration.sh create mode 100644 registeredusers.data diff --git a/checkregistration.sh b/checkregistration.sh new file mode 100755 index 0000000..13e4030 --- /dev/null +++ b/checkregistration.sh @@ -0,0 +1,10 @@ +cd /home/sigonasr2/GiteaMailNotifications +CURRENT=$(curl -s -D - -o /dev/null 'http://sig.projectdivar.com/api/v1/admin/users' -H 'accept: application/json' -H 'authorization: Basic $(cat .APIKEY)' | grep "X-Total-Count:") +PREVIOUS=$(cat registeredusers.data) +if [ "$CURRENT" != "$PREVIOUS" ]; then + ./notifyregistration.sh + echo $CURRENT > registeredusers.data + echo "New registration detected. Email sent" +else + echo "No new users detected." +fi diff --git a/notifyregistration.sh b/notifyregistration.sh new file mode 100755 index 0000000..a5ce832 --- /dev/null +++ b/notifyregistration.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# sendmail command line optons: +# -i - do not treat lines starting with dot specially +# -t - read recipients lists from message headers: TO,CC,BCC +# -v - use verbose mode (describe what is happening) + +/usr/sbin/sendmail -i -t << MESSAGE_END +From: Sig +To: sigonasr2@yahoo.com +Date: Fri, 5 Aug 2022 10:44:00 -0700 +Subject: Gitea - New User Registration! + +A new user has registered on your site. You can go approve them now. diff --git a/registeredusers.data b/registeredusers.data new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/registeredusers.data @@ -0,0 +1 @@ +