Skip to content

Commit

Permalink
nc-update-nc-apps-auto: notify user
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Mar 14, 2019
1 parent b969bc7 commit 311ccc7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bin/ncp/CONFIG/nc-notify-updates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ 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 )
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
ncc notification:generate \
$USER "NextCloudPi update" \
-l "Update from \$( cat \$VERFILE ) to \$( cat \$LATEST ) is available. Update from https://\$IP:4443"
Expand Down Expand Up @@ -74,7 +74,7 @@ sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgrad
echo -e "Packages automatically upgraded: \$PKGS\\n"
# notify
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
ncc notification:generate \
$USER "NextCloudPi Unattended Upgrades" \
-l "Packages automatically upgraded \$PKGS"
EOF
Expand Down
18 changes: 12 additions & 6 deletions bin/ncp/CONFIG/nc-update-nc-apps-auto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,27 @@
# More at: https://ownyourbits.com
#

cronfile=/etc/cron.daily/ncp-autoupdate-apps

configure()
{
local cronfile=/etc/cron.daily/ncp-autoupdate-apps

[[ "$ACTIVE" != "yes" ]] && {
rm -f "$cronfile"
echo "automatic app updates disabled"
return 0
}

cat > "$cronfile" <<'EOF'
cat > "$cronfile" <<EOF
#!/bin/bash
echo "[ nc-update-nc-apps-auto ]" >> /var/log/ncp.log
echo "checking for updates..." >> /var/log/ncp.log
ncc app:update --all -n >> /var/log/ncp.log
OUT="\$(
echo "[ nc-update-nc-apps-auto ]"
echo "checking for updates..."
ncc app:update --all -n
)"
echo "\$OUT" >> /var/log/ncp.log
APPS=\$( echo "\$OUT" | grep 'updated\$' | awk '{ print \$1 }')
ncc notification:generate "$USER" "Apps updated" -l "\$APPS"
EOF
chmod 755 "$cronfile"
echo "automatic app updates enabled"
Expand Down
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

[v1.10.0](https://github.com/nextcloud/nextcloudpi/commit/b00c5f1) (2019-03-13) add nc-previews-auto
[v1.10.1](https://github.com/nextcloud/nextcloudpi/commit/9003eb0) (2019-03-13) nc-update-nc-apps-auto: notify user

[v1.10.0 ](https://github.com/nextcloud/nextcloudpi/commit/06073ed) (2019-03-13) add nc-previews-auto

[v1.9.8 ](https://github.com/nextcloud/nextcloudpi/commit/d7bbe25) (2019-03-13) nc-scan: improvements

Expand Down
6 changes: 6 additions & 0 deletions etc/ncp-config.d/nc-update-nc-apps-auto.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"name": "Active",
"value": "no",
"type": "bool"
},
{
"id": "USER",
"name": "Notify user",
"value": "ncp",
"suggest": "ncp"
}
]
}

0 comments on commit 311ccc7

Please sign in to comment.