Skip to content

Commit c60ee01

Browse files
committed
protect ncp-update from self modifications
1 parent 1c19f4c commit c60ee01

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

bin/ncp-update

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22

33
# update latest NextCloudPi code from github
44

5-
ping -W 2 -w 1 -q github.com &>/dev/null || { echo "No internet connectivity"; exit 1; }
6-
echo -e "Downloading updates"
7-
rm -rf /tmp/ncp-update-tmp
8-
git clone -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-update-tmp || exit 1
9-
cd /tmp/ncp-update-tmp
5+
{
6+
ping -W 2 -w 1 -q github.com &>/dev/null || { echo "No internet connectivity"; exit 1; }
7+
echo -e "Downloading updates"
8+
rm -rf /tmp/ncp-update-tmp
9+
git clone -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-update-tmp || exit 1
10+
cd /tmp/ncp-update-tmp
1011

11-
echo -e "Performing updates"
12-
./update.sh
12+
echo -e "Performing updates"
13+
./update.sh
1314

14-
VER=$( git describe --always --tags )
15-
echo $VER > /usr/local/etc/ncp-version
16-
echo $VER > /var/run/.ncp-latest-version
15+
VER=$( git describe --always --tags )
16+
echo $VER > /usr/local/etc/ncp-version
17+
echo $VER > /var/run/.ncp-latest-version
1718

18-
cd /
19-
rm -rf /tmp/ncp-update-tmp
19+
cd /
20+
rm -rf /tmp/ncp-update-tmp
2021

21-
echo -e "NextCloudPi updated to version \e[1m$VER\e[0m"
22+
echo -e "NextCloudPi updated to version \e[1m$VER\e[0m"
23+
exit
24+
} # force to read the whole thing into memory, as its contents might change in update.sh

nextcloud.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -266,23 +266,26 @@ EOF
266266

267267
cat > /usr/local/bin/ncp-update <<'EOF'
268268
#!/bin/bash
269-
ping -W 2 -w 1 -q github.com &>/dev/null || { echo "No internet connectivity"; exit 1; }
270-
echo -e "Downloading updates"
271-
rm -rf /tmp/ncp-update-tmp
272-
git clone -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-update-tmp || exit 1
273-
cd /tmp/ncp-update-tmp
269+
{
270+
ping -W 2 -w 1 -q github.com &>/dev/null || { echo "No internet connectivity"; exit 1; }
271+
echo -e "Downloading updates"
272+
rm -rf /tmp/ncp-update-tmp
273+
git clone -q --depth 1 https://github.com/nachoparker/nextcloud-raspbian-generator.git /tmp/ncp-update-tmp || exit 1
274+
cd /tmp/ncp-update-tmp
274275
275-
echo -e "Performing updates"
276-
./update.sh
276+
echo -e "Performing updates"
277+
./update.sh
277278
278-
VER=$( git describe --always --tags )
279-
echo $VER > /usr/local/etc/ncp-version
280-
echo $VER > /var/run/.ncp-latest-version
279+
VER=$( git describe --always --tags )
280+
echo $VER > /usr/local/etc/ncp-version
281+
echo $VER > /var/run/.ncp-latest-version
281282
282-
cd /
283-
rm -rf /tmp/ncp-update-tmp
283+
cd /
284+
rm -rf /tmp/ncp-update-tmp
284285
285-
echo -e "NextCloudPi updated to version \e[1m$VER\e[0m"
286+
echo -e "NextCloudPi updated to version \e[1m$VER\e[0m"
287+
exit
288+
}
286289
EOF
287290
chmod a+x /usr/local/bin/ncp-update
288291

0 commit comments

Comments
 (0)