diff --git a/bin/ncp-update b/bin/ncp-update index 12089bf1d..c387d5154 100755 --- a/bin/ncp-update +++ b/bin/ncp-update @@ -2,20 +2,23 @@ # 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 +{ + 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 + 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 + 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 + cd / + rm -rf /tmp/ncp-update-tmp -echo -e "NextCloudPi updated to version \e[1m$VER\e[0m" + echo -e "NextCloudPi updated to version \e[1m$VER\e[0m" + exit +} # force to read the whole thing into memory, as its contents might change in update.sh diff --git a/nextcloud.sh b/nextcloud.sh index 46059c6f7..c5be31689 100755 --- a/nextcloud.sh +++ b/nextcloud.sh @@ -266,23 +266,26 @@ EOF 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 || exit 1 -cd /tmp/ncp-update-tmp +{ + 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 + 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 + 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 + cd / + rm -rf /tmp/ncp-update-tmp -echo -e "NextCloudPi updated to version \e[1m$VER\e[0m" + echo -e "NextCloudPi updated to version \e[1m$VER\e[0m" + exit +} EOF chmod a+x /usr/local/bin/ncp-update