From 6bb855873d98309cf7ae9ed117615638366e5d8b Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 3 May 2017 15:03:26 -0700 Subject: [PATCH] GitHub issue #494 -- shut down and restart UI on Mac pkg install/upgrade. --- ext/installfiles/mac/postinst.sh | 9 +++++++++ ext/installfiles/mac/preinst.sh | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ext/installfiles/mac/postinst.sh b/ext/installfiles/mac/postinst.sh index 2e4f59162..4f5a50c22 100755 --- a/ext/installfiles/mac/postinst.sh +++ b/ext/installfiles/mac/postinst.sh @@ -43,4 +43,13 @@ ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-idtool launchctl load /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1 +sleep 1 + +if [ -f /tmp/zt1-gui-restart.tmp ]; + for u in `cat /tmp/zt1-gui-restart.tmp`; do + su $u -c '/Applications/ZeroTier\ One.app/Contents/MacOS/ZeroTier\ One &' >>/dev/null 2>&1 & + done +fi +rm -f /tmp/zt1-gui-restart.tmp + exit 0 diff --git a/ext/installfiles/mac/preinst.sh b/ext/installfiles/mac/preinst.sh index c2cb494b1..af2a93208 100755 --- a/ext/installfiles/mac/preinst.sh +++ b/ext/installfiles/mac/preinst.sh @@ -2,6 +2,19 @@ export PATH=/bin:/usr/bin:/sbin:/usr/sbin +rm -f /tmp/zt1-gui-restart.tmp +for i in `ps axuwww | tr -s ' ' ',' | grep -F '/Applications/ZeroTier,One.app' | grep -F -v grep | cut -d , -f 1,2 | xargs`; do + u=`echo $i | cut -d , -f 1` + p=`echo $i | cut -d , -f 2` + if [ ! -z "$u" -a "0$p" -gt 0 ]; then + kill $p >>/dev/null 2>&1 + sleep 0.2 + kill -9 $p >>/dev/null 2>&1 + echo "$u" >>/tmp/zt1-gui-restart.tmp + fi +done +chmod 0600 /tmp/zt1-gui-restart.tmp + if [ -f /Library/LaunchDaemons/com.zerotier.one.plist ]; then launchctl unload /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1 fi