blob: e439a55ec4627b844e4f62a75d3eb6a8392c153d (
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
|
#!/bin/bash
# given in disk version information, return 0 if an update is available
NEED_UPDATE=false
VERFILE=/var/run/.ncp-latest-version
[[ $( cat $VERFILE | wc -c ) -eq 0 ]] && ncp-check-version
if grep -qP "v\d+\.\d+\.\d+" $VERFILE; then
MAJOR=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f1 )
MINOR=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f2 )
PATCH=$( grep -oP "\d+\.\d+\.\d+" $VERFILE | cut -d. -f3 )
MAJ=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f1 )
MIN=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f2 )
PAT=$( grep -oP "\d+\.\d+\.\d+" /usr/local/etc/ncp-version | cut -d. -f3 )
if [ "$MAJOR" -gt "$MAJ" ]; then
NEED_UPDATE=true
elif [ "$MAJOR" -eq "$MAJ" ] && [ "$MINOR" -gt "$MIN" ]; then
NEED_UPDATE=true
elif [ "$MAJOR" -eq "$MAJ" ] && [ "$MINOR" -eq "$MIN" ] && [ "$PATCH" -gt "$PAT" ]; then
NEED_UPDATE=true
fi
fi
[[ "$NEED_UPDATE" == "true" ]] && exit 0
|