[Vtun-Commit] CVS: The file 'vtun/scripts/vtund.rc.debian' has been modified.
Status: Inactive
Brought to you by:
mtbishop
From: Bishop <mtb...@us...> - 2007-03-31 23:04:15
|
The following file was modified in vtun/scripts: Name Old version New version Comment ---- ----------- ----------- ------- vtund.rc.debian 1.1.1.1 1.1.1.1.2.1=20=20=20=20=20 The accompanying log: rfe780607 - new debian scripts. The diff of the modified file(s): --- vtund.rc.debian 26 Mar 2000 17:06:37 -0000 1.1.1.1 +++ vtund.rc.debian 31 Mar 2007 23:04:14 -0000 1.1.1.1.2.1 @@ -1,92 +1,61 @@ -#! /usr/bin/perl -w - -### vtund-start -### -### script to start vtund as either a server or a client, according to -### the config file /etc/vtund-start.conf -### -### Copyright 1999 Craig Sanders <ca...@ta...> -### -### Written for the Debian GNU/Linux distribution. This script is free -### software licensed under the terms of the GNU General Public License. - -$DAEMON=3D"/usr/sbin/vtund" ; - -$do_what =3D shift ; -$args=3D"start|stop|reload|force-reload|restart" ; -if ( $do_what !~ /^($args)$/i ) { - print "Usage: /etc/init.d/vtun {$args}\n" ; - exit 0 ; -} - -$SSD=3D"/sbin/start-stop-daemon" ; -$SSDARGS=3D"--verbose --exec $DAEMON" ; - -$sconf=3D"/etc/vtund-start.conf" ; -open(SCONF,"<$sconf") || die "couldn't open $sconf: $!\n" ; -while (<SCONF>) { - chomp ; - s/#.*//; - s/^ +| +$//; - next if (/^$/) ; - - @line =3D split ; - $host =3D shift(@line) ; - $server =3D shift(@line) ; - $args =3D "" ; - foreach (@line) { $args .=3D " $_" } ; - - $host=3D'' if ($host =3D~ /--server--/i ) ; - - if ( $do_what eq 'start' ) { - &start($host,$server,$args) ; - } elsif ( $do_what eq 'stop' ) { - &stop($host,$server,$args) ; - } elsif ( $do_what eq 'restart' ) { - &stop($pidfile) ; - &start($host,$server,$args) ; - } elsif ( $do_what =3D~ /^(reload|force-reload)$/ ) { - &reload($host,$server) ; - } -} -close (SCONF); +#! /bin/sh +# +# submitted by Morgon Kanter +#=20 =20 +PATH=3D/bin:/usr/bin:/sbin:/usr/sbin +DAEMON=3D/usr/sbin/vtund +CONFFILE=3D/etc/vtund-start.conf +PIDPREFIX=3D/var/run/vtund =20 -sub start { - my($host,$server,$args) =3D @_ ; - print " Starting vtun " ; - if ($host eq '') { - print "server\n" ; - system "$SSD --start $SSDARGS -- $args -s -P $server" ; - } else { - print "client $host to $server\n" ; - $pidfile=3D"/var/run/vtun.$host.$server" ; - system "$SSD --start $SSDARGS --pidfile $pidfile -- $args $host $s= erver" ; - } -} ; +test -f $DAEMON || exit 0 =20 -sub stop { - my($host,$server,$args) =3D @_ ; - print " Stopping vtun " ; - if ($host eq '') { - print "server\n" ; - system "$SSD --stop $SSDARGS" ; - } else { - print "client $host to $server\n" ; - $pidfile=3D"/var/run/vtun.$host.$server" ; - system "$SSD --stop $SSDARGS --pidfile $pidfile" ; - } -} ; +case "$1" in=20 + start) + # find all the defined tunnels + egrep -v '^[:space:]*(#.*)?$' $CONFFILE | while true; + do + read i + # no more lines available? done, then. + if [ $? !=3D 0 ] ; then break; fi + SARGS=3D`echo $i|sed -ne 's/--server--\s*/-s -P /p'`; + if [ -n "$SARGS" ]; + then + echo "Starting vtund server." + start-stop-daemon --start --exec $DAEMON --pidfile $PIDP= REFIX.pid -- $SARGS; + else + # split args into host and rest + HOST=3D`echo $i|cut -f 1 -d " "`; + TARGET=3D`echo $i|cut -f 2 -d " "`; + echo "Starting vtund client $HOST to $TARGET."; + start-stop-daemon --start --exec $DAEMON --pidfile $PIDP= REFIX.$HOST.pid -- $i; =20 -sub reload { - my($host,$server) =3D @_ ; - print " Reloading vtun " ; - if ($host eq '') { - print "server\n" ; - system "$SSD --stop $SSDARGS --signal 1" ; - } else { - print "client $host to $server\n" ; - $pidfile=3D"/var/run/vtun.$host.$server" ; - system "$SSD --stop $SSDARGS --signal 1 --pidfile $pidfile" ; - } -} + fi + done + ;; + stop)=20 + echo "Stopping vtund."; + for i in $PIDPREFIX*; + do + start-stop-daemon --stop --pidfile $i;=20 + rm -f $i; + done + ;; + reload|force-reload) + echo "Reloading vtund."; + for i in $PIDPREFIX*; + do + start-stop-daemon --stop --signal 1 --pidfile $i;=20 + done + ;; + restart)=20 + $0 stop + sleep 1; + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2 + exit 1 + ;; +esac +exit 0 |