4 # suitable for direct use in most SysV-style inits
10 [ -f @initconfig@ ] && . @initconfig@
11 : ${prefix=@prefix@} ${exec_prefix=@exec_prefix@}
12 : ${bindir=@bindir@} ${sbindir=@sbindir@}
13 : ${TRIPEDIR=@configdir@}
14 : ${tripe=$sbindir/tripe} ${tripectl=$bindir/tripectl}
15 PATH=/usr/bin:/usr/sbin:/bin:/sbin:$bindir
18 # --- Check it will work, or at least stands a fighting chance ---
20 # Having loads of different tunnel types doesn't help any.
22 test -x $tripe -a -x $tripectl || exit 0
24 case `$tripe --tunnel` in
28 if { test -f /proc/misc && grep -q net/tun /proc/misc; } ||
32 echo >&2 "$tripe needs the Linux TUN/TAP driver to run."
35 if test -c /dev/net/tun; then
38 echo >&2 "$tripe needs /dev/net/tun, which is missing."
43 echo >&2 "CONFIGURATION ERROR"
44 echo >&2 " $tripe is compiled to use a Linux tunnel device, but"
45 echo >&2 " this system is `uname -s`"
53 if { test -f /proc/devices && grep -q unet /proc/devices; } ||
54 modprobe -q unet; then
57 echo >&2 "$tripe needs the Linux UNET driver to run."
60 if test -c /dev/unet; then
63 echo >&2 "$tripe needs /dev/unet, which is missing."
68 echo >&2 "CONFIGURATION ERROR"
69 echo >&2 " $tripe is compiled to use a Linux tunnel device, but"
70 echo >&2 " this system is `uname -s`"
78 # Don't know how to check the device is working.
79 if test -c /dev/tun0; then
82 echo >&2 "$tripe needs /dev/tun0, which is missing."
87 echo >&2 "CONFIGURATION ERROR"
88 echo >&2 " $tripe is compiled to use a BSD tunnel device, but"
89 echo >&2 " this system is `uname -s`"
96 # --- Do what was wanted ---
100 echo -n "Starting TrIPE VPN daemon:"
101 if $tripectl help >/dev/null 2>/dev/null; then
102 echo " already running"
105 $tripectl -D -s -p$tripe \
106 -f${logfile-@logfile@} \
107 -P${pidfile-@pidfile@} \
109 ${port+-S-p}${port} \
110 ${user+-S-u}${user} \
111 ${group+-S-g}${group} \
112 ${trace+-S-T}${trace} \
114 for i in 1 2 3 4 give-up; do
115 $tripectl help >/dev/null 2>/dev/null && break
118 if [ $i = give-up ]; then
119 echo " wouldn't start"
123 for i in $TRIPEDIR/peers/*; do
124 [ -x $i ] || continue
126 case $name in *~|\#*) continue;; esac
130 echo -n " ($name failed)"
136 echo -n "Stopping TrIPE VPN daemon:"
141 for i in `$tripectl list`; do
143 $tripectl stats $i | sed 's/^/ /'
146 restart | force-reload)
151 echo >&2 "usage: $0 start|stop|restart|status|force-reload"