diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-09-01 11:16:27 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-09-02 00:32:22 +0300 |
commit | a695c1669383d9ab8d02488177c1a6739c8a889c (patch) | |
tree | 26a7aee2bf4a59c6cb20a3fc641026a9f0f650ab /etc/nextcloudpi-config.d/nc-notify-updates.sh | |
parent | c4d2e41c1c5c0c887724a0c33e5b682bb12e47a3 (diff) |
nc-notify-updates: allow specifying userv0.24.17
Diffstat (limited to 'etc/nextcloudpi-config.d/nc-notify-updates.sh')
-rw-r--r-- | etc/nextcloudpi-config.d/nc-notify-updates.sh | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/etc/nextcloudpi-config.d/nc-notify-updates.sh b/etc/nextcloudpi-config.d/nc-notify-updates.sh index 4c9b73b5..147f346e 100644 --- a/etc/nextcloudpi-config.d/nc-notify-updates.sh +++ b/etc/nextcloudpi-config.d/nc-notify-updates.sh @@ -14,6 +14,7 @@ # ACTIVE_=yes +USER_=admin CHECKINTERVAL=60 DESCRIPTION="Notify in NC when a NextCloudPi update is available" @@ -31,34 +32,6 @@ install() chown -R www-data:www-data * sudo -u www-data php /var/www/nextcloud/occ app:enable admin_notifications - # code - cat > /usr/local/bin/ncp-notify-update <<'EOF' -#!/bin/bash -VERFILE=/usr/local/etc/ncp-version -LATEST=/var/run/.ncp-latest-version -NOTIFIED=/var/run/.ncp-version-notified - -test -e $LATEST || exit 0; -ncp-test-updates || { echo "NextCloudPi up to date"; exit 0; } - -test -e $NOTIFIED && [[ "$( cat $LATEST )" == "$( cat $NOTIFIED )" ]] && { - echo "Found update from $( cat $VERFILE ) to $( cat $LATEST ). Already notified" - exit 0 -} - -echo "Found update from $( cat $VERFILE ) to $( cat $LATEST ). Sending notification..." - -IFACE=$( ip r | grep "default via" | awk '{ print $5 }' ) -IP=$( ip a | grep "global $IFACE" | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) - -sudo -u www-data php /var/www/nextcloud/occ notification:generate \ - admin "NextCloudPi $( cat $VERFILE )" \ - -l "NextCloudPi $( cat $LATEST ) is available. Update from https://$IP:4443" - -cat $LATEST > $NOTIFIED -EOF - chmod +x /usr/local/bin/ncp-notify-update - # timers cat > /etc/systemd/system/nc-notify-updates.service <<EOF [Unit] @@ -82,6 +55,35 @@ configure() return 0 } + # code + cat > /usr/local/bin/ncp-notify-update <<EOF +#!/bin/bash +VERFILE=/usr/local/etc/ncp-version +LATEST=/var/run/.ncp-latest-version +NOTIFIED=/var/run/.ncp-version-notified + +test -e \$LATEST || exit 0; +ncp-test-updates || { echo "NextCloudPi up to date"; exit 0; } + +test -e \$NOTIFIED && [[ "\$( cat \$LATEST )" == "\$( cat \$NOTIFIED )" ]] && { + echo "Found update from \$( cat \$VERFILE ) to \$( cat \$LATEST ). Already notified" + exit 0 +} + +echo "Found update from \$( cat \$VERFILE ) to \$( cat \$LATEST ). Sending notification..." + +IFACE=\$( ip r | grep "default via" | awk '{ print \$5 }' ) +IP=\$( ip a | grep "global \$IFACE" | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 ) + +sudo -u www-data php /var/www/nextcloud/occ notification:generate \ + $USER_ "NextCloudPi \$( cat \$VERFILE )" \ + -l "NextCloudPi \$( cat \$LATEST ) is available. Update from https://\$IP:4443" + +cat \$LATEST > \$NOTIFIED +EOF + chmod +x /usr/local/bin/ncp-notify-update + + # timer cat > /etc/systemd/system/nc-notify-updates.timer <<EOF [Unit] Description=Timer notify NCP updates in browser |