diff --git a/README.md b/README.md index f866fed9..bcc75075 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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: diff --git a/configs/procd/godns b/configs/procd/godns new file mode 100755 index 00000000..bb226cb0 --- /dev/null +++ b/configs/procd/godns @@ -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 +} +