openvpn-nomades : postinst
authorThomas NOEL <thomas.noel@auf.org>
Wed, 5 Nov 2008 16:06:57 +0000 (16:06 +0000)
committerThomas NOEL <thomas@thomas-pc.sn.auf>
Wed, 5 Nov 2008 16:06:57 +0000 (16:06 +0000)
auf-serveur-openvpn-nomades/debian/postinst [new file with mode: 0644]
auf-serveur-openvpn-nomades/debian/postinst.ex [deleted file]

diff --git a/auf-serveur-openvpn-nomades/debian/postinst b/auf-serveur-openvpn-nomades/debian/postinst
new file mode 100644 (file)
index 0000000..5e1e554
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/sh
+# postinst script for auf-serveur-openvpn-nomades
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+LOCALCONF=/etc/openvpn/auf-nomades.conf.local
+
+conf_openvpn_local() {
+       # create /etc/openvpn/auf-nomades.conf.local
+       VPNIP=`LANG=C /sbin/ifconfig | sed -n 's/^[[:space:]]*inet addr:\(10\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/p' | head -1`
+       test -z "$VPNIP" && VPNIP="10.255.0.0"
+       VPN16=`echo $VPNIP | cut -d. -f1-2`
+       VPN20=$(($((`echo $VPNIP | cut -d. -f3` / 16))*16))
+       VPNNOMADE=$(($VPN20 + 8))
+       CONF_IFCONFIG="ifconfig $VPN16.$VPNNOMADE.1 $VPN16.$VPNNOMADE.2"
+       CONF_ROUTE="route $VPN16.$VPNNOMADE.0 255.255.248.0"
+       CONF_POOL="ifconfig-pool $VPN16.$(($VPNNOMADE + 4)).1 $VPN16.$(($VPNNOMADE + 7)).255"
+       sed -e 's/^ifconfig[[:space:]].*$/'"$CONF_IFCONFIG"'/' \
+               -e 's/^route[[:space:]].*$/'"$CONF_ROUTE"'/' \
+               -e 's/^ifconfig-pool[[:space:]].*$/'"$CONF_POOL"'/' < /usr/share/doc/auf-serveur-openvpn-nomades/auf-nomades.conf.local.ex > $LOCALCONF
+}
+
+case "$1" in
+    configure)
+       if ! test -f $LOCALCONF
+       then
+               conf_openvpn_local
+               if test -x /etc/init.d/openvpn
+               then
+                       invoke-rc.d openvpn start auf-nomades
+               fi
+       fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
diff --git a/auf-serveur-openvpn-nomades/debian/postinst.ex b/auf-serveur-openvpn-nomades/debian/postinst.ex
deleted file mode 100644 (file)
index ed911f0..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# postinst script for auf-serveur-openvpn-nomades
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <postinst> `configure' <most-recently-configured-version>
-#        * <old-postinst> `abort-upgrade' <new version>
-#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-#          <new-version>
-#        * <postinst> `abort-remove'
-#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-#          <failed-install-package> <version> `removing'
-#          <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-
-case "$1" in
-    configure)
-    ;;
-
-    abort-upgrade|abort-remove|abort-deconfigure)
-    ;;
-
-    *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
-
-