Skip to content

Commit ec24f9d

Browse files
committed
wait for relay list to be populated
1 parent 69b3e84 commit ec24f9d

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

modules/mullvad.nix

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ in {
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
@@ -99,6 +101,17 @@ in {
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
@@ -125,6 +138,7 @@ in {
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
''}

modules/prowlarr/applications.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ in {
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" \

0 commit comments

Comments
 (0)