aboutsummaryrefslogtreecommitdiff
path: root/net/misc/tinc/rc.tinc.new
blob: 9dc5104eb216d0ca4a39cf1f42de68b542e48e55 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# thanks to gentoo initscript

tinc_networks() {

  for conf in `ls /etc/tinc`; do
    if [ -e "/etc/tinc/$conf/tinc.conf" ]; then
      echo $conf
    fi
  done

}

tinc_start() {
  echo "Starting tinc VPN networks"
  for TINCNET in `tinc_networks`; do
    echo "Starting tinc network $TINCNET"
    /usr/sbin/tincd --net="$TINCNET" --logfile=/var/log/tinc.$TINCNET.log --pidfile=/var/run/tinc.$TINCNET.pid
  done
}

tinc_stop() {
  echo "Stopping tinc VPN networks"
  for TINCNET in `tinc_networks`; do
    if [ -f /var/run/tinc."$TINCNET".pid ]; then
      echo "Stopping tinc network $TINCNET"
      /usr/sbin/tincd --kill --pidfile=/var/run/tinc."$TINCNET".pid
    fi
  done
}

tinc_reload() {
  echo "Reloading configuration for tinc VPN networks"
  for TINCNET in `tinc_networks`; do
    if [ -f /var/run/tinc."$TINCNET".pid ]; then
      echo "Reloading tinc network $TINCNET"
      /usr/sbin/tincd --kill HUP --pidfile=/var/run/tinc."$TINCNET".pid
    fi
  done
}

case "$1" in
'start')
  tinc_start
  ;;
'stop')
  tinc_stop
  ;;
'restart')
  tinc_stop
  tinc_start
  ;;
'reload')
  tinc_reload
  ;;
*)
  echo "usage $0 start|stop|restart|reload"
esac