From: Ulrich Dangel Date: Wed, 14 Oct 2009 12:51:03 +0000 (+0200) Subject: Reworked and grmlfied patch from Andreas Thienemann X-Git-Tag: v0.8.34~1 X-Git-Url: http://git.grml.org/?p=grml-autoconfig.git;a=commitdiff_plain;h=91d88e67c7e46049809a9b79b6aa7841ecda3c7d;hp=98b0e91f4ac3801dd6d084f39e7c112e211e0a40 Reworked and grmlfied patch from Andreas Thienemann 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 --- diff --git a/autoconfig.functions b/autoconfig.functions index 5417220..cd9baca 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -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 diff --git a/debian/rules b/debian/rules index 834d890..82bbdbe 100755 --- a/debian/rules +++ b/debian/rules @@ -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 index 2d0ef13..0000000 --- a/etc/grml/pump-script +++ /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 index 0000000..9c2c518 --- /dev/null +++ b/etc/grml/pump-scripts.d/set-hostname @@ -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 index 0000000..3985964 --- /dev/null +++ b/lib/pump-runparts @@ -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/