Add tools/rahunas-vipmap.in
authorNeutron Soutmun <neo.neutron@gmail.com>
Tue, 11 May 2010 17:52:29 +0000 (00:52 +0700)
committerNeutron Soutmun <neo.neutron@gmail.com>
Tue, 11 May 2010 17:52:29 +0000 (00:52 +0700)
configure.ac
tools/Makefile.am
tools/rahunas-vipmap.in [new file with mode: 0755]

index 5a18b0b..7de0b75 100644 (file)
@@ -61,6 +61,7 @@ AC_CONFIG_FILES([
   tools/Makefile
   tools/rahunas-firewall
   tools/rahunas-bandwidth
+  tools/rahunas-vipmap
   tools/rahunas-weblogin-config-update
   example/Makefile
   example/rahunas.default
index 251929c..b870359 100644 (file)
@@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in
 dist_sbin_SCRIPTS = \
        rahunas-firewall \
        rahunas-bandwidth \
+       rahunas-vipmap \
        rahunas-weblogin-config-update
 
 bin_PROGRAMS = \
diff --git a/tools/rahunas-vipmap.in b/tools/rahunas-vipmap.in
new file mode 100755 (executable)
index 0000000..6ea5425
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:@prefix@/sbin:@prefix@/bin
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+
+IPTABLES=/sbin/iptables
+
+case "$1" in
+  add)
+    $IPTABLES -t nat -I ${2}_nat_vip_post -s ${3} -j SNAT --to-source ${4}
+    if [ $? -eq 0 ]; then
+      echo "Adding VIP map: ${3} => ${4}"
+    fi
+    ;;
+  del)
+    $IPTABLES -t nat -D ${2}_nat_vip_post -s ${3} -j SNAT --to-source ${4}
+    if [ $? -eq 0 ]; then
+      echo "Deleting VIP map: ${3} => ${4}"
+    fi
+    ;;
+  *)
+    N=@sbindir@/rahunas-vipmap
+    echo "Usage: $N {add|del} vserver_name client_ip vipmap_ip"
+    exit 3
+    ;;
+esac 
+
+exit 0