Skip to content

Commit 98846dd

Browse files
evie-lauCopilot
andauthored
Add retry mechanism, directly reference commands (#25)
* Add retry mechanism, directly reference commands Added retry logic for failures with dpkg Updated commands to remove shell wrapper --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 8725274 commit 98846dd

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,25 +243,32 @@ Requires=network-online.target
243243

244244
[Service]
245245
Type=oneshot
246-
ExecStartPre=/bin/sh -c 'dpkg -Ri /etc/wpa_supplicant/packages'
246+
ExecStartPre=/usr/bin/dpkg -Ri /etc/wpa_supplicant/packages
247247
# 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
248248
# 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'
249-
ExecStart=/bin/sh -c 'systemctl start wpa_supplicant-wired@eth1'
250-
ExecStartPost=/bin/sh -c 'systemctl enable wpa_supplicant-wired@eth1'
249+
ExecStart=/bin/systemctl start wpa_supplicant-wired@eth1
250+
ExecStartPost=/bin/systemctl enable wpa_supplicant-wired@eth1
251+
251252
Restart=on-failure
253+
RestartSec=20
254+
255+
# Allow up to 10 attempts within ~300 seconds
256+
StartLimitIntervalSec=300
257+
StartLimitBurst=10
252258

253259
[Install]
254260
WantedBy=multi-user.target
255261
```
262+
256263
Now enable the service.
257264
```bash
258265
> systemctl daemon-reload
259266
> systemctl enable reinstall-wpa.service
260267
```
261-
This service should run on startup. It will check if `/sbin/wpa_supplicant` got wiped, and if our package files exist. If both are true, it will install and startup wpa_supplicant.
268+
This service should run on startup. It will check if `/sbin/wpa_supplicant` got wiped, and if our package files exist. If both are true, it will install and startup wpa_supplicant. If `dpkg` or starting `wpa_supplicant` fail, the service will retry every 20 seconds up to 10 times.
262269

263270
<details>
264-
<summary><h3>(Optional) If you want to test this...</h3></summary>
271+
<summary><h3>(Optional) If you want to test this, click here...</h3></summary>
265272

266273
```bash
267274
> systemctl stop wpa_supplicant-wired@eth1

0 commit comments

Comments
 (0)