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
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
parent986046f51f1a25e4591ac902e70e34383790b25e (diff)
add notify_admin functionalityv1.20.9
Signed-off-by: nachoparker <nacho@ownyourbits.com>
-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
-rw-r--r--changelog.md8
-rw-r--r--etc/library.sh9
-rw-r--r--etc/ncp-config.d/l10n/letsencrypt/zh.json3
-rw-r--r--etc/ncp-config.d/l10n/nc-autoupdate-nc/pt.json1
-rw-r--r--etc/ncp-config.d/l10n/nc-autoupdate-nc/zh.json1
-rw-r--r--etc/ncp-config.d/l10n/nc-autoupdate-ncp/es.json2
-rw-r--r--etc/ncp-config.d/l10n/nc-autoupdate-ncp/pt.json2
-rw-r--r--etc/ncp-config.d/l10n/nc-autoupdate-ncp/zh.json1
-rw-r--r--etc/ncp-config.d/l10n/nc-hdd-monitor/pt.json1
-rw-r--r--etc/ncp-config.d/l10n/nc-hdd-monitor/zh.json1
-rw-r--r--etc/ncp-config.d/letsencrypt.cfg6
-rw-r--r--etc/ncp-config.d/nc-autoupdate-nc.cfg6
-rw-r--r--etc/ncp-config.d/nc-autoupdate-ncp.cfg6
-rw-r--r--etc/ncp-config.d/nc-backup-auto.cfg6
-rw-r--r--etc/ncp-config.d/nc-hdd-monitor.cfg6
-rwxr-xr-xupdate.sh2
22 files changed, 45 insertions, 63 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"
diff --git a/changelog.md b/changelog.md
index ff937bd1..32e12fb6 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,9 @@
-[v1.20.7](https://github.com/nextcloud/nextcloudpi/commit/8ce053f) (2020-01-26) fail2ban: update regex for NC17
+[v1.20.9](https://github.com/nextcloud/nextcloudpi/commit/135f4d4) (2020-02-04) add notify_admin functionality
+
+[v1.20.8](https://github.com/nextcloud/nextcloudpi/commit/986046f) (2020-02-05) nc-backup: add more info to description (#1073)
+
+[v1.20.7](https://github.com/nextcloud/nextcloudpi/commit/b404765) (2020-01-26) fail2ban: update regex for NC17
[v1.20.6 ](https://github.com/nextcloud/nextcloudpi/commit/4a99207) (2020-01-21) ncp-config: dont save passwords
@@ -11,7 +15,7 @@
[v1.20.2 ](https://github.com/nextcloud/nextcloudpi/commit/953c47a) (2019-11-13) Extend the ssh configuration check by calling the echo command if the first check fails.
-[v1.20.1](https://github.com/nextcloud/nextcloudpi/commit/6d0bc6b) (2019-12-19) Revert "build: dont use empty values by default"
+[v1.20.1 ](https://github.com/nextcloud/nextcloudpi/commit/6d0bc6b) (2019-12-19) Revert "build: dont use empty values by default"
[v1.20.0 ](https://github.com/nextcloud/nextcloudpi/commit/f75c415) (2019-12-19) upgrade to NC17.0.2
diff --git a/etc/library.sh b/etc/library.sh
index 461b2e5b..d61b50fa 100644
--- a/etc/library.sh
+++ b/etc/library.sh
@@ -299,6 +299,15 @@ function apt_install()
apt-get install -y --no-install-recommends -o Dpkg::Options::=--force-confdef
}
+function notify_admin()
+{
+ local header="$1"
+ local msg="$2"
+ local admin=$(mysql -u root nextcloud -Nse "select uid from oc_group_user where gid='admin' limit 1;")
+ [[ "${admin}" == "" ]] && { echo "admin user not found" >&2; return 0; }
+ ncc notification:generate "${admin}" "${header}" -l "${msg}" || true
+}
+
# License
#
# This script is free software; you can redistribute it and/or modify it
diff --git a/etc/ncp-config.d/l10n/letsencrypt/zh.json b/etc/ncp-config.d/l10n/letsencrypt/zh.json
index 9cf51d01..36eaeeb7 100644
--- a/etc/ncp-config.d/l10n/letsencrypt/zh.json
+++ b/etc/ncp-config.d/l10n/letsencrypt/zh.json
@@ -5,7 +5,6 @@
"EMAIL": "電子郵件",
"Internet access is required for this configuration to complete\nBoth ports 80 and 443 need to be accessible from the internet\n \nYour certificate will be automatically renewed every month": "使用letsencrypt提供的SSL證書\n在執行這個動作之前,請開啟網路且開啟Port 80和443\n完成此動作之後,SSL證書將每個月自動更新續期。",
"Warning": "警告",
- "letsencrypt": "SSL證書",
- "NOTIFYUSER":"提醒用戶"
+ "letsencrypt": "SSL證書"
}
}
diff --git a/etc/ncp-config.d/l10n/nc-autoupdate-nc/pt.json b/etc/ncp-config.d/l10n/nc-autoupdate-nc/pt.json
index f257436c..5fa44890 100644
--- a/etc/ncp-config.d/l10n/nc-autoupdate-nc/pt.json
+++ b/etc/ncp-config.d/l10n/nc-autoupdate-nc/pt.json
@@ -1,7 +1,6 @@
{
"translations":{
"ACTIVE":"Ativo",
- "NOTIFYUSER":"Noticar Usuario",
"Automatically apply Nextcloud updates":"Aplicar atualizações automaticas ao Nextcloud",
"nc-autoupdate-nc":"nc-autoupdate-nc"
}
diff --git a/etc/ncp-config.d/l10n/nc-autoupdate-nc/zh.json b/etc/ncp-config.d/l10n/nc-autoupdate-nc/zh.json
index 059967e0..dd73090c 100644
--- a/etc/ncp-config.d/l10n/nc-autoupdate-nc/zh.json
+++ b/etc/ncp-config.d/l10n/nc-autoupdate-nc/zh.json
@@ -1,7 +1,6 @@
{
"translations":{
"ACTIVE":"開啟",
- "NOTIFYUSER":"提醒用戶",
"Automatically apply Nextcloud updates":"自動更新Nextcloud",
"nc-autoupdate-nc":"自動更新NC"
}
diff --git a/etc/ncp-config.d/l10n/nc-autoupdate-ncp/es.json b/etc/ncp-config.d/l10n/nc-autoupdate-ncp/es.json
index f59311aa..31b15e13 100644
--- a/etc/ncp-config.d/l10n/nc-autoupdate-ncp/es.json
+++ b/etc/ncp-config.d/l10n/nc-autoupdate-ncp/es.json
@@ -1 +1 @@
-{"translations":{"ACTIVE":"Activado","NOTIFYUSER":"Notificar usuario"}}
+{"translations":{"ACTIVE":"Activado"}}
diff --git a/etc/ncp-config.d/l10n/nc-autoupdate-ncp/pt.json b/etc/ncp-config.d/l10n/nc-autoupdate-ncp/pt.json
index 51a9d8ff..c3e70656 100644
--- a/etc/ncp-config.d/l10n/nc-autoupdate-ncp/pt.json
+++ b/etc/ncp-config.d/l10n/nc-autoupdate-ncp/pt.json
@@ -1 +1 @@
-{"translations":{"ACTIVE":"Ativo","NOTIFYUSER":"Notificar usuário"}}
+{"translations":{"ACTIVE":"Ativo"}}
diff --git a/etc/ncp-config.d/l10n/nc-autoupdate-ncp/zh.json b/etc/ncp-config.d/l10n/nc-autoupdate-ncp/zh.json
index 8976ec23..0a47c89a 100644
--- a/etc/ncp-config.d/l10n/nc-autoupdate-ncp/zh.json
+++ b/etc/ncp-config.d/l10n/nc-autoupdate-ncp/zh.json
@@ -1,7 +1,6 @@
{
"translations":{
"ACTIVE":"開啟",
- "NOTIFYUSER":"提示使用者",
"Automatically apply NextCloudPi updates":"自動更新NextcloudPi",
"nc-autoupdate-ncp":"自動更新NCP"
}
diff --git a/etc/ncp-config.d/l10n/nc-hdd-monitor/pt.json b/etc/ncp-config.d/l10n/nc-hdd-monitor/pt.json
index 912f420d..903f419c 100644
--- a/etc/ncp-config.d/l10n/nc-hdd-monitor/pt.json
+++ b/etc/ncp-config.d/l10n/nc-hdd-monitor/pt.json
@@ -2,7 +2,6 @@
"translations": {
"ACTIVE": "Ativo",
"Monitor HDD health automatically":"Monitorar saúde do HDD automaticamente",
- "NOTIFYUSER":"Notificar usuário",
"EMAIL":"E-mail"
}
}
diff --git a/etc/ncp-config.d/l10n/nc-hdd-monitor/zh.json b/etc/ncp-config.d/l10n/nc-hdd-monitor/zh.json
index bd947b37..a82cf22d 100644
--- a/etc/ncp-config.d/l10n/nc-hdd-monitor/zh.json
+++ b/etc/ncp-config.d/l10n/nc-hdd-monitor/zh.json
@@ -2,7 +2,6 @@
"translations": {
"ACTIVE": "開啟",
"Monitor HDD health automatically":"定期檢查HDD硬碟狀態",
- "NOTIFYUSER":"提示使用者",
"EMAIL":"電子郵件"
}
}
diff --git a/etc/ncp-config.d/letsencrypt.cfg b/etc/ncp-config.d/letsencrypt.cfg
index b1097b4b..1ee41702 100644
--- a/etc/ncp-config.d/letsencrypt.cfg
+++ b/etc/ncp-config.d/letsencrypt.cfg
@@ -23,12 +23,6 @@
"name": "Email",
"value": "",
"suggest": "mycloud@ownyourbits.com"
- },
- {
- "id": "NOTIFYUSER",
- "name": "Notify user",
- "value": "ncp",
- "suggest": "ncp"
}
]
}
diff --git a/etc/ncp-config.d/nc-autoupdate-nc.cfg b/etc/ncp-config.d/nc-autoupdate-nc.cfg
index 8c85cd76..617e71b0 100644
--- a/etc/ncp-config.d/nc-autoupdate-nc.cfg
+++ b/etc/ncp-config.d/nc-autoupdate-nc.cfg
@@ -11,12 +11,6 @@
"name": "Active",
"value": "no",
"type": "bool"
- },
- {
- "id": "NOTIFYUSER",
- "name": "Notify user",
- "value": "ncp",
- "suggest": "ncp"
}
]
}
diff --git a/etc/ncp-config.d/nc-autoupdate-ncp.cfg b/etc/ncp-config.d/nc-autoupdate-ncp.cfg
index dabb5f8b..80d2e77e 100644
--- a/etc/ncp-config.d/nc-autoupdate-ncp.cfg
+++ b/etc/ncp-config.d/nc-autoupdate-ncp.cfg
@@ -11,12 +11,6 @@
"name": "Active",
"value": "no",
"type": "bool"
- },
- {
- "id": "NOTIFYUSER",
- "name": "Notify user",
- "value": "ncp",
- "suggest": "ncp"
}
]
}
diff --git a/etc/ncp-config.d/nc-backup-auto.cfg b/etc/ncp-config.d/nc-backup-auto.cfg
index 32a4c09a..42d0ce26 100644
--- a/etc/ncp-config.d/nc-backup-auto.cfg
+++ b/etc/ncp-config.d/nc-backup-auto.cfg
@@ -42,12 +42,6 @@
"name": "Number of backups to keep",
"suggest": "4",
"value": "4"
- },
- {
- "id": "NOTIFYUSER",
- "name": "Notify user",
- "suggest": "ncp",
- "value": "ncp"
}
]
}
diff --git a/etc/ncp-config.d/nc-hdd-monitor.cfg b/etc/ncp-config.d/nc-hdd-monitor.cfg
index d19c340e..70bfe994 100644
--- a/etc/ncp-config.d/nc-hdd-monitor.cfg
+++ b/etc/ncp-config.d/nc-hdd-monitor.cfg
@@ -13,12 +13,6 @@
"type": "bool"
},
{
- "id": "NOTIFYUSER",
- "name": "Notify user",
- "value": "ncp",
- "suggest": "ncp"
- },
- {
"id": "EMAIL",
"name": "Email",
"value": "",
diff --git a/update.sh b/update.sh
index 3dd10c94..53d33298 100755
--- a/update.sh
+++ b/update.sh
@@ -189,7 +189,7 @@ check_distro "$NCPCFG" && check_distro etc/ncp.cfg || {
msg="Update to $release_new available. Get the latest container to upgrade" || \
msg="Update to $release_new available. Type 'sudo ncp-dist-upgrade' to upgrade"
echo "${msg}"
- ncc notification:generate "ncp" "New distribution available" -l "${msg}"
+ notify_admin "New distribution available" "${msg}"
wall "${msg}"
cat > /etc/update-motd.d/30ncp-dist-upgrade <<EOF
#!/bin/bash