Skip to content

Commit

Permalink
Add OpenWRT procd service script
Browse files Browse the repository at this point in the history
  • Loading branch information
Starrah committed Oct 28, 2024
1 parent 254f045 commit 5dcdc59
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
- [As a manual daemon](#as-a-manual-daemon)
- [As a managed daemon (with upstart)](#as-a-managed-daemon-with-upstart)
- [As a managed daemon (with systemd)](#as-a-managed-daemon-with-systemd)
- [As a managed daemon (with procd)](#as-a-managed-daemon-with-procd)
- [As a Docker container](#as-a-docker-container)
- [As a Windows service](#as-a-windows-service)
- [Contributing](#contributing)
Expand Down Expand Up @@ -1167,6 +1168,17 @@ Note: when the program stops, it will not be restarted.
sudo systemctl start godns
```
### As a managed daemon (with procd)
`procd` is the init system on OpenWRT. If you want to use godns as a service with OpenWRT and procd:
1. Copy `./config/procd/godns` to `/etc/init.d` (and tweak it to your needs)
2. Start the service (with root privilege):
```bash
service godns enable
service godns start
```
### As a Docker container
Available docker registries:
Expand Down
21 changes: 21 additions & 0 deletions configs/procd/godns
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh /etc/rc.common

# Put this script at /etc/init.d/godns
# To start: `service godns start`
# To enable (i.e. auto-start on boot): `service godns enable`

USE_PROCD=1
START=98
PROG="/path/to/your/godns-dir/godns"
CONF="/path/to/your/godns-dir/config.json"

start_service() {
procd_open_instance
procd_set_param command "$PROG"
procd_append_param command -c="$CONF"
#procd_set_param stdout 1 # if enabled, log will go into syslog
procd_set_param stderr 1
procd_set_param respawn 600 10 10
procd_close_instance
}

0 comments on commit 5dcdc59

Please sign in to comment.