Skip to content

Commit d1bd7f1

Browse files
committed
Add retry conf for wpa_supplicant service. Fix systemd config lines.
1 parent 524d12b commit d1bd7f1

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

README.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,29 @@ Now we can go ahead and enable the service.
199199

200200
Try restarting your Unifi gateway if you wish, and it should automatically authenticate!
201201

202-
If WAN doesn't come back up after a restart, it may be that wpa_supplicant is starting too soon. In that case, adding a 10s "sleep" has helped for some. Note: 10s has been tested successfully on a UDM Pro. If you have other hardware and WAN does not come back up, I suggest you incrementally increase from 10s until a restart results in your WAN connection coming back up successfully.
202+
### Add failure tolerance to wpa_supplicant
203+
If WAN doesn't come back up after a restart, it may be that wpa_supplicant is starting too soon. Regardless, we can configure a retry for the wpa_supplicant service.
204+
203205
```bash
204-
> grep -q "ExecStartPre" /lib/systemd/system/wpa_supplicant-wired\@.service || sed -i "/Type\=simple/a ExecStartPre=/bin/sleep 10" /lib/systemd/system/wpa_supplicant-wired\@.service
206+
> vi /etc/systemd/system/wpa_supplicant-wired@.service.d/restart-on-failure.conf
207+
```
208+
209+
```ini
210+
[Unit]
211+
# Allow up to 10 attempts within a 3 minute window
212+
StartLimitIntervalSec=3min
213+
StartLimitBurst=10
214+
215+
[Service]
216+
# Enable restarting on failure
217+
Restart=on-failure
218+
# Wait 10 seconds between restart attempts
219+
RestartSec=10s
205220
```
206221

222+
This `.conf` file specifying the retries will tie in to the wpa_supplicant-wired services, regardless of the eth number port.
223+
224+
207225
## Survive firmware updates
208226
Firmware updates will nuke the packages installed through `apt` that don't come with the stock Unifi OS, removing our `wpasupplicant` package and service. Since we'll no longer have internet without wpa_supplicant authenticating us with ATT, we can't reinstall it from the debian repos.
209227

@@ -238,24 +256,23 @@ Description=Reinstall and start/enable wpa_supplicant
238256
AssertPathExistsGlob=/etc/wpa_supplicant/packages/wpasupplicant*arm64.deb
239257
AssertPathExistsGlob=/etc/wpa_supplicant/packages/libpcsclite1*arm64.deb
240258
ConditionPathExists=!/sbin/wpa_supplicant
259+
241260
After=network-online.target
242261
Requires=network-online.target
243262

263+
# Allow up to 10 attempts within ~300 seconds
264+
StartLimitIntervalSec=300
265+
StartLimitBurst=10
266+
244267
[Service]
245268
Type=oneshot
246269
ExecStartPre=/usr/bin/dpkg -Ri /etc/wpa_supplicant/packages
247-
# If you needed to add a sleep to your wpa_supplicant service startup to successfully restore your WAN connection on restart, uncomment the following line (and update "sleep 10" to "sleep <whatever_timing_worked_for_you>") to persist that setting
248-
# ExecStartPre=/bin/sh -c 'grep -q "ExecStartPre" /lib/systemd/system/wpa_supplicant-wired\@.service || sed -i "/Type\=simple/a ExecStartPre=/bin/sleep 10" /lib/systemd/system/wpa_supplicant-wired\@.service'
249270
ExecStart=/bin/systemctl start wpa_supplicant-wired@eth1
250271
ExecStartPost=/bin/systemctl enable wpa_supplicant-wired@eth1
251272

252273
Restart=on-failure
253274
RestartSec=20
254275

255-
# Allow up to 10 attempts within ~300 seconds
256-
StartLimitIntervalSec=300
257-
StartLimitBurst=10
258-
259276
[Install]
260277
WantedBy=multi-user.target
261278
```
@@ -297,8 +314,10 @@ etc
297314
│ └── if-up.d
298315
│ └── **changemac** (if needed for MAC spoof)
299316
├── systemd
300-
│ └── system
301-
│ └── **reinstall-wpa.service**
317+
│ ├── system
318+
│ │ └── **reinstall-wpa.service**
319+
│ └── wpa_supplicant-wired@.service.d
320+
│ └── **restart-on-failure.conf**
302321
└── wpa_supplicant
303322
├── **wpa_supplicant-wired-eth1.conf**
304323
├── certs

0 commit comments

Comments
 (0)