Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2020-02-05 06:14:47 +0300
committernachoparker <nacho@ownyourbits.com>2020-02-05 06:29:03 +0300
commit0c538aef3c86ba09e2e346e52c78a09d2422c00b (patch)
treefda115f4294ab35ac57b4d0e456f7fa1bce94c9c /bin
parent986046f51f1a25e4591ac902e70e34383790b25e (diff)
add notify_admin functionalityv1.20.9
Signed-off-by: nachoparker <nacho@ownyourbits.com>
Diffstat (limited to 'bin')
-rw-r--r--bin/ncp/NETWORKING/letsencrypt.sh14
-rw-r--r--bin/ncp/SYSTEM/nc-hdd-monitor.sh7
-rw-r--r--bin/ncp/UPDATES/nc-autoupdate-nc.sh4
-rw-r--r--bin/ncp/UPDATES/nc-autoupdate-ncp.sh5
-rw-r--r--bin/ncp/UPDATES/nc-notify-updates.sh14
-rw-r--r--bin/ncp/UPDATES/nc-update-nc-apps-auto.sh3
6 files changed, 26 insertions, 21 deletions
diff --git a/bin/ncp/NETWORKING/letsencrypt.sh b/bin/ncp/NETWORKING/letsencrypt.sh
index 86241e6f..449a5dc2 100644
--- a/bin/ncp/NETWORKING/letsencrypt.sh
+++ b/bin/ncp/NETWORKING/letsencrypt.sh
@@ -67,14 +67,15 @@ configure()
# Set up auto-renewal
cat > /etc/cron.weekly/letsencrypt-ncp <<EOF
#!/bin/bash
+source /usr/local/etc/library.sh
# renew and notify
$letsencrypt renew --quiet
# notify if fails
-[[ \$? -ne 0 ]] && ncc notification:generate \
- $NOTIFYUSER "SSL renewal error" \
- -l "SSL certificate renewal failed. See /var/log/letsencrypt/letsencrypt.log"
+[[ \$? -ne 0 ]] && notify_admin \
+ "SSL renewal error" \
+ "SSL certificate renewal failed. See /var/log/letsencrypt/letsencrypt.log"
# cleanup
rm -rf $ncdir/.well-known
@@ -84,9 +85,10 @@ EOF
mkdir -p /etc/letsencrypt/renewal-hooks/deploy
cat > /etc/letsencrypt/renewal-hooks/deploy/ncp <<EOF
#!/bin/bash
-/usr/local/bin/ncc notification:generate \
- $NOTIFYUSER "SSL renewal" \
- -l "Your SSL certificate(s) \$RENEWED_DOMAINS has been renewed for another 90 days"
+source /usr/local/etc/library.sh
+notify_admin \
+ "SSL renewal" \
+ "Your SSL certificate(s) \$RENEWED_DOMAINS has been renewed for another 90 days"
exit 0
EOF
chmod +x /etc/letsencrypt/renewal-hooks/deploy/ncp
diff --git a/bin/ncp/SYSTEM/nc-hdd-monitor.sh b/bin/ncp/SYSTEM/nc-hdd-monitor.sh
index e4c0976a..8d61de3f 100644
--- a/bin/ncp/SYSTEM/nc-hdd-monitor.sh
+++ b/bin/ncp/SYSTEM/nc-hdd-monitor.sh
@@ -45,10 +45,11 @@ EOF
}
cat >> /usr/local/etc/ncp-hdd-notif.sh <<EOF
+source /usr/local/etc/library.sh
wall "\$SMARTD_MESSAGE"
-sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- $NOTIFYUSER "NextCloudPi HDD health \$SMARTD_FAILTYPE" \
- -l "\$SMARTD_MESSAGE"
+notify_admin \
+ "NextCloudPi HDD health \$SMARTD_FAILTYPE" \
+ "\$SMARTD_MESSAGE"
EOF
chmod +x /usr/local/etc/ncp-hdd-notif.sh
diff --git a/bin/ncp/UPDATES/nc-autoupdate-nc.sh b/bin/ncp/UPDATES/nc-autoupdate-nc.sh
index ee2a5669..10593c0f 100644
--- a/bin/ncp/UPDATES/nc-autoupdate-nc.sh
+++ b/bin/ncp/UPDATES/nc-autoupdate-nc.sh
@@ -21,6 +21,7 @@ configure()
cat > /etc/cron.daily/ncp-autoupdate-nc <<EOF
#!/bin/bash
+source /usr/local/etc/library.sh
echo -e "[ncp-update-nc]" >> /var/log/ncp.log
/usr/local/bin/ncp-update-nc "$NCVER" 2>&1 | tee -a /var/log/ncp.log
@@ -29,8 +30,7 @@ if [[ \${PIPESTATUS[0]} -eq 0 ]]; then
VER="\$( /usr/local/bin/ncc status | grep "version:" | awk '{ print \$3 }' )"
- sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- "$NOTIFYUSER" "NextCloudPi" -l "Nextcloud was updated to \$VER"
+ notify_admin "NextCloudPi" "Nextcloud was updated to \$VER"
fi
echo "" >> /var/log/ncp.log
EOF
diff --git a/bin/ncp/UPDATES/nc-autoupdate-ncp.sh b/bin/ncp/UPDATES/nc-autoupdate-ncp.sh
index 2a662ac6..6aa00f68 100644
--- a/bin/ncp/UPDATES/nc-autoupdate-ncp.sh
+++ b/bin/ncp/UPDATES/nc-autoupdate-ncp.sh
@@ -19,11 +19,10 @@ configure()
cat > /etc/cron.daily/ncp-autoupdate <<EOF
#!/bin/bash
+source /usr/local/etc/library.sh
if /usr/local/bin/ncp-test-updates; then
/usr/local/bin/ncp-update || exit 1
- /usr/local/bin/ncc notification:generate \
- "$NOTIFYUSER" "NextCloudPi" \
- -l "NextCloudPi was updated to \$( cat /usr/local/etc/ncp-version )"
+ notify_admin "NextCloudPi" "NextCloudPi was updated to \$(cat /usr/local/etc/ncp-version)"
fi
EOF
chmod 755 /etc/cron.daily/ncp-autoupdate
diff --git a/bin/ncp/UPDATES/nc-notify-updates.sh b/bin/ncp/UPDATES/nc-notify-updates.sh
index 4155ae9f..98e4240f 100644
--- a/bin/ncp/UPDATES/nc-notify-updates.sh
+++ b/bin/ncp/UPDATES/nc-notify-updates.sh
@@ -26,6 +26,7 @@ configure()
# code
cat > /usr/local/bin/ncp-notify-update <<EOF
#!/bin/bash
+source /usr/local/etc/library.sh
VERFILE=/usr/local/etc/ncp-version
LATEST=/var/run/.ncp-latest-version
NOTIFIED=/var/run/.ncp-version-notified
@@ -43,9 +44,9 @@ echo "Found update from \$( cat \$VERFILE ) to \$( cat \$LATEST ). Sending notif
IFACE=\$( ip r | grep "default via" | awk '{ print \$5 }' | head -1 )
IP=\$( ip a show dev "\$IFACE" | grep global | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 )
-/usr/local/bin/ncc notification:generate \
- $USER "NextCloudPi update" \
- -l "Update from \$( cat \$VERFILE ) to \$( cat \$LATEST ) is available. Update from https://\$IP:4443"
+notify_admin \
+ "NextCloudPi update" \
+ "Update from \$( cat \$VERFILE ) to \$( cat \$LATEST ) is available. Update from https://\$IP:4443"
cat \$LATEST > \$NOTIFIED
EOF
@@ -53,6 +54,7 @@ EOF
cat > /usr/local/bin/ncp-notify-unattended-upgrade <<EOF
#!/bin/bash
+source /usr/local/etc/library.sh
LOGFILE=/var/log/unattended-upgrades/unattended-upgrades.log
STAMPFILE=/var/run/.ncp-notify-unattended-upgrades
@@ -74,9 +76,9 @@ sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgrad
echo -e "Packages automatically upgraded: \$PKGS\\n"
# notify
-/usr/local/bin/ncc notification:generate \
- $USER "NextCloudPi Unattended Upgrades" \
- -l "Packages automatically upgraded \$PKGS"
+notify_admin \
+ "NextCloudPi Unattended Upgrades" \
+ "Packages automatically upgraded \$PKGS"
EOF
chmod +x /usr/local/bin/ncp-notify-unattended-upgrade
diff --git a/bin/ncp/UPDATES/nc-update-nc-apps-auto.sh b/bin/ncp/UPDATES/nc-update-nc-apps-auto.sh
index bd50f0ff..5c5d06d4 100644
--- a/bin/ncp/UPDATES/nc-update-nc-apps-auto.sh
+++ b/bin/ncp/UPDATES/nc-update-nc-apps-auto.sh
@@ -20,6 +20,7 @@ configure()
cat > "$cronfile" <<EOF
#!/bin/bash
+source /usr/local/etc/library.sh
OUT="\$(
echo "[ nc-update-nc-apps-auto ]"
echo "checking for updates..."
@@ -28,7 +29,7 @@ echo "checking for updates..."
echo "\$OUT" >> /var/log/ncp.log
APPS=\$( echo "\$OUT" | grep 'updated\$' | awk '{ print \$1 }')
-[[ "\$APPS" != "" ]] && /usr/local/bin/ncc notification:generate "$USER" "Apps updated" -l "\$APPS"
+[[ "\$APPS" != "" ]] && notify_admin "Apps updated" "\$APPS"
EOF
chmod 755 "$cronfile"
echo "automatic app updates enabled"