diff options
author | nachoparker <nacho@ownyourbits.com> | 2019-01-14 01:41:42 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2019-01-14 01:41:52 +0300 |
commit | 61e3ff31b530f0e1c05960da212d7241c26bdd2a (patch) | |
tree | 4e4b32895b66f25433204bc85b56cca115cba250 /bin/ncp-update | |
parent | 96a80213724682bccd43bfdfb6dcc573b30b5d98 (diff) |
ncp-update: fail if version cant be parsedv1.3.1
Diffstat (limited to 'bin/ncp-update')
-rwxr-xr-x | bin/ncp-update | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/bin/ncp-update b/bin/ncp-update index a68afc26..93c11408 100755 --- a/bin/ncp-update +++ b/bin/ncp-update @@ -9,7 +9,7 @@ [[ "$BRANCH" != "master" ]] && echo "INFO: updating to development branch '$BRANCH'" TMPDIR="$( mktemp -d /tmp/ncp-update.XXXXXX || ( echo "Failed to create temp dir. Exiting" >&2; exit 1 ) )" - trap "rm -rf \"${TMPDIR}\"; exit 0" 0 1 2 3 15 + trap "cd /; rm -rf \"${TMPDIR}\"; exit 0" 0 1 2 3 15 echo -e "Downloading updates" git clone --depth 20 -b "$BRANCH" -q https://github.com/nextcloud/nextcloudpi.git "$TMPDIR" || { @@ -24,18 +24,19 @@ cd "$TMPDIR" VER=$( git describe --always --tags | grep -oP "v\d+\.\d+\.\d+" ) - grep -qP "v\d+\.\d+\.\d+" <<< "$VER" && { # check format - echo "$VER" > /usr/local/etc/ncp-version - echo "$VER" > /var/run/.ncp-latest-version - - # write changelog - git log --graph --oneline --decorate \ - --pretty=format:"[%D] %s" --date=short | \ - grep 'tag: v' | \ - sed '/HEAD ->\|origin/s|\[.*\(tag: v[0-9]\+\.[0-9]\+\.[0-9]\+\).*\]|[\1]|' | \ - sed 's|* \[tag: |[|' > /usr/local/etc/ncp-changelog - } - cd / + + # check format + grep -qP "v\d+\.\d+\.\d+" <<< "$VER" || { "Error: missing version"; exit 1; } + + echo "$VER" > /usr/local/etc/ncp-version + echo "$VER" > /var/run/.ncp-latest-version + + # write changelog + git log --graph --oneline --decorate \ + --pretty=format:"[%D] %s" --date=short | \ + grep 'tag: v' | \ + sed '/HEAD ->\|origin/s|\[.*\(tag: v[0-9]\+\.[0-9]\+\.[0-9]\+\).*\]|[\1]|' | \ + sed 's|* \[tag: |[|' > /usr/local/etc/ncp-changelog echo -e "NextCloudPi updated to version $VER" exit 0 |