summaryrefslogtreecommitdiff
path: root/core/openvpn/openvpn-tapdev.rc
blob: 2c51f8248d590f12968a8c635aa1e7414be152b7 (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
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

. /etc/conf.d/openvpn-tapdev

case "$1" in
  start)
    stat_busy "Creating tap devices for OpenVPN ... "
    success=0
    for tapdev in ${TAPDEVS}; do
      stat_append "${tapdev} "
      /usr/sbin/openvpn --mktun --dev-type tap --dev ${tapdev} >/dev/null 2>&1 || success=$?
    done
    if [ $success -eq 0 ]; then
      add_daemon openvpn-tapdev
      stat_done
    else
      stat_fail
    fi
    ;;
  stop)
    stat_busy "Destroying tap devices for OpenVPN ..."
    for tapdev in ${TAPDEVS}; do
      stat_append "${tapdev} "
      /usr/sbin/openvpn --rmtun --dev-type tap --dev ${tapdev} >/dev/null 2>&1 || success=$?
    done
    rm_daemon openvpn-tapdev
    stat_done
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac
exit 0