diff --git a/bin/ncp-check-updates b/bin/ncp-check-updates index 0a483b760..c30176abd 100755 --- a/bin/ncp-check-updates +++ b/bin/ncp-check-updates @@ -1,6 +1,9 @@ #!/bin/bash - cat > /usr/local/bin/ncp-check-updates <<'EOF' + +# print message if an update is available + VERFILE=/var/run/.ncp-latest-version + if ncp-test-updates; then echo -e "\nNextCloudPi \e[1m$( cat $VERFILE )\e[0m available!!" echo -e "update through 'nextcloudpi-config' or type 'sudo ncp-update'" diff --git a/bin/ncp-check-version b/bin/ncp-check-version new file mode 100755 index 000000000..1c97a9d9f --- /dev/null +++ b/bin/ncp-check-version @@ -0,0 +1,15 @@ +#!/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 -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-check-tmp || exit 1 + +cd /tmp/ncp-check-tmp +git describe --always --tags > /var/run/.ncp-latest-version +cd / + +rm -rf /tmp/ncp-check-tmp diff --git a/bin/ncp-test-updates b/bin/ncp-test-updates index bc7867eb9..08617f76c 100755 --- a/bin/ncp-test-updates +++ b/bin/ncp-test-updates @@ -1,5 +1,7 @@ #!/bin/bash +# given in disk version information, return 0 if an update is available + NEED_UPDATE=false VERFILE=/var/run/.ncp-latest-version diff --git a/bin/ncp-update b/bin/ncp-update new file mode 100755 index 000000000..12089bf1d --- /dev/null +++ b/bin/ncp-update @@ -0,0 +1,21 @@ +#!/bin/bash + +# update latest NextCloudPi code from github + +ping -W 2 -w 1 -q github.com &>/dev/null || { echo "No internet connectivity"; exit 1; } +echo -e "Downloading updates" +rm -rf /tmp/ncp-update-tmp +git clone -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-update-tmp || exit 1 +cd /tmp/ncp-update-tmp + +echo -e "Performing updates" +./update.sh + +VER=$( git describe --always --tags ) +echo $VER > /usr/local/etc/ncp-version +echo $VER > /var/run/.ncp-latest-version + +cd / +rm -rf /tmp/ncp-update-tmp + +echo -e "NextCloudPi updated to version \e[1m$VER\e[0m" diff --git a/nextcloud.sh b/nextcloud.sh index a8d651b4b..46059c6f7 100755 --- a/nextcloud.sh +++ b/nextcloud.sh @@ -264,23 +264,12 @@ EOF chmod a+x /etc/cron.daily/ncp-check-version - cat > /usr/local/bin/ncp-check-version <<'EOF' -#!/bin/bash -[ $(id -u) -ne 0 ] && exit 1 -git clone -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-check-tmp -cd /tmp/ncp-check-tmp -git describe --always --tags > /var/run/.ncp-latest-version -cd / -rm -rf /tmp/ncp-check-tmp -EOF - chmod a+x /usr/local/bin/ncp-check-version - - cat > /usr/local/bin/ncp-update <<'EOF' #!/bin/bash +ping -W 2 -w 1 -q github.com &>/dev/null || { echo "No internet connectivity"; exit 1; } echo -e "Downloading updates" rm -rf /tmp/ncp-update-tmp -git clone -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-update-tmp +git clone -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-update-tmp || exit 1 cd /tmp/ncp-update-tmp echo -e "Performing updates"