summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-06-05 08:19:53 +0000
committerEric Andersen <andersen@codepoet.org>2003-06-05 08:19:53 +0000
commit19109125e8ad1752e79fd7292eb2d6870223ded1 (patch)
tree39094db33ac1d883c6e06695f239a23ee84ec698
parentbc9fb854fe2e138246fcaf7e07e098ae2374579e (diff)
support vtun
-rw-r--r--make/vtun.mk65
-rw-r--r--sources/vtun.patch181
2 files changed, 246 insertions, 0 deletions
diff --git a/make/vtun.mk b/make/vtun.mk
new file mode 100644
index 000000000..ff6097b73
--- /dev/null
+++ b/make/vtun.mk
@@ -0,0 +1,65 @@
+#############################################################
+#
+# vtun
+#
+# NOTE: Uses start-stop-daemon in init script, so be sure
+# to enable that within busybox
+#
+#############################################################
+VTUN_SOURCE:=vtun-2.6.tar.gz
+VTUN_SITE:=http://unc.dl.sourceforge.net/sourceforge/vtun/
+VTUN_DIR:=$(BUILD_DIR)/vtun-2.6
+VTUN_CAT:=zcat
+VTUN_BINARY:=vtun
+VTUN_TARGET_BINARY:=usr/bin/vtun
+VTUN_PATCH:=$(SOURCE_DIR)/vtun.patch
+
+$(DL_DIR)/$(VTUN_SOURCE):
+ $(WGET) -P $(DL_DIR) $(VTUN_SITE)/$(VTUN_SOURCE)
+
+vtun-source: $(DL_DIR)/$(VTUN_SOURCE)
+
+$(VTUN_DIR)/.unpacked: $(DL_DIR)/$(VTUN_SOURCE)
+ $(VTUN_CAT) $(DL_DIR)/$(VTUN_SOURCE) | tar -C $(BUILD_DIR) -xvf -
+ mv $(BUILD_DIR)/vtun $(VTUN_DIR)
+ cat $(VTUN_PATCH) | patch -p1 -d $(VTUN_DIR)
+ touch $(VTUN_DIR)/.unpacked
+
+$(VTUN_DIR)/.configured: $(VTUN_DIR)/.unpacked
+ (cd $(VTUN_DIR); rm -rf config.cache; \
+ $(TARGET_CONFIGURE_OPTS) \
+ ./configure \
+ --target=$(GNU_TARGET_NAME) \
+ --host=$(GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --bindir=/usr/bin \
+ --sbindir=/usr/sbin \
+ --libexecdir=/usr/lib \
+ --sysconfdir=/etc \
+ --datadir=/usr/share \
+ --localstatedir=/var \
+ --mandir=/usr/man \
+ --infodir=/usr/info \
+ --disable-lzo \
+ );
+ touch $(VTUN_DIR)/.configured
+
+$(VTUN_DIR)/$(VTUN_BINARY): $(VTUN_DIR)/.configured
+ $(MAKE) -C $(VTUN_DIR)
+
+$(TARGET_DIR)/$(VTUN_TARGET_BINARY): $(VTUN_DIR)/$(VTUN_BINARY)
+ $(MAKE) DESTDIR=$(TARGET_DIR) -C $(VTUN_DIR) install
+ rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
+ $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
+
+vtun: uclibc $(TARGET_DIR)/$(VTUN_TARGET_BINARY)
+
+vtun-clean:
+ $(MAKE) DESTDIR=$(TARGET_DIR) -C $(VTUN_DIR) uninstall
+ -$(MAKE) -C $(VTUN_DIR) clean
+
+vtun-dirclean:
+ rm -rf $(VTUN_DIR)
+
diff --git a/sources/vtun.patch b/sources/vtun.patch
new file mode 100644
index 000000000..f5946562e
--- /dev/null
+++ b/sources/vtun.patch
@@ -0,0 +1,181 @@
+diff -urN vtun.orig/Makefile.in vtun-2.6/Makefile.in
+--- vtun.orig/Makefile.in 2002-12-20 09:55:47.000000000 -0700
++++ vtun-2.6/Makefile.in 2003-06-05 01:51:50.000000000 -0600
+@@ -28,7 +28,7 @@
+ LEXFLAGS = -t
+
+ INSTALL = @INSTALL@
+-INSTALL_OWNER = -o root -g 0
++INSTALL_OWNER =
+
+ prefix = @prefix@
+ exec_prefix = @exec_prefix@
+@@ -86,12 +86,10 @@
+
+ install_config:
+ $(INSTALL) -d -m 755 $(INSTALL_OWNER) $(DESTDIR)$(ETC_DIR)
+- if [ ! -f $(ETC_DIR)/vtund.conf ]; then \
+- $(INSTALL) -m 600 $(INSTALL_OWNER) vtund.conf $(DESTDIR)$(ETC_DIR); \
+- fi
++ $(INSTALL) -m 600 $(INSTALL_OWNER) vtund.conf $(DESTDIR)$(ETC_DIR);
++ $(INSTALL) -m 600 $(INSTALL_OWNER) scripts/vtund-start.conf $(DESTDIR)$(ETC_DIR);
+
+ install: vtund install_config install_man
+- $(INSTALL) -d -m 755 $(INSTALL_OWNER) $(DESTDIR)$(VAR_DIR)/run
+ $(INSTALL) -d -m 755 $(INSTALL_OWNER) $(DESTDIR)$(STAT_DIR)
+ $(INSTALL) -d -m 755 $(INSTALL_OWNER) $(DESTDIR)$(LOCK_DIR)
+ $(INSTALL) -d -m 755 $(INSTALL_OWNER) $(DESTDIR)$(SBIN_DIR)
+diff -urN vtun.orig/scripts/vtund.rc.debian vtun-2.6/scripts/vtund.rc.debian
+--- vtun.orig/scripts/vtund.rc.debian 2000-03-26 10:06:37.000000000 -0700
++++ vtun-2.6/scripts/vtund.rc.debian 2003-06-05 01:52:54.000000000 -0600
+@@ -1,92 +1,59 @@
+-#! /usr/bin/perl -w
++#! /bin/sh
++#
+
+-### 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 <cas@taz.net.au>
+-###
+-### Written for the Debian GNU/Linux distribution. This script is free
+-### software licensed under the terms of the GNU General Public License.
+-
+-$DAEMON="/usr/sbin/vtund" ;
+-
+-$do_what = shift ;
+-$args="start|stop|reload|force-reload|restart" ;
+-if ( $do_what !~ /^($args)$/i ) {
+- print "Usage: /etc/init.d/vtun {$args}\n" ;
+- exit 0 ;
+-}
+-
+-$SSD="/sbin/start-stop-daemon" ;
+-$SSDARGS="--verbose --exec $DAEMON" ;
+-
+-$sconf="/etc/vtund-start.conf" ;
+-open(SCONF,"<$sconf") || die "couldn't open $sconf: $!\n" ;
+-while (<SCONF>) {
+- chomp ;
+- s/#.*//;
+- s/^ +| +$//;
+- next if (/^$/) ;
+-
+- @line = split ;
+- $host = shift(@line) ;
+- $server = shift(@line) ;
+- $args = "" ;
+- foreach (@line) { $args .= " $_" } ;
+-
+- $host='' if ($host =~ /--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 =~ /^(reload|force-reload)$/ ) {
+- &reload($host,$server) ;
+- }
+-}
+-close (SCONF);
+-
+-
+-sub start {
+- my($host,$server,$args) = @_ ;
+- 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="/var/run/vtun.$host.$server" ;
+- system "$SSD --start $SSDARGS --pidfile $pidfile -- $args $host $server" ;
+- }
+-} ;
+-
+-sub stop {
+- my($host,$server,$args) = @_ ;
+- print " Stopping vtun " ;
+- if ($host eq '') {
+- print "server\n" ;
+- system "$SSD --stop $SSDARGS" ;
+- } else {
+- print "client $host to $server\n" ;
+- $pidfile="/var/run/vtun.$host.$server" ;
+- system "$SSD --stop $SSDARGS --pidfile $pidfile" ;
+- }
+-} ;
+-
+-sub reload {
+- my($host,$server) = @_ ;
+- print " Reloading vtun " ;
+- if ($host eq '') {
+- print "server\n" ;
+- system "$SSD --stop $SSDARGS --signal 1" ;
+- } else {
+- print "client $host to $server\n" ;
+- $pidfile="/var/run/vtun.$host.$server" ;
+- system "$SSD --stop $SSDARGS --signal 1 --pidfile $pidfile" ;
+- }
+-}
++PATH=/bin:/usr/bin:/sbin:/usr/sbin
++DAEMON=/usr/sbin/vtund
++CONFFILE=/etc/vtund-start.conf
++PIDPREFIX=/var/run/vtund
++
++test -f $DAEMON || exit 0
++
++case "$1" in
++ start)
++ # find all the defined tunnels
++ egrep -v '^[:space:]*(#.*)?$' $CONFFILE | while true;
++ do
++ read i
++ # no more lines available? done, then.
++ if [ $? != 0 ] ; then break; fi
++ SARGS=`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 $PIDPREFIX.pid -- $SARGS;
++ else
++ # split args into host and rest
++ HOST=`echo $i|cut -f 1 -d " "`;
++ TARGET=`echo $i|cut -f 2 -d " "`;
++ echo "Starting vtund client $HOST to $TARGET.";
++ start-stop-daemon --start --exec $DAEMON --pidfile $PIDPREFIX.$HOST.pid -- $i;
++
++ fi
++ done
++ ;;
++ stop)
++ echo "Stopping vtund.";
++ for i in $PIDPREFIX*;
++ do
++ start-stop-daemon --stop --pidfile $i;
++ rm -f $i;
++ done
++ ;;
++ reload|force-reload)
++ echo "Reloading vtund.";
++ for i in $PIDPREFIX*;
++ do
++ start-stop-daemon --stop --signal 1 --pidfile $i;
++ done
++ ;;
++ restart)
++ $0 stop
++ sleep 1;
++ $0 start
++ ;;
++ *)
++ echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
++ exit 1
++ ;;
++esac
++exit 0