Update ChaosVPN
authorJens Muecke <jens@nons.de>
Sun, 29 Aug 2010 12:38:00 +0000 (12:38 +0000)
committerJens Muecke <jens@nons.de>
Sun, 29 Aug 2010 12:38:00 +0000 (12:38 +0000)
done by Haegar
add init script
update to version 2.0

SVN-Revision: 22831

net/chaosvpn/Makefile
net/chaosvpn/files/chaosvpn.hotplug [new file with mode: 0644]
net/chaosvpn/files/chaosvpn.init [new file with mode: 0644]
net/chaosvpn/files/chaosvpn_config.sh [new file with mode: 0644]

index 77cee1c..d9bef86 100644 (file)
@@ -1,27 +1,20 @@
-# 
-# Copyright (C) 2006-2008 OpenWrt.org
+# Copyright (C) 2010 OpenWrt.org
+# All rights reserved.
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
-#
-# $Id: Makefile 12693 2008-09-25 10:47:39Z nico $
 
 include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=chaosvpn
-PKG_VERSION:=2.0-rc11
-PKG_MD5SUM:=8c5c9ee78151d521492ceeb41a812456
-PKG_REV:=2.0-rc11
-PKG_RELEASE:=1
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
-PKG_SOURCE_URL:=git://github.com/ryd/chaosvpn.git
-PKG_SOURCE_PROTO:=git
-PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_VERSION:=2.0
+PKG_RELEASE:=2
 
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_BUILD_DIR:=$(BUILD_DIR)/${PKG_NAME}-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+PKG_SOURCE:=${PKG_NAME}-${PKG_VERSION}.tar.gz
+PKG_SOURCE_URL:=http://github.com/downloads/ryd/chaosvpn/
+PKG_MD5SUM:=4263202d65bf4ab0d1356b149d7c53af
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -29,27 +22,33 @@ define Package/chaosvpn
   SECTION:=net
   CATEGORY:=Network
   TITLE:=Config generator for chaos vpn
+  DEPENDS:=+ip +tinc +kmod-tun +libopenssl
+  URL:=https://wiki.hamburg.ccc.de/index.php/ChaosVPN::DebianHowto
   MAINTAINER:=Christopher J. Pilkington <cjp@0x1.net>
-  URL:=http://github.com/ryd/chaosvpn
-  DEPENDS:=+tinc +kmod-tun +ip +libopenssl
 endef
 
 define Package/chaosvpn/description
-  Configure tincd for the chaosvpn network
+       Configure tincd for the chaosvpn network
 endef
 
 define Build/Compile
-  $(MAKE) -C $(PKG_BUILD_DIR) \
-    CC="$(TARGET_CC)" \
-    COPT="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/lib" \
-    LIB="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib -Wl,-rpath-link,$(STAGING_DIR)/usr/lib"
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               CC="$(TARGET_CC)" \
+               CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/lib" \
+               LIB="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib -lz -lcrypto -Wl,-rpath-link,$(STAGING_DIR)/usr/lib" \
+               INCLUDES="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
+               LIBDIRS="-L$(STAGING_DIR)/usr/lib"
 endef
 
 define Package/chaosvpn/install
-       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_DIR) $(1)/etc/tinc/chaos/ $(1)/usr/sbin/ $(1)/etc/init.d/ $(1)/etc/hotplug.d/iface/
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/chaosvpn $(1)/usr/sbin/
-       $(INSTALL_DIR) $(1)/etc/tinc
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/chaosvpn.conf $(1)/etc/tinc/chaosvpn.conf.sample
+       #$(INSTALL_DATA) $(PKG_BUILD_DIR)/chaosvpn.conf $(1)/etc/tinc/
+       sed -e 's/"\/sbin\/ip /"\/usr\/sbin\/ip /' <$(PKG_BUILD_DIR)/chaosvpn.conf >$(1)/etc/tinc/chaosvpn.conf
+       $(INSTALL_BIN) ./files/chaosvpn_config.sh $(1)/usr/sbin/
+       $(INSTALL_BIN) ./files/chaosvpn.init $(1)/etc/init.d/chaosvpn
+       $(INSTALL_BIN) ./files/chaosvpn.hotplug $(1)/etc/hotplug.d/iface/40-chaosvpn
 endef
 
 $(eval $(call BuildPackage,chaosvpn))
+
diff --git a/net/chaosvpn/files/chaosvpn.hotplug b/net/chaosvpn/files/chaosvpn.hotplug
new file mode 100644 (file)
index 0000000..3044e53
--- /dev/null
@@ -0,0 +1,3 @@
+[ "$INTERFACE" == "wan" ] || return
+[ "$ACTION" == "ifup" ] && /etc/init.d/chaosvpn restart
+
diff --git a/net/chaosvpn/files/chaosvpn.init b/net/chaosvpn/files/chaosvpn.init
new file mode 100644 (file)
index 0000000..0862638
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh /etc/rc.common
+START=99
+
+start()
+{
+       /usr/sbin/chaosvpn_config.sh
+       [ $? = 0 ] || {
+               logger "not starting chaosvpn, check your config"
+               exit 1
+       }
+       /usr/sbin/chaosvpn -f -c /etc/tinc/chaosvpn.conf >/dev/null 2>&1 &
+}
+
+stop()
+{
+       killall chaosvpn
+}
diff --git a/net/chaosvpn/files/chaosvpn_config.sh b/net/chaosvpn/files/chaosvpn_config.sh
new file mode 100644 (file)
index 0000000..6b3b273
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+[ -f "/etc/tinc/chaos/rsa_key.pub" -a -f "/etc/tinc/chaos/rsa_key.priv" ] || {
+       echo "please generate rsa key pair"
+       echo "tincd -n chaos --generate-keys=2048"
+       exit 1
+}
+
+C=`grep unconfigured_please_change_me /etc/tinc/chaosvpn.conf  | wc -l`
+[ "$C" = "0" ] || {
+       echo "/etc/tinc/chaosvpn.conf is not configured yet"
+       exit 1
+}
+exit 0