Skip to content

Commit

Permalink
nc-notify-updates: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Nov 9, 2017
1 parent 4329eea commit 1955ece
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
8 changes: 5 additions & 3 deletions changelog.md
@@ -1,9 +1,11 @@

[v0.32.6](https://github.com/nextcloud/nextcloudpi/commit/83adc32) (2017-11-08) noip: manage many interfaces and fix return value
[v0.32.7](https://github.com/nextcloud/nextcloudpi/commit/ae1c47a) (2017-11-09) nc-notify-updates: fixes

[v0.32.5 ](https://github.com/nextcloud/nextcloudpi/commit/f192b20) (2017-11-08) update: wait running apt processes
[v0.32.6](https://github.com/nextcloud/nextcloudpi/commit/455cb73) (2017-11-08) noip: manage many interfaces and fix return value

[v0.32.4 ](https://github.com/nextcloud/nextcloudpi/commit/63e0f73) (2017-11-08) fail2ban: update logpath on nc-datadir or nc-restore
[v0.32.5 ](https://github.com/nextcloud/nextcloudpi/commit/3147047) (2017-11-08) update: wait running apt processes

[v0.32.4 ](https://github.com/nextcloud/nextcloudpi/commit/42cef25) (2017-11-08) fail2ban: update logpath on nc-datadir or nc-restore

[v0.32.3 ](https://github.com/nextcloud/nextcloudpi/commit/bfe0b61) (2017-11-06) nc-notify-updates: rework for more accuracy

Expand Down
4 changes: 3 additions & 1 deletion etc/nextcloudpi-config.d/nc-notify-updates.sh
Expand Up @@ -107,7 +107,9 @@ 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 "NextCloudPi Unattended Upgrades" -l "Packages automatically upgraded $PKGS"
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
$USER_ "NextCloudPi Unattended Upgrades" \
-l "Packages automatically upgraded \$PKGS"
EOF
chmod +x /usr/local/bin/ncp-notify-unattended-upgrade

Expand Down
31 changes: 31 additions & 0 deletions update.sh
Expand Up @@ -232,6 +232,37 @@ EOF

# relocate noip2 config
mkdir -p /usr/local/etc/noip2

# fix unattended
NUSER=$( grep USER_ /usr/local/etc/nextcloudpi-config.d/nc-notify-updates.sh | head -1 | cut -f2 -d= )
cat > /usr/local/bin/ncp-notify-unattended-upgrade <<EOF
#!/bin/bash
LOGFILE=/var/log/unattended-upgrades/unattended-upgrades.log
STAMPFILE=/var/run/.ncp-notify-unattended-upgrades
VERFILE=/usr/local/etc/ncp-version
test -e "\$LOGFILE" || { echo "\$LOGFILE not found"; exit 1; }
# find lines with package updates
LINE=\$( grep "INFO Packages that will be upgraded:" "\$LOGFILE" )
[[ "\$LINE" == "" ]] && { echo "no new upgrades"; exit 0; }
# extract package names
PKGS=\$( sed 's|^.*Packages that will be upgraded: ||' <<< "\$LINE" | tr '\\n' ' ' )
# mark lines as read
sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgraded :|' \$LOGFILE
echo -e "Packages automatically upgraded: \$PKGS\\n"
# notify
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
$NUSER "NextCloudPi Unattended Upgrades" \
-l "Packages automatically upgraded \$PKGS"
EOF
chmod +x /usr/local/bin/ncp-notify-unattended-upgrade
}

# License
Expand Down

0 comments on commit 1955ece

Please sign in to comment.