Use dhclient hooks instead of proprietary pump hooks for dhcphostname
authorUlrich Dangel <mru@grml.org>
Mon, 6 Dec 2010 22:58:36 +0000 (23:58 +0100)
committerUlrich Dangel <mru@grml.org>
Tue, 7 Dec 2010 00:23:26 +0000 (01:23 +0100)
debian/rules
etc/dhcp/dhclient-exit-hooks.d/grml-sethostname [new symlink]
etc/dhcp3/dhclient-exit-hooks.d/grml-sethostname [new file with mode: 0755]
etc/grml/pump-scripts.d/set-hostname [deleted file]
lib/pump-runparts [deleted file]

index f8d767d..687f607 100755 (executable)
@@ -30,7 +30,7 @@ install: build
        dh_testdir
        dh_testroot
        dh_clean -k
-       dh_installdirs etc/grml etc/init.d usr/sbin usr/bin usr/share/doc/grml-saveconfig usr/lib/grml-autoconfig
+       dh_installdirs etc/grml etc/dhcp{3,}/dhclient-exit-hooks.d etc/init.d usr/sbin usr/bin usr/share/doc/grml-saveconfig
 
        # Add here commands to install the package into debian/grml-autoconfig.
        install -m 755 grml-autoconfig      debian/grml-autoconfig/etc/init.d/grml-autoconfig
@@ -43,7 +43,6 @@ install: build
 
        install -m 755 bin/restore-config debian/grml-autoconfig/usr/bin/restore-config
        install -m 755 bin/save-config debian/grml-autoconfig/usr/bin/save-config
-       install -m 755 lib/pump-runparts debian/grml-autoconfig/usr/lib/grml-autoconfig/pump-runparts
 
        # just as a "backup" solution:
        cp -a etc/* debian/grml-autoconfig/etc/
diff --git a/etc/dhcp/dhclient-exit-hooks.d/grml-sethostname b/etc/dhcp/dhclient-exit-hooks.d/grml-sethostname
new file mode 120000 (symlink)
index 0000000..36cd991
--- /dev/null
@@ -0,0 +1 @@
+../../dhcp3/dhclient-exit-hooks.d/grml-sethostname
\ No newline at end of file
diff --git a/etc/dhcp3/dhclient-exit-hooks.d/grml-sethostname b/etc/dhcp3/dhclient-exit-hooks.d/grml-sethostname
new file mode 100755 (executable)
index 0000000..acd03a2
--- /dev/null
@@ -0,0 +1,12 @@
+# only run the comamnd if we bound to a new ip
+case "$reason" in BOUND)
+if ! grep -q 'nodhcphostname' /proc/cmdline && [ -f /etc/grml_cd ] ; then
+
+    hostname=$(busybox nslookup "$new_ip_address" | awk '/Address 1: '$new_ip_address'/ {print $4}')
+    if [ -n "$hostname" ] ; then
+        grml-hostname "$hostname"
+        hostname -F /etc/hostname
+    fi
+fi
+;;
+esac
diff --git a/etc/grml/pump-scripts.d/set-hostname b/etc/grml/pump-scripts.d/set-hostname
deleted file mode 100755 (executable)
index 6682d3e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/zsh -e
-# PUMP Script
-# $1 Calling circumstance (up, renewal, down)
-# $2 interface
-# $3 ip
-
-# Exit early, if we're not being called for the initial lease
-[ "$1" != "up" ] && exit 0
-
-. /etc/grml/autoconfig.functions
-
-# only run if no nodhcphostname parameter is given
-# and if running in live mode
-if ! checkbootparam 'nodhcphostname' && [ -f /etc/grml_cd ] ; then
-
-    hostname=$(busybox nslookup "$3" | awk '/Address 1: '$3'/ {print $4}')
-    [ -n "$hostname" ] || exit 1
-
-    grml-hostname "$hostname"
-    hostname -F /etc/hostname
-fi
diff --git a/lib/pump-runparts b/lib/pump-runparts
deleted file mode 100644 (file)
index 3985964..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh -e
-
-arguments=""
-
-for ARG in $* ; do
-    arguments="${arguments} -a ${ARG} "
-done
-
-run-parts $arguments /etc/grml/pump-scripts.d/