Reworked and grmlfied patch from Andreas Thienemann
authorUlrich Dangel <uli@spamt.net>
Wed, 14 Oct 2009 12:51:03 +0000 (14:51 +0200)
committerMichael Prokop <mika@grml.org>
Sat, 17 Oct 2009 11:12:28 +0000 (13:12 +0200)
introduced etc/grml/pump-scripts.d, added wrapper script
usr/lib/grml-autoconfig/pump-runparts, modified set-hostname to use
checkbootparam and run it per default

autoconfig.functions
debian/rules
etc/grml/pump-script [deleted file]
etc/grml/pump-scripts.d/set-hostname [new file with mode: 0755]
lib/pump-runparts [new file with mode: 0644]

index 5417220..cd9baca 100755 (executable)
@@ -1274,7 +1274,7 @@ else
     einfo "Network device ${WHITE}${DEVICE}${NORMAL} detected, DHCP broadcasting for IP. (Backgrounding)"
     trap 2 3 11
     ifconfig $DEVICE up >>$DEBUG 2>&1
-    ( pump -i $DEVICE --script=/etc/grml/pump-script >>$DEBUG 2>&1 && echo finished_running_pump > /etc/network/status/$DEVICE ) &
+    ( pump -i $DEVICE --script=/usr/lib/grml-autoconfig/pump-runparts >>$DEBUG 2>&1 && echo finished_running_pump > /etc/network/status/$DEVICE ) &
     trap "" 2 3 11
     sleep 1
     eend 0
index 834d890..82bbdbe 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
+       dh_installdirs etc/grml etc/init.d usr/sbin usr/bin usr/share/doc/grml-saveconfig usr/lib/grml-autoconfig
 
        # Add here commands to install the package into debian/grml-autoconfig.
        install -m 755 grml-autoconfig      debian/grml-autoconfig/etc/init.d/grml-autoconfig
@@ -44,6 +44,7 @@ install: build
        install -m 755 bin/mkpersistenthome debian/grml-autoconfig/usr/bin/mkpersistenthome
        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/grml/pump-script b/etc/grml/pump-script
deleted file mode 100644 (file)
index 2d0ef13..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-# 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
-
-# See if we're needed at all, only run when booted with dhcphostname
-for i in $(cat /proc/cmdline)
-do
-       if [ "$i" = "dhcphostname" ]
-       then
-               # dhcphostname is set, get the PTR for the ip
-               hostname=$(host $3 | awk '{ print substr($5, 0, length($5)-1) }')
-               if [ -n "$hostname" ]
-               then
-                       echo $hostname > /etc/hostname
-               fi
-       fi
-done
diff --git a/etc/grml/pump-scripts.d/set-hostname b/etc/grml/pump-scripts.d/set-hostname
new file mode 100755 (executable)
index 0000000..9c2c518
--- /dev/null
@@ -0,0 +1,24 @@
+#!/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
+if ! checkbootparam 'nodhcphostname' ; then
+
+    hostname=$(host $3) || exit 1
+    # dhcphostname is set, get the PTR for the ip
+    hostname=$(echo ${hostname} | awk '{ print substr($5, 0, length($5)-1) }')
+
+    if [ -n "$hostname" ] ; then
+        echo $hostname > /etc/hostname
+        hostname -F /etc/hostname
+    fi
+fi
diff --git a/lib/pump-runparts b/lib/pump-runparts
new file mode 100644 (file)
index 0000000..3985964
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh -e
+
+arguments=""
+
+for ARG in $* ; do
+    arguments="${arguments} -a ${ARG} "
+done
+
+run-parts $arguments /etc/grml/pump-scripts.d/