LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   DDclient slack13 dhcpcd.sh vs dhcpcd.eth0.exe question (http://www.linuxquestions.org/questions/slackware-14/ddclient-slack13-dhcpcd-sh-vs-dhcpcd-eth0-exe-question-762772/)

nl1at 10-18-2009 09:34 AM

DDclient slack13 dhcpcd.sh vs dhcpcd.eth0.exe question
 
In slack13 there is a dhcpcd.sh script like this:
Code:

#!/bin/sh
#
#  This is a sample /etc/dhcpc/dhcpcd.sh script.
#  /etc/dhcpc/dhcpcd.sh script is executed by dhcpcd daemon
#  any time it configures or shuts down interface.
#  The following parameters are passed to the dhcpcd.sh script:
#  $1 = HostInfoFilePath, e.g  "/etc/dhcpc/dhcpcd-eth0.info"
#  $2 = "up" if interface has been configured with the same
#      IP address as before reboot;
#  $2 = "down" if interface has been shut down;
#  $2 = "new" if interface has been configured with new IP address;
#
#  Sanity checks

if [ $# -lt 2 ]; then
        logger -s -p local0.err -t dhcpcd.sh "wrong usage"
        exit 1
fi

hostinfo="$1"
state="$2"

# Reading HostInfo file for configuration parameters
[ -e "${hostinfo}" ] && . "${hostinfo}"

case "${state}" in
        up)
        logger -s -p local0.info -t dhcpcd.sh \
        "interface ${INTERFACE} has been configured with old IP=${IPADDR}"
        # Put your code here for when the interface has been brought up with an
        # old IP address here
        ;;

        new)
        logger -s -p local0.info -t dhcpcd.sh \
        "interface ${INTERFACE} has been configured with new IP=${IPADDR}"
        # Put your code here for when the interface has been brought up with a
        # new IP address
        ;;

        down) logger -s -p local0.info -t dhcpcd.sh \
        "interface ${INTERFACE} has been brought down"
        # Put your code here for the when the interface has been shut down
        ;;
esac
exit 0

Now my older slack distro has a file called dhcpcd-eth0.exe and ddclient has got a replacement for it so it updates my dyndns account like this :
Code:

#!/bin/sh
######################################################################
## $Header: /home/paul/src/ddclient/RCS/sample-etc_dhcpc_dhcpcd-eth0.exe,v 3.6 2002/11/03 20:20:16 root Exp $
######################################################################
PATH=/usr/sbin:${PATH}

## update the DNS server unless the IP address is a private address
## that may be used as a internal LAN address. This may be true if
## other interfaces are assigned private addresses from internal
## DHCP server.

case "$1" in
10.*)          ;;
172.1[6-9].* | 172.2[0-9].* | 172.3[0-1].*)        ;;
192.168.*)        ;;
*)
        logger -t dhcpcd IP address changed to $1
        ddclient -daemon=0 -syslog -use=ip -ip=$1 >/dev/null 2>&1
        ;;
esac

My question is what code to insert to the dhcpcd.sh file to update dyndns with ddclient?

MQMan 10-18-2009 03:21 PM

dhcpcd.sh is a straight replacement for dhcpcd.exe, not dhcpcd-eth0.exe.

Its' dhcpcd.exe that is invoked by dhcpcd, so the first thing to do, is to find out how your dhcpcd-eth0.exe is called. Then you can look at modifying dhcpcd.sh.

My, easier, guess, would be to find the line in dhcpcd.exe, that outputs the IP to the log, which is followed by the comment "Put your code here", and follow it with:
Code:

case "${IPADDR}" in
10.*)          ;;
172.1[6-9].* | 172.2[0-9].* | 172.3[0-1].*)        ;;
192.168.*)        ;;
*)
        ddclient -daemon=0 -syslog -use=ip -ip=${IPADDR} >/dev/null 2>&1
        ;;
esac

Cheers.

nl1at 10-22-2009 01:03 PM

Hey thanks!
Gonna try that.

nl1at 10-27-2010 01:51 PM

This does not seem to work?

And dhcpcd.sh always says that my interface was brought up with new ipnr.
But it always get the same adress?
With no cat cable attached and dhcpcd gives a ipnr in the 169 segment it says configured with old ip nr??? :confused:


All times are GMT -5. The time now is 10:10 PM.