#!/bin/sh # ### BEGIN INIT INFO # Provides: router-checks # Required-Start: $local_fs networking # Required-Stop: $local_fs networking # Should-Start: iptables-persistent ip6tables-persistent # Should-Stop: iptables-persistent ip6tables-persistent # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Router control ### END INIT INFO . /lib/lsb/init-functions . /etc/router-checks.conf case "$1" in start) log_daemon_msg "Starting router control..." "router-checks" if [ -f $PID_FILE ]; then log_action_msg "PID file exists" log_end_msg 1 fi /usr/local/sbin/router-checks /dev/null 2>&1 sleep 1 if [ -f $PID_FILE ]; then log_end_msg 0 else log_end_msg 1 fi ;; stop) log_daemon_msg "Stopping router control..." "router-checks" if ! [ -f $PID_FILE ]; then log_action_msg "PID file not found" log_end_msg 1 fi rm -f $PID_FILE.`cat $PID_FILE` sleep 2 if [ -f "$PID_FILE" ]; then count=18 log_action_begin_msg " Waiting" while [ $count -gt 0 ] && [ -f "$PID_FILE" ]; do sleep 5 log_action_cont_msg "" count=$(( count - 1 )) done if [ -f "$PID_FILE" ]; then log_end_msg 1 fi fi log_end_msg 0 ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac exit 0