Welcome to mirror list, hosted at ThFree Co, Russian Federation.

updatenotification.sh « static - github.com/nextcloud/vm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 912555bd1e5c1ee7fe9d6634ac93ef099bc2faa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash

# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/

true
SCRIPT_NAME="Update Notification"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh

# Get all needed variables from the library
nc_update

print_text_in_color "$ICyan" "Checking for new Nextcloud version..."

# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode

# Check if root
root_check

NCMIN=$(curl -s -m 900 $NCREPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | grep "${CURRENTVERSION%%.*}" | tail -1)
REPORTEDMAJ="$CURRENTVERSION"
REPORTEDMIN="$CURRENTVERSION"

# Check for supported Nextcloud version
if [ "${CURRENTVERSION%%.*}" -lt "$NCBAD" ]
then
    notify_admin_gui \
        "Your Nextcloud version is End of Life! Please upgrade as soon as possible!" \
        "Nextcloud ${CURRENTVERSION%%.*} doesn't get security updates anymore. \
You should because of that update to a supported Nextcloud version as soon as possible. \
You can check your Nextcloud with the security scanner: 'https://scan.nextcloud.com/'"
fi

if [ "$CURRENTVERSION" == "$NCVERSION" ] && [ "$CURRENTVERSION" == "$NCMIN" ]
then
    print_text_in_color "$IGreen" "You already run the latest version! ($NCVERSION)"
    exit
fi

if [ "$REPORTEDMAJ" == "$NCVERSION" ] && [ "$REPORTEDMIN" == "$NCMIN" ]
then
    print_text_in_color "$ICyan" "The notification regarding the new Nextcloud update has been already reported!"
    exit
fi

if [ "$NCVERSION" == "$NCMIN" ] && version_gt "$NCMIN" "$REPORTEDMIN" && version_gt "$NCMIN" "$CURRENTVERSION"
then
    sed -i "s|^REPORTEDMAJ.*|REPORTEDMAJ=$NCVERSION|" $SCRIPTS/updatenotification.sh
    sed -i "s|^REPORTEDMIN.*|REPORTEDMIN=$NCMIN|" $SCRIPTS/updatenotification.sh
    if crontab -l -u root | grep -q $SCRIPTS/update.sh
    then
        notify_admin_gui \
        "New minor Nextcloud Update!" \
        "Nextcloud $NCMIN just became available. Since you are running Automatic \
Updates on Saturdays at $AUT_UPDATES_TIME:00, you don't need to bother about updating \
the server to minor Nextcloud versions manually, as that's already taken care of."
    else
        notify_admin_gui \
        "New minor Nextcloud Update!" \
        "Nextcloud $NCMIN just became available. Please run 'sudo bash \
/var/scripts/update.sh minor' from your CLI to update your server to Nextcloud $NCMIN."
    fi
    exit
fi

if version_gt "$NCMIN" "$REPORTEDMIN" && version_gt "$NCMIN" "$CURRENTVERSION"
then
    sed -i "s|^REPORTEDMIN.*|REPORTEDMIN=$NCMIN|" $SCRIPTS/updatenotification.sh
    if crontab -l -u root | grep -q $SCRIPTS/update.sh
    then
        notify_admin_gui \
        "New minor Nextcloud Update!" \
        "Nextcloud $NCMIN just became available. Since you are running Automatic \
Updates on Saturdays at $AUT_UPDATES_TIME:00, you don't need to bother about updating \
the server to minor Nextcloud versions manually, as that's already taken care of."
    else
        notify_admin_gui \
        "New minor Nextcloud Update!" \
        "Nextcloud $NCMIN just became available. Please run 'sudo bash \
/var/scripts/update.sh minor' from your CLI to update your server to Nextcloud $NCMIN."
    fi
fi

if version_gt "$NCVERSION" "$REPORTEDMAJ" && version_gt "$NCVERSION" "$CURRENTVERSION"
then
    sed -i "s|^REPORTEDMAJ.*|REPORTEDMAJ=$NCVERSION|" $SCRIPTS/updatenotification.sh
    notify_admin_gui \
    "New major Nextcloud Update!" \
    "Nextcloud $NCVERSION just became available. Please run 'sudo bash \
/var/scripts/update.sh' from your CLI to update your server to Nextcloud $NCVERSION. \
Before updating though, you should visit https://your-nc-domain/settings/admin/overview \
and make sure that all apps are compatible with the new version. And please never forget to \
create a backup and/or snapshot before updating!"
fi