nextcloudpi/bin/ncp-check-version
2017-08-16 00:37:50 +02:00

19 lines
533 B
Bash
Executable File

#!/bin/bash
# update latest available version in /var/run/.ncp-latest-version
[ $(id -u) -ne 0 ] && exit 1
ping -W 2 -w 1 -q github.com &>/dev/null || { echo "No internet connectivity"; exit 1; }
git clone --depth 20 -q --bare https://github.com/nextcloud/nextcloudpi.git /tmp/ncp-check-tmp || exit 1
cd /tmp/ncp-check-tmp
VER=$( git describe --always --tags | grep -oP "v\d+\.\d+\.\d+" )
grep -qP "v\d+\.\d+\.\d+" <<< $VER && { # check format
echo $VER > /var/run/.ncp-latest-version
}
cd /
rm -rf /tmp/ncp-check-tmp