--- /dev/null
+#!/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
+
+
+++ /dev/null
-#!/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
-
-