Skip to content

Commit

Permalink
protect ncp-update from self modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Apr 4, 2017
1 parent 1c19f4c commit c60ee01
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
29 changes: 16 additions & 13 deletions bin/ncp-update
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 16 additions & 13 deletions nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c60ee01

Please sign in to comment.