File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8181 systemd . services . mullvad-config = {
8282 description = "Configure Mullvad VPN settings" ;
8383 wantedBy = [ "multi-user.target" ] ;
84- wants = [ "mullvad-daemon.service" "network-online.target" ] ;
8584 after = [ "mullvad-daemon.service" "network-online.target" ] ;
85+ requires = [ "mullvad-daemon.service" "network-online.target" ] ;
8686 serviceConfig = {
8787 Type = "oneshot" ;
8888 RemainAfterExit = true ;
8989 ExecStart = pkgs . writeShellScript "configure-mullvad" ''
9090 for i in {1..30}; do
9191 if ${ mullvadPkg } /bin/mullvad status &>/dev/null; then
92+ echo "Mullvad daemon is ready with relay list available"
93+ sleep 2
9294 break
9395 fi
9496 sleep 1
99101 echo "Logging in to Mullvad account..."
100102 ACCOUNT_NUMBER=$(cat ${ cfg . accountNumberPath } )
101103 ${ mullvadPkg } /bin/mullvad account login "$ACCOUNT_NUMBER"
104+
105+ echo "Waiting for relay list to download..."
106+ for i in {1..30}; do
107+ RELAY_COUNT=$(${ mullvadPkg } /bin/mullvad relay list 2>/dev/null | wc -l)
108+ if [ "$RELAY_COUNT" -gt 10 ]; then
109+ echo "Relay list populated ($RELAY_COUNT lines)"
110+ sleep 1
111+ break
112+ fi
113+ sleep 1
114+ done
102115 fi
103116 '' }
104117
125138 ${ mullvadPkg } /bin/mullvad auto-connect set on
126139 ${ mullvadPkg } /bin/mullvad connect
127140 '' }
141+
128142 ${ optionalString ( ! cfg . autoConnect ) ''
129143 ${ mullvadPkg } /bin/mullvad auto-connect set off
130144 '' }
Original file line number Diff line number Diff line change 7373 APPLICATION_NAME=$(echo "$application" | ${ pkgs . jq } /bin/jq -r '.name')
7474 APPLICATION_ID=$(echo "$application" | ${ pkgs . jq } /bin/jq -r '.id')
7575
76- if ! echo "$CONFIGURED_NAMES" | ${ pkgs . jq } /bin/jq -e --arg name "$APPLICATION_NAME" 'index($name)' >/dev/null 2>&1 ; then
76+ if ! echo "$CONFIGURED_NAMES" | ${ pkgs . jq } /bin/jq -e --arg name "$APPLICATION_NAME" 'index($name)' >/dev/null; then
7777 echo "Deleting application not in config: $APPLICATION_NAME (ID: $APPLICATION_ID)"
7878 ${ pkgs . curl } /bin/curl -sSf -X DELETE \
7979 -H "X-Api-Key: $API_KEY" \
You can’t perform that action at this time.
0 commit comments