diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-04-04 19:25:23 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-04-04 19:25:23 +0300 |
commit | c60ee017ab7a5e5cbbcf7166e87806a878be0e11 (patch) | |
tree | 97ae7571e340204f67eb256e0d4500382d01d34f | |
parent | 1c19f4c3620d5bc4b13458306ab29587890e2cee (diff) |
protect ncp-update from self modificationsv0.5.7
-rwxr-xr-x | bin/ncp-update | 29 | ||||
-rwxr-xr-x | nextcloud.sh | 29 |
2 files changed, 32 insertions, 26 deletions
diff --git a/bin/ncp-update b/bin/ncp-update index 12089bf1..c387d515 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 46059c6f..c5be3168 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 |