summaryrefslogtreecommitdiff
path: root/openwrt
diff options
context:
space:
mode:
Diffstat (limited to 'openwrt')
-rw-r--r--openwrt/kamikaze/uanytun-nocrypt/Makefile2
-rw-r--r--openwrt/kamikaze/uanytun/Makefile7
-rw-r--r--openwrt/kamikaze/uanytun/files/uanytun.config1
-rwxr-xr-xopenwrt/kamikaze/uanytun/files/uanytun.init66
4 files changed, 56 insertions, 20 deletions
diff --git a/openwrt/kamikaze/uanytun-nocrypt/Makefile b/openwrt/kamikaze/uanytun-nocrypt/Makefile
index 05c8ebb..b0ff2bc 100644
--- a/openwrt/kamikaze/uanytun-nocrypt/Makefile
+++ b/openwrt/kamikaze/uanytun-nocrypt/Makefile
@@ -18,7 +18,7 @@ PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.anytun.org/~equinox/
-PKG_MD5SUM:=4ada32936048fce0e615f550e7b12a85
+PKG_MD5SUM:=97854b33081f7685ff174db4c7083d8e
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
diff --git a/openwrt/kamikaze/uanytun/Makefile b/openwrt/kamikaze/uanytun/Makefile
index 583ead0..784fc94 100644
--- a/openwrt/kamikaze/uanytun/Makefile
+++ b/openwrt/kamikaze/uanytun/Makefile
@@ -18,7 +18,7 @@ PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.anytun.org/~equinox/
-PKG_MD5SUM:=4ada32936048fce0e615f550e7b12a85
+PKG_MD5SUM:=97854b33081f7685ff174db4c7083d8e
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
@@ -53,8 +53,13 @@ define Build/Compile
endef
define Package/uanytun/install
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/uanytun.config $(1)/etc/config/uanytun
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/uanytun $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/uanytun.init $(1)/etc/init.d/uanytun
+
endef
$(eval $(call BuildPackage,uanytun))
diff --git a/openwrt/kamikaze/uanytun/files/uanytun.config b/openwrt/kamikaze/uanytun/files/uanytun.config
index e71bb9d..9cfe579 100644
--- a/openwrt/kamikaze/uanytun/files/uanytun.config
+++ b/openwrt/kamikaze/uanytun/files/uanytun.config
@@ -19,6 +19,7 @@ config "client1"
# option dev 'anytun0'
option type 'tun'
option ifconfig '192.168.123.1/24'
+# option post-up-script '/etc/uanytun/client1-post-up.sh'
option remote_host 'example.com'
option remote_port '4444'
diff --git a/openwrt/kamikaze/uanytun/files/uanytun.init b/openwrt/kamikaze/uanytun/files/uanytun.init
index 27296ca..9c1a928 100755
--- a/openwrt/kamikaze/uanytun/files/uanytun.init
+++ b/openwrt/kamikaze/uanytun/files/uanytun.init
@@ -2,15 +2,10 @@
START=50
BIN=uanytun
+DAEMON=/usr/sbin/$BIN
DESC=uanytun
RUN_D=/var/run
-uanytun() {
- local name
- name=${2%%.pid}
- name=${name##/var/run/uanytun.}
- echo "$name" > $2
-}
option_cb() {
local varname="$1"
@@ -21,19 +16,28 @@ option_cb() {
fi
}
+foreach_config_forced() {
+ foreach_config $1 "forced"
+}
+
foreach_config() {
local cfg="$1"
local name
local option
local value
- local DAEMONARGS=""
+ local args=""
+ local forced=0
+
+ if [ -n "$2" ] && [ "x$2" == "xforced" ]; then
+ forced=1
+ fi
config_get name "$cfg" TYPE
for option in $CONFIG_OPTIONS
do
config_get value "$cfg" "$option"
if [ "x$option" == "xdisabled" ]; then
- if [ $value -eq 1 ]; then
+ if [ $forced -eq 0 ] && [ $value -eq 1 ]; then
echo -n " $name(disabled)"
return
fi
@@ -42,19 +46,40 @@ foreach_config() {
option=`echo $option | tr '_' '-'`
if [ -n "$value" ]; then
- DAEMONARGS="$DAEMONARGS --$option $value"
+ args="$args --$option $value"
fi
done
echo -n " $name"
local status="OK"
- $BIN --write-pid "$RUN_D/$BIN.$name.pid" $DAEMONARGS || status="failed"
+ $DAEMON --write-pid "$RUN_D/$BIN.$name.pid" $args || status="failed"
+ echo -n "($status)"
+}
+
+stop_vpn() {
+ local name=$1
+ local pidfile=$RUN_D/$BIN.$name.pid
+ echo -n " $name"
+ local status="OK"
+ if [ ! -f "$pidfile" ]; then
+ status="tunnel not active"
+ else
+ kill `cat $pidfile` > /dev/null 2>&1 || status="failed"
+ rm -f $pidfile
+ fi
echo -n "($status)"
}
start() {
echo -n "Starting $DESC:"
config_load uanytun
- config_foreach foreach_config ""
+ if [ $# -gt 0 ]; then
+ while [ $# -gt 0 ]; do
+ config_foreach foreach_config_forced "$1"
+ shift
+ done
+ else
+ config_foreach foreach_config ""
+ fi
echo "."
}
@@ -63,12 +88,17 @@ stop() {
local name
local pidfile
- for pidfile in `ls $RUN_D/$BIN.*.pid 2> /dev/null`; do
- name=${pidfile%%.pid}
- name=${name##$RUN_D/$BIN.}
- echo -n " $name"
- kill `cat $pidfile` || true
- rm -f $pidfile
- done
+ if [ $# -gt 0 ]; then
+ while [ $# -gt 0 ]; do
+ stop_vpn $1
+ shift
+ done
+ else
+ for pidfile in `ls $RUN_D/$BIN.*.pid 2> /dev/null`; do
+ name=${pidfile%%.pid}
+ name=${name##$RUN_D/$BIN.}
+ stop_vpn $name
+ done
+ fi
echo "."
}