Fixing /etc/init.d/dnscrypt-proxy


I am using dnscrypt-proxy from as there is a release for arm, on my router.

The problem is that the dnscrypt-proxy in /etc/init.d is written for some kind of Linux, and not OpenWRT/LEDE.

Can someone let me know what the following commands means, and how to fix these?
[ -e /etc/sysconfig/$name ] && . /etc/sysconfig/$name

is_running() {
[ -f "$pid_file" ] && ps $(get_pid) > /dev/null 2>&1

On OpenWRT/LEDE, ps does not support a parameter.

The entire script is here and I've fixed parts of it, but the above, I do not know how to fix.

I'ved updated my dnscrypt-proxy to the following, which works:

#!/bin/sh /etc/rc.common
# by chuacw 18 Apr 2018

name=$(basename $(readlink -f $cmd))
arguments="-config /etc/config/dnscrypt-proxy.toml -logfile $stdout_log"
start_cmd="start-stop-daemon -b -S -m -p $pid_file -x $name -- $arguments"
stop_cmd="start-stop-daemon -K -p $pid_file"

# echo start cmd is: $start_cmd
# echo stop cmd is: $stop_cmd

get_pid() {
  cat "$pid_file"

start() {
  echo "Starting DNSCrypt proxy..."
  echo "See ps result for confirmation"
  ps | grep "$name"

stop() {
  echo "Stopping DNSCrypt proxy..."
  echo "See ps result below for confirmation"
  ps | grep "$name"
  rm $pid_file

Take a look here:

You can add this repo to your feeds.conf if you building your own firmware.

Otherwise you can use the init script from his repo.
The init script has procd support and works quite well.

Here is my simple script:

#!/bin/sh /etc/rc.common


start() {

	if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
		echo 'dnscrypt-proxy2 already running...' >&2
		return 1
		echo 'Starting dnscrypt-proxy2...' >&2
		$DNSCRYPTPROXY -config $CONFIG -pidfile $PIDFILE -syslog &

stop() {

	if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
		echo 'dnscrypt-proxy2 not running...' >&2
		return 1
	echo 'Stopping dnscrypt-proxy2...' >&2
	kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
	echo 'dnscrypt-proxy2 stopped...' >&2

Not as good as inkblots but it works x)

1 Like