Skip to content

Commit

Permalink
fix ncp-update with no internet access
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Apr 4, 2017
1 parent eaf3fe7 commit 1c19f4c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
5 changes: 4 additions & 1 deletion bin/ncp-check-updates
Original file line number Diff line number Diff line change
@@ -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'"
Expand Down
15 changes: 15 additions & 0 deletions bin/ncp-check-version
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions bin/ncp-test-updates
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 21 additions & 0 deletions bin/ncp-update
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 2 additions & 13 deletions nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1c19f4c

Please sign in to comment.