diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-04-03 20:59:44 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-04-03 21:28:26 +0300 |
commit | 9b5cd8126f05a8151e78410df994c00a20c49f75 (patch) | |
tree | d74190d05cc1103969bb482d183037d627a50c9e /bin/ncp-test-updates | |
parent | 138fecc9f67eb2aaba6c50bf39cf22a16891f7c8 (diff) |
check for updates (and update) upon launching nextcloudpi-configv0.5.3
Diffstat (limited to 'bin/ncp-test-updates')
-rwxr-xr-x | bin/ncp-test-updates | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/ncp-test-updates b/bin/ncp-test-updates new file mode 100755 index 00000000..bc7867eb --- /dev/null +++ b/bin/ncp-test-updates @@ -0,0 +1,24 @@ +#!/bin/bash + +NEED_UPDATE=false +VERFILE=/var/run/.ncp-latest-version + +if test -f $VERFILE && 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 > $MAJ ]]; then + NEED_UPDATE=true + elif [[ $MAJOR == $MAJ ]] && [[ $MINOR > $MIN ]]; then + NEED_UPDATE=true + elif [[ $MAJOR == $MAJ ]] && [[ $MINOR == $MIN ]] && [[ $PATCH > $PAT ]]; then + NEED_UPDATE=true + fi +fi +[[ "$NEED_UPDATE" == "true" ]] && exit 0 |