--- /dev/null
+[Unit]
+Description=Water meter pulse counter
+
+[Service]
+Type=forking
+Environment="SENSOR_MAC=xx:xx:xx:xx:xx:xx"
+ExecStart=/usr/local/bin/pulsecounter -d -b ${SENSOR_MAC}
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: pulsecounter
+# Required-Start: $local_fs $remote_fs $syslog $network
+# Required-Stop: $local_fs $remote_fs $syslog $network
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Water meter pulse counter
+### END INIT INFO
+
+PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin"
+DAEMON="/usr/local/bin/pulsecounter"
+
+test -x "$DAEMON" || exit 0
+
+NAME="pulsecounter"\
+DESC="Water meter pulse counter"
+PIDFILE="/var/run/pulsecounter.pid"
+DEFAULTS="/etc/default/pulsecounter"
+
+set -e
+
+[ -r "$DEFAULTS" ] && . "$DEFAULTS"
+
+. /lib/lsb/init-functions
+
+do_start()
+{
+ start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- \
+ -d -b $SENSOR_MAC
+}
+
+do_stop ()
+{
+ start-stop-daemon --stop --quiet --oknodo --name $NAME
+}
+
+case "$1" in
+ start)
+ init_is_upstart > /dev/null 2>&1 && exit 1
+ log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ log_end_msg $?
+ ;;
+ stop)
+ init_is_upstart > /dev/null 2>&1 && exit 0
+ log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ log_end_msg $?
+ ;;
+ restart|force-reload)
+ init_is_upstart > /dev/null 2>&1 && exit 1
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ sleep 1
+ do_start
+ log_end_msg $?
+ ;;
+ status)
+ status_of_proc $DAEMON $NAME
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
+ exit 3
+ ''
+esac
+