Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 31bdfa5

Browse files
authoredMay 8, 2025··
fix(pkgbuild): dont start coder connect after upgrade (#150)
As part of my work on #121 and trying to reproduce the behaviour in a VM, I discovered the issue consistently occurs if the VPN is running when the app is launched (as the network extension is replaced on upgrade). The existing pkgbuild scripts don't account for the VPN running with the app closed. In this scenario the `preinstall` script creates a marker file saying the VPN should be started in the `postinstall`. A marker file saying the app is running is not created. Then, in the `postinstall` the VPN is started, but not the app. When the user does launch the app, the network extension is upgraded whilst the VPN is running, and the linked issue occurs. It's not possible to write a bash script that waits for not only the app to launch, but for the network extension replacement request to be sent and handled. However, we already do this in Swift code. If `Start Coder Connect on launch` is toggled on, the VPN won't be started until it is absolutely safe to do so. <img width="604" alt="image" src="https://github.com/user-attachments/assets/010446b6-be33-47f0-9e59-4131f89d46a0" /> Therefore, we'll remove the portion of the pkgbuild scripts responsible for turning the VPN on after upgrade. If users want this behaviour, they can just toggle it on in settings.
1 parent 79b0f7c commit 31bdfa5

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed
 

‎pkgbuild/scripts/postinstall

-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env bash
22

33
RUNNING_MARKER_FILE="/tmp/coder_desktop_running"
4-
VPN_MARKER_FILE="/tmp/coder_vpn_was_running"
54

65
# Before this script, or the user, opens the app, make sure
76
# Gatekeeper has ingested the notarization ticket.
@@ -19,14 +18,4 @@ if [ -f "$RUNNING_MARKER_FILE" ]; then
1918
echo "Coder Desktop started."
2019
fi
2120

22-
# Restart VPN if it was running before
23-
if [ -f "$VPN_MARKER_FILE" ]; then
24-
echo "Restarting CoderVPN..."
25-
echo "Sleeping for 3..."
26-
sleep 3
27-
scutil --nc start "$(scutil --nc list | grep "com.coder.Coder-Desktop" | awk -F'"' '{print $2}')"
28-
rm "$VPN_MARKER_FILE"
29-
echo "CoderVPN started."
30-
fi
31-
3221
exit 0

‎pkgbuild/scripts/preinstall

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env bash
22

33
RUNNING_MARKER_FILE="/tmp/coder_desktop_running"
4-
VPN_MARKER_FILE="/tmp/coder_vpn_was_running"
54

6-
rm $VPN_MARKER_FILE $RUNNING_MARKER_FILE || true
5+
rm $RUNNING_MARKER_FILE || true
76

87
if pgrep 'Coder Desktop'; then
98
touch $RUNNING_MARKER_FILE
@@ -14,9 +13,6 @@ vpn_name=$(scutil --nc list | grep "com.coder.Coder-Desktop" | awk -F'"' '{print
1413
echo "Turning off VPN"
1514
if [[ -n "$vpn_name" ]]; then
1615
echo "CoderVPN found. Stopping..."
17-
if scutil --nc status "$vpn_name" | grep -q "^Connected$"; then
18-
touch $VPN_MARKER_FILE
19-
fi
2016
scutil --nc stop "$vpn_name"
2117

2218
# Wait for VPN to be disconnected

0 commit comments

Comments
 (0)
Please sign in to comment.