-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpreinstall
executable file
·38 lines (31 loc) · 1017 Bytes
/
preinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
RUNNING_MARKER_FILE="/tmp/coder_desktop_running"
VPN_MARKER_FILE="/tmp/coder_vpn_was_running"
rm $VPN_MARKER_FILE $RUNNING_MARKER_FILE || true
if pgrep 'Coder Desktop'; then
touch $RUNNING_MARKER_FILE
fi
echo "Turning off VPN"
if scutil --nc list | grep -q "Coder"; then
echo "CoderVPN found. Stopping..."
if scutil --nc status "Coder" | grep -q "^Connected$"; then
touch $VPN_MARKER_FILE
fi
scutil --nc stop "Coder"
# Wait for VPN to be disconnected
while scutil --nc status "Coder" | grep -q "^Connected$"; do
echo "Waiting for VPN to disconnect..."
sleep 1
done
while scutil --nc status "Coder" | grep -q "^Disconnecting$"; do
echo "Waiting for VPN to complete disconnect..."
sleep 1
done
else
echo "CoderVPN not found. Nothing to stop."
fi
echo "Done."
echo "Asking com.coder.Coder-Desktop to quit..."
osascript -e 'if app id "com.coder.Coder-Desktop" is running then' -e 'quit app id "com.coder.Coder-Desktop"' -e 'end if'
echo "Done."
exit 0