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@} ${TRIPESOCK=@socketdir@/tripesock}
14 : ${pidfile=@pidfile@}
15 : ${tripe=$sbindir/tripe} ${tripectl=$bindir/tripectl}
16 PATH
=/usr
/bin
:/usr
/sbin
:/bin
:/sbin
:$bindir
17 export PATH TRIPEDIR TRIPESOCK
19 # --- Give up if there's no key ---
21 if test ! -f
$TRIPEDIR/keyring ||
test ! -f
$TRIPEDIR/keyring.pub
; then
22 echo >&2 "Not starting/stopping TrIPE: keyring files missing"
26 # --- Check it will work, or at least stands a fighting chance ---
28 # Having loads of different tunnel types doesn't help any.
30 test -x
$tripe -a
-x
$tripectl ||
exit 0
32 case ${tunnel-`$tripe --tunnels | head -1`} in
36 if { test -f
/proc
/misc
&& grep -q tun
/proc
/misc
; } ||
40 echo >&2 "$tripe needs the Linux TUN/TAP driver to run."
43 if test -c
/dev
/net
/tun
; then
46 echo >&2 "$tripe needs /dev/net/tun, which is missing."
51 echo >&2 "CONFIGURATION ERROR"
52 echo >&2 " $tripe is compiled to use a Linux tunnel device, but"
53 echo >&2 " this system is `uname -s`"
61 if { test -f
/proc
/devices
&& grep -q unet
/proc
/devices
; } ||
62 modprobe
-q unet
; then
65 echo >&2 "$tripe needs the Linux UNET driver to run."
68 if test -c
/dev
/unet
; then
71 echo >&2 "$tripe needs /dev/unet, which is missing."
76 echo >&2 "CONFIGURATION ERROR"
77 echo >&2 " $tripe is compiled to use a Linux tunnel device, but"
78 echo >&2 " this system is `uname -s`"
86 # Don't know how to check the device is working.
87 if test -c
/dev
/tun0
; then
90 echo >&2 "$tripe needs /dev/tun0, which is missing."
95 echo >&2 "CONFIGURATION ERROR"
96 echo >&2 " $tripe is compiled to use a BSD tunnel device, but"
97 echo >&2 " this system is `uname -s`"
103 if test "$TRIPE_SLIPIF" = ""; then
104 echo >&2 "$tripe needs SLIP interfaces set up!"
110 # --- Do what was wanted ---
114 echo -n
"Starting TrIPE VPN daemon:"
115 if $tripectl version
>/dev
/null
2>/dev
/null
; then
116 echo " already running"
119 $tripectl -D
-s
-p
$tripe \
120 -f
${logfile-@logfile@} \
122 ${keytag+-S-t}$keytag \
124 ${port+-S-p}${port} \
126 ${group+-G}${group} \
127 ${trace+-S-T}${trace} \
128 ${tunnel+-S-n}${tunnel} \
130 for i
in 1 2 3 4 give-up
; do
131 $tripectl help >/dev
/null
2>/dev
/null
&& break
134 if [ $i = give-up
]; then
135 echo " wouldn't start"
139 sep
=" services [" end
=""
140 [ -d
$TRIPEDIR/services
] && for i
in $TRIPEDIR/services
/*; do
141 [ -x
$i ] ||
continue
143 case $name in *~|\
#*) continue;; esac
144 if $i --daemon
--startup
; then
147 echo -n
"$sep($name failed)"
152 sep
=" peers [" end
=""
153 [ -d
$TRIPEDIR/peers
] && for i
in $TRIPEDIR/peers
/*; do
154 [ -x
$i ] ||
continue
156 case $name in *~|\
#*) continue;; esac
160 echo -n
"$sep($name failed)"
167 echo -n
"Stopping TrIPE VPN daemon:"
168 if test ! -S
$TRIPESOCK; then
170 elif $tripectl quit
>/dev
/null
2>&1; then
172 elif test ! -f
$pidfile; then
173 echo " stale socket found: removing"
175 elif kill `cat $pidfile`; then
176 echo " done (killed violently)"
178 echo " it doesn't want to die!"
183 for i
in `$tripectl list`; do
185 $tripectl stats
$i |
sed 's/^/ /'
190 echo "Keyrings reloaded OK."
192 restart | force-reload
)
197 echo >&2 "usage: $0 start|stop|restart|status|reload|force-reload"