Skip to content

Commit e4b5593

Browse files
committed
ncp-check-nc-version: dont notify the same version more than once
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent 9e27660 commit e4b5593

3 files changed

Lines changed: 56 additions & 9 deletions

File tree

bin/ncp-check-nc-version

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ source /usr/local/etc/library.sh # sets NCLATESTVER
88

99
CURRENT="$(ncc status | grep "version:" | awk '{ print $3 }')"
1010
LATEST="$(wget -qO- https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/etc/ncp.cfg | jq -r .nextcloud_version)"
11+
NOTIFIED=/var/run/.nc-version-notified
12+
13+
test -e "${NOTIFIED}" && [[ "$( cat "${LATEST}" )" == "$( cat "${NOTIFIED}" )" ]] && {
14+
echo "Found update from ${CURRENT} to ${LATEST}. Already notified"
15+
exit 0
16+
}
1117

1218
if is_more_recent_than "${LATEST}" "${CURRENT}"; then
1319
notify_admin \
1420
"Nextcloud update" \
15-
"Update from ${CURRENT} to "${LATEST}" is available. Update from https://$(get_ip):4443"
21+
"Update from ${CURRENT} to ${LATEST} is available. Update from https://$(get_ip):4443"
22+
cat "${LATEST}" > "${NOTIFIED}"
1623
fi

bin/ncp/UPDATES/nc-notify-updates.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,33 @@ cat $LATEST > $NOTIFIED
5050
EOF
5151
chmod +x /usr/local/bin/ncp-notify-update
5252

53-
cat > /usr/local/bin/ncp-notify-unattended-upgrade <<EOF
53+
cat > /usr/local/bin/ncp-notify-unattended-upgrade <<'EOF'
5454
#!/bin/bash
5555
source /usr/local/etc/library.sh
5656
5757
LOGFILE=/var/log/unattended-upgrades/unattended-upgrades.log
5858
STAMPFILE=/var/run/.ncp-notify-unattended-upgrades
5959
VERFILE=/usr/local/etc/ncp-version
6060
61-
test -e "\$LOGFILE" || { echo "\$LOGFILE not found"; exit 1; }
61+
test -e "$LOGFILE" || { echo "$LOGFILE not found"; exit 1; }
6262
6363
# find lines with package updates
64-
LINE=\$( grep "INFO Packages that will be upgraded:" "\$LOGFILE" )
64+
LINE=$( grep "INFO Packages that will be upgraded:" "$LOGFILE" )
6565
66-
[[ "\$LINE" == "" ]] && { echo "no new upgrades"; exit 0; }
66+
[[ "$LINE" == "" ]] && { echo "no new upgrades"; exit 0; }
6767
6868
# extract package names
69-
PKGS=\$( sed 's|^.*Packages that will be upgraded: ||' <<< "\$LINE" | tr '\\n' ' ' )
69+
PKGS=$( sed 's|^.*Packages that will be upgraded: ||' <<< "$LINE" | tr '\n' ' ' )
7070
7171
# mark lines as read
72-
sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgraded :|' \$LOGFILE
72+
sed -i 's|INFO Packages that will be upgraded:|INFO Packages that will be upgraded :|' \LOGFILE
7373
74-
echo -e "Packages automatically upgraded: \$PKGS\\n"
74+
echo -e "Packages automatically upgraded: $PKGS\n"
7575
7676
# notify
7777
notify_admin \
7878
"NextCloudPi Unattended Upgrades" \
79-
"Packages automatically upgraded \$PKGS"
79+
"Packages automatically upgraded $PKGS"
8080
EOF
8181
chmod +x /usr/local/bin/ncp-notify-unattended-upgrade
8282

updates/1.41.0.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
## BACKWARD FIXES ( for older images )
6+
7+
source /usr/local/etc/library.sh # sets NCLATESTVER PHPVER RELEASE
8+
9+
# all images
10+
11+
# we handle this ourselves now
12+
ncc app:disable updatenotification
13+
run_app nc-notify-updates
14+
15+
# docker images only
16+
[[ -f /.docker-image ]] && {
17+
:
18+
}
19+
20+
# for non docker images
21+
[[ ! -f /.docker-image ]] && {
22+
23+
# make sure redis is up before running nextclud-domain
24+
cat > /usr/lib/systemd/system/nextcloud-domain.service <<'EOF'
25+
[Unit]
26+
Description=Register Current IP as Nextcloud trusted domain
27+
Requires=network.target
28+
After=mysql.service redis.service
29+
30+
[Service]
31+
ExecStart=/bin/bash /usr/local/bin/nextcloud-domain.sh
32+
Restart=on-failure
33+
RestartSec=5s
34+
35+
[Install]
36+
WantedBy=multi-user.target
37+
EOF
38+
}
39+
40+
exit 0

0 commit comments

Comments
 (0)