From: <ow...@us...> - 2008-07-18 12:08:28
|
Revision: 1580 http://ipcop.svn.sourceforge.net/ipcop/?rev=1580&view=rev Author: owes Date: 2008-07-18 12:08:37 +0000 (Fri, 18 Jul 2008) Log Message: ----------- Add shell script used by dhcpcd Modified Paths: -------------- ipcop/trunk/config/rootfiles/common/stage2 Added Paths: ----------- ipcop/trunk/src/scripts/dhcpcd.sh Modified: ipcop/trunk/config/rootfiles/common/stage2 =================================================================== --- ipcop/trunk/config/rootfiles/common/stage2 2008-07-18 12:07:22 UTC (rev 1579) +++ ipcop/trunk/config/rootfiles/common/stage2 2008-07-18 12:08:37 UTC (rev 1580) @@ -60,6 +60,7 @@ #usr/lib/libgcc_s.so.1 #usr/local/bin usr/local/bin/dhclient-script.sh +usr/local/bin/dhcpcd.sh usr/local/bin/compile.help usr/local/bin/httpscert usr/local/bin/makegraphs Added: ipcop/trunk/src/scripts/dhcpcd.sh =================================================================== --- ipcop/trunk/src/scripts/dhcpcd.sh (rev 0) +++ ipcop/trunk/src/scripts/dhcpcd.sh 2008-07-18 12:08:37 UTC (rev 1580) @@ -0,0 +1,110 @@ +#!/bin/bash +# +# dhcpcd.sh is called by dhcpcd +# +# +# This file is part of the IPCop Firewall. +# +# IPCop is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# IPCop is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with IPCop; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# This script is based on the dhcpcd.sh sample script of the dhcpcd package, which has +# following copyright information: +# dhcpcd-3 - DHCP client daemon +# Copyright 2006-2008 Roy Marples <roy at marples dot name> +# +# +# (c) 2008, the IPCop team +# +# $Id$ +# + + +make_info_file() { + cat /dev/null > $FILE_INFO + echo "DHCLIENT_IPADDR=$IPADDR" >> $FILE_INFO + echo "DHCLIENT_INTERFACE=$INTERFACE" >> $FILE_INFO + router=`echo $GATEWAYS | /usr/bin/cut -d ' ' -f 1` + echo "DHCLIENT_GATEWAY=$router" >> $FILE_INFO + count=1 + for nameserver in $DNSSERVERS; do + echo "DHCLIENT_DNS$count=$nameserver" >> $FILE_INFO + ((++count)) + done + echo "DHCLIENT_HOSTNAME=$new_host_name" >> $FILE_INFO + echo "DHCLIENT_DOMAIN=$DNSDOMAIN" >> $FILE_INFO + echo "DHCLIENT_SIADDR=$DHCPSID" >> $FILE_INFO + echo "DHCLIENT_LEASETIME=$LEASETIME" >> $FILE_INFO + EXPIRY=$(( ${LEASEDFROM} + ${LEASETIME} )) + echo "DHCLIENT_EXPIRY=$EXPIRY" >> $FILE_INFO +} + + +# The following parameters are passed to dhcpcd.exe script: +# $1 = HostInfoFilePath, e.g "/var/lib/dhcpcd/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" + +FILE_INFO=/var/log/dhcpclient.info + +# 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 + make_info_file + ;; + + 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 + make_info_file + ;; + + 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 + ;; + + *) + if [ $# -lt 2 ]; then + logger -s -p local0.err -t dhcpcd.sh "wrong usage" + exit 1 + fi + ;; + +esac + +. /etc/rc.d/rc.updatered $FILE_INFO ${state} + +exit 0 Property changes on: ipcop/trunk/src/scripts/dhcpcd.sh ___________________________________________________________________ Added: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |