summaryrefslogtreecommitdiff
path: root/ext/installfiles/mac-update
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2018-04-25 06:39:02 -0700
committerGitHub <noreply@github.com>2018-04-25 06:39:02 -0700
commit42ec780a6f6eedef4d8b1d8218bd72fc6ed75cc0 (patch)
tree7bf86c4d92d6a0f77eced79bfc33313c62c7b6dd /ext/installfiles/mac-update
parent18c9dc8a0649c866eff9f299f20fa5b19c502e52 (diff)
parent4608880fb06700822d01e9e5d6729fcdeb82b64b (diff)
downloadinfinitytier-42ec780a6f6eedef4d8b1d8218bd72fc6ed75cc0.tar.gz
infinitytier-42ec780a6f6eedef4d8b1d8218bd72fc6ed75cc0.zip
Merge branch 'dev' into netbsd-support
Diffstat (limited to 'ext/installfiles/mac-update')
-rw-r--r--ext/installfiles/mac-update/updater.tmpl.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/ext/installfiles/mac-update/updater.tmpl.sh b/ext/installfiles/mac-update/updater.tmpl.sh
new file mode 100644
index 00000000..0b07f6d9
--- /dev/null
+++ b/ext/installfiles/mac-update/updater.tmpl.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+export PATH=/bin:/usr/bin:/sbin:/usr/sbin
+shopt -s expand_aliases
+
+if [ "$UID" -ne 0 ]; then
+ echo '*** Auto-updater must be run as root.'
+ exit 1
+fi
+
+scriptPath="`dirname "$0"`/`basename "$0"`"
+if [ ! -s "$scriptPath" ]; then
+ scriptPath="$0"
+ if [ ! -s "$scriptPath" ]; then
+ echo "*** Auto-updater cannot determine its own path; $scriptPath is not readable."
+ exit 2
+ fi
+fi
+
+endMarkerIndex=`grep -a -b -E '^################' "$scriptPath" | head -c 16 | cut -d : -f 1`
+if [ "$endMarkerIndex" -le 100 ]; then
+ echo 'Internal error: unable to find end of script / start of binary data marker.'
+ exit 2
+fi
+blobStart=`expr $endMarkerIndex + 17`
+if [ "$blobStart" -le "$endMarkerIndex" ]; then
+ echo 'Internal error: unable to find end of script / start of binary data marker.'
+ exit 2
+fi
+
+rm -f /tmp/ZeroTierOne-update.pkg
+tail -c +$blobStart "$scriptPath" >/tmp/ZeroTierOne-update.pkg
+chmod 0600 /tmp/ZeroTierOne-update.pkg
+
+if [ -s /tmp/ZeroTierOne-update.pkg ]; then
+ rm -f '/Library/Application Support/ZeroTier/One/latest-update.exe' '/Library/Application Support/ZeroTier/One/latest-update.json' /tmp/ZeroTierOne-update.log
+ installer -verbose -pkg /tmp/ZeroTierOne-update.pkg -target / >/tmp/ZeroTierOne-update.log 2>&1
+ rm -f /tmp/ZeroTierOne-update.pkg
+ exit 0
+else
+ echo '*** Error self-unpacking update!'
+ exit 3
+fi
+
+# Do not remove the last line or add a carriage return to it! The installer
+# looks for an unterminated line beginning with 16 #'s in itself to find
+# the binary blob data, which is appended after it.
+
+################ \ No newline at end of file