#!/bin/sh /etc/rc.common START=90 PIDFILE=/var/run/tunneldigger.pid tunnel_id=1 config_cb() { local cfg="$CONFIG_SECTION" config_get configname "$cfg" TYPE case "$configname" in broker) config_get addresses "$cfg" address config_get uuid "$cfg" uuid config_get interface "$cfg" interface config_get limit_bw_down "$cfg" limit_bw_down config_get hook_script "$cfg" hook_script local broker_opts="" for address in $addresses; do broker_opts="${broker_opts} -b ${address}" done if [ ! -z "${limit_bw_down}" ]; then broker_opts="${broker_opts} -L ${limit_bw_down}" fi echo "Starting tunneldigger on ${interface}" /sbin/start-stop-daemon -S -q -b -m -p $PIDFILE -x /usr/bin/tunneldigger -- -u ${uuid} -i ${interface} -t ${tunnel_id} -s ${hook_script} ${broker_opts} let tunnel_id++ ;; esac } start() { config_load tunneldigger } stop() { echo "Stopping tunneldigger" if [ -f $PIDFILE ]; then PID=`cat ${PIDFILE}` start-stop-daemon -K -q -p $PIDFILE while test -d "/proc/${PID}"; do echo "waiting for tunneldigger to stop" sleep 1 done echo "tunneldigger stopped" else echo "Looks like tunneldigger wasn't running" fi } restart() { stop start }