]> git.pld-linux.org Git - packages/vtun.git/blame - vtun.init
- release++,
[packages/vtun.git] / vtun.init
CommitLineData
735a2745 1#!/bin/sh
2#
3# Script for starting and stoping vtund.
4#
5# chkconfig: 345 55 45
6# description: vtund Virtual Tunnel Daemon.
7# VTun provides the method for creating Virtual Tunnels over TCP/IP networks
8# and allows to shape, compress, encrypt traffic in that tunnels.
9
10# Source function library.
11. /etc/rc.d/init.d/functions
12
2f2c96cd 13# Get network config
14. /etc/sysconfig/network
15
16# Check that networking is up.
17if is_no "${NETWORKING}"; then
18 msg_Network_Down Vtund
19 exit 1
20fi
21
c8f10ef0 22# Get service config
23[ -f /etc/sysconfig/vtun ] && . /etc/sysconfig/vtun
24
25err_exit() {
26 echo @$
27 exit 1
28}
29
c10f8c9f 30[ -n "$VTUND_MODE" ] || err_exit "VTUND_MODE not set"
c8f10ef0 31
22ec0a04 32VTUND_OPTS="$VTUND_OPTS -f $VTUND_CONF"
c8f10ef0 33
34if [ $VTUND_MODE = "server" ]; then
35 VTUND_OPTS="$VTUND_OPTS -s"
36
37elif [ $VTUND_MODE = "client" ]; then
c10f8c9f 38 [ -n "$VTUND_SESSION" ] || err_exit "VTUND_SESSION not set"
39 [ -n "$VTUND_SERVER_ADDR" ] || err_exit "VTUND_SERVER_ADDR not set"
40 [ -n "$VTUND_PORT" ] && VTUND_OPTS="$VTUND_OPTS -P $VTUND_PORT"
c8f10ef0 41 VTUND_OPTS="$VTUND_OPTS $VTUND_SESSION $VTUND_SERVER_ADDR"
c8f10ef0 42
43else
44 err_exit "Invalid VTUND_MODE ($VTUND_MODE), should be set to \"server\" or \"client\""
45fi
46
47
735a2745 48# See how we were called.
49case "$1" in
50 start)
2f2c96cd 51 # Check if the service is already running?
52 if [ ! -f /var/lock/subsys/vtund ]; then
53 msg_starting Vtund
c8f10ef0 54 daemon vtund $VTUND_OPTS
2f2c96cd 55 RETVAL=$?
56 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/vtund
57 else
58 msg_Already_Running Vtund
59 exit 1
60 fi
61
735a2745 62 ;;
63 stop)
2f2c96cd 64 # Stop daemons.
65 if [ -f /var/lock/subsys/vtund ]; then
66 msg_stopping Vtund
67 killproc vtund
68 rm -f /var/lock/subsys/vtund >/dev/null 2>&1
69 else
70 msg_Not_Running Vtund
71 exit 1
72 fi
735a2745 73 ;;
74 restart)
75 $0 stop
76 $0 start
77 ;;
78 status)
79 status vtund
2f2c96cd 80 exit $?
735a2745 81 ;;
82 *)
2f2c96cd 83 msg_Usage "$0 {start|stop|restart|status}"
735a2745 84 exit 1
85esac
86
2f2c96cd 87exit $RETVAL
This page took 0.094181 seconds and 4 git commands to generate.