opendns/dnscrypt-proxy — Issue #5: init.d script
Author: evoserver
Created: 2012-01-30 10:57:07+00:00
State: open

Hello

I'm testing your dnscypt service. I modified a init.d script but I'm still having some issues at reboot.
Here is the log:

dnscrypt-proxy[1774]: Generating a new key pair
dnscrypt-proxy[1774]: Done
dnscrypt-proxy[1774]: Unable to bind [192.168.4.1] (TCP)

However if I start the service manually with "/etc/init.d/dnscrypt start", it works flawlessly.
dnscrypt-proxy[2885]: Generating a new key pair
dnscrypt-proxy[2885]: Done
dnscrypt-proxy[2885]: Server certificate #1323392947 received
dnscrypt-proxy[2885]: This certificate looks valid
dnscrypt-proxy[2885]: Server key fingerprint is E07C:5F90:03C2:D764:A9FC:9A1E:6633:632A:0FE0:B1C5:5EF9:894A:FC7A:BA18:4A62:462E
dnscrypt-proxy[2885]: dnscrypt-proxy is ready: proxying from [192.168.4.1] to [208.67.220.220]

The init.d script is the following:

#! /bin/sh
### BEGIN INIT INFO
# Provides: dnsCrypt
# Required-Start: $local_fs $remote_fs $network $named $time $syslog
# Required-Stop: $local_fs $remote_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: SEcure DNS ssl proxy, initscript made by Dju and modified by EVO
### END INIT INFO

DC_BIN=/usr/local/sbin/dnscrypt-proxy
DC_NAME=$(basename $DC_BIN)
DC_CONF=/etc/default/dnscrypt
DC_USER=nobody
DC_IP=192.168.4.1
DC_PORT=53
DC_ARGS=""

if [ -f $DC_CONF ]; then . $DC_CONF; fi

dc_start()
{
$DC_BIN -a $DC_IP -P $DC_PORT -d -u $DC_USER $DC_ARGS
}

dc_stop()
{
killall $DC_NAME
}

dc_status()
{
pid=$(pidof $(basename $DC_BIN))
if [ -z "$pid" ]; then
echo "$DC_NAME is not running"
else
echo "$DC_NAME is running with pid $pid"
fi
}

case "$1" in
start)
echo -n "starting $DC_NAME ..."
dc_start
echo OK
;;
stop)
echo -n "Stopping $DC_NAME ..."
dc_stop
echo OK
;;
status)
dc_status
;;
*)
echo "Usage: /etc/init.d/dnscrypt {start|stop|status}"
exit 1
;;
esac