[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

passing "-c filename" to /etc/init.d/dhcpc



I want to dynamically set /etc/hostname by using the below script and
having it called using the -c switch to dhcpcd

(from dhcpcd(8)):
OPTIONS
       -c filename
              Specifies the command file which  is  invoked  when
              dhcpcd successfully gets an IP address.

I altered /etc/init.d/dhcpc to start the daemon as follows:
start-stop-daemon --start --quiet --exec $DAEMON -- -c /usr/sbin/dynamic_host $IFACE

where /usr/sbin/dynamic_host is owned by root:root and has permissions of
755 and is:
#! /bin/bash

if [ -f /var/run/dhcpcd-cache.eth0 ] ; then
    IPADDR=$(grep IPADDR /etc/dhcpc/hostinfo-eth0 | sed 's/IPADDR=//g')
    HOSTNAME=$(host $IPADDR | grep Name | sed 's/Name: //g' | sed 's/.cgocable.net//g')
    echo $HOSTNAME > /etc/hostname
else
    echo "dhcpcd has not retrieved a ip address yet."
fi
 
However, nothing to /etc/hostname happens when /etc/init.d/dhcpc is
restarted. Furthermore, running /usr/sbin/dynamic_host by hand works fine
and so I am totally confused. Does /etc/init.d/dhcpc have write access to
/etc/hostname? Any help is gratefully appreciated. Cheers.

--
	  Colin R. Telmer, Institute of Intergovernmental Relations
	    School of Policy Studies Building, Queen's University
		     Kingston, Ontario, Canada, K7L-3N6
	      (613)545-6000x4219   telmerco@qed.econ.queensu.ca
	   PGP Public Key at <URL:http://terrapin.econ.queensu.ca>



--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: