Dionaea: Auto Start Script on Ubuntu

Getting Dionaea to run should be very straightforward for most people.  One of the thing we need for our project is  As for us, to get our Dionaea appliance running properly, one the feature we need is to get Dionaea service running when the OS is booting. Below is the script for it (shameless ripped off from Nepenthes’s script):

#! /bin/sh
### BEGIN INIT INFO
# Required-Start:    $network
# Required-Stop:     $network
# Should-Start:
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/dionaea/bin/dionaea
NAME=dionaea
GROUP=dionaea
CONFIG_FILE="/opt/dionaea/etc/dionaea/dionaea.conf"
#dionaea -u nobody -g nogroup -r /opt/dionaea/ -w /opt/dionaea -p /opt/dionaea/var/dionaea.pid
DAEMON_OPTS="-u $NAME -g $GROUP -l all,-debug -L '*'  -w /opt/dionaea -c $CONFIG_FILE"

test -x $DAEMON || exit 0

set -e

case "$1" in
  start)
	echo -n "Starting $NAME: "
	start-stop-daemon --start --quiet --oknodo --pidfile /opt/dionaea/var/$NAME.pid \
	--background --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $NAME: "
	start-stop-daemon --stop --quiet --oknodo --pidfile /opt/dionaea/var/$NAME.pid \
	--signal 15 --exec $DAEMON
	echo "$NAME."
	;;
  restart|force-reload)
	echo -n "Restarting $NAME: "
	start-stop-daemon --stop --quiet --oknodo --pidfile /opt/dionaea/var/$NAME.pid \
	--signal 15 --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --oknodo --pidfile /opt/dionaea/var/$NAME.pid \
	--background --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0

Copy the script, rename it to dioanea and move it to /etc/init.d/

On Ubuntu, we need to activate this to reflect our desire init level for Dionaea script. Lets use defaults init :

shell$sudo update-rc.d dionaea defaults

To execute or start the dionaea service, just simply:

shell$sudo /etc/init.d/dionaea start

Leave a Reply