mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-10 15:12:01 -03:30
add notify_admin functionality
Signed-off-by: nachoparker <nacho@ownyourbits.com>
This commit is contained in:
parent
986046f51f
commit
0c538aef3c
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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證書"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"translations":{
|
||||
"ACTIVE":"開啟",
|
||||
"NOTIFYUSER":"提醒用戶",
|
||||
"Automatically apply Nextcloud updates":"自動更新Nextcloud",
|
||||
"nc-autoupdate-nc":"自動更新NC"
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
{"translations":{"ACTIVE":"Activado","NOTIFYUSER":"Notificar usuario"}}
|
||||
{"translations":{"ACTIVE":"Activado"}}
|
||||
|
||||
@ -1 +1 @@
|
||||
{"translations":{"ACTIVE":"Ativo","NOTIFYUSER":"Notificar usuário"}}
|
||||
{"translations":{"ACTIVE":"Ativo"}}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"translations":{
|
||||
"ACTIVE":"開啟",
|
||||
"NOTIFYUSER":"提示使用者",
|
||||
"Automatically apply NextCloudPi updates":"自動更新NextcloudPi",
|
||||
"nc-autoupdate-ncp":"自動更新NCP"
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
"translations": {
|
||||
"ACTIVE": "Ativo",
|
||||
"Monitor HDD health automatically":"Monitorar saúde do HDD automaticamente",
|
||||
"NOTIFYUSER":"Notificar usuário",
|
||||
"EMAIL":"E-mail"
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
"translations": {
|
||||
"ACTIVE": "開啟",
|
||||
"Monitor HDD health automatically":"定期檢查HDD硬碟狀態",
|
||||
"NOTIFYUSER":"提示使用者",
|
||||
"EMAIL":"電子郵件"
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,12 +23,6 @@
|
||||
"name": "Email",
|
||||
"value": "",
|
||||
"suggest": "mycloud@ownyourbits.com"
|
||||
},
|
||||
{
|
||||
"id": "NOTIFYUSER",
|
||||
"name": "Notify user",
|
||||
"value": "ncp",
|
||||
"suggest": "ncp"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -11,12 +11,6 @@
|
||||
"name": "Active",
|
||||
"value": "no",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": "NOTIFYUSER",
|
||||
"name": "Notify user",
|
||||
"value": "ncp",
|
||||
"suggest": "ncp"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -11,12 +11,6 @@
|
||||
"name": "Active",
|
||||
"value": "no",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": "NOTIFYUSER",
|
||||
"name": "Notify user",
|
||||
"value": "ncp",
|
||||
"suggest": "ncp"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -42,12 +42,6 @@
|
||||
"name": "Number of backups to keep",
|
||||
"suggest": "4",
|
||||
"value": "4"
|
||||
},
|
||||
{
|
||||
"id": "NOTIFYUSER",
|
||||
"name": "Notify user",
|
||||
"suggest": "ncp",
|
||||
"value": "ncp"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -12,12 +12,6 @@
|
||||
"value": "no",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": "NOTIFYUSER",
|
||||
"name": "Notify user",
|
||||
"value": "ncp",
|
||||
"suggest": "ncp"
|
||||
},
|
||||
{
|
||||
"id": "EMAIL",
|
||||
"name": "Email",
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user