aboutsummaryrefslogtreecommitdiff
path: root/network/knock/rc.knockd.new
blob: 5198603ffbc763a17581d1900ae18aaf89f33e86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
# Start/stop/restart knockd.

# Start knockd:
knockd_start() {
  CMDLINE="/usr/sbin/knockd -d"
  echo -n "Starting knock daemon:  $CMDLINE "
  $CMDLINE
  echo
}

# Stop knockd:
knockd_stop() {
  echo -n "Stopping knock daemon..."
  kill `cat /var/run/knockd.pid`
  echo
  sleep 1
  rm -f /var/run/knockd.pid
  killall knockd 2> /dev/null
}

# Restart knockd:
knockd_restart() {
  knockd_stop
  sleep 1
  knockd_start
}

case "$1" in
'start')
  knockd_start
  ;;
'stop')
  knockd_stop
  ;;
'restart')
  knockd_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac