Author: ken
Date: 2011-11-23 10:05:21 -0700 (Wed, 23 Nov 2011)
New Revision: 9004
Added:
trunk/bootscripts/blfs/services/dhclient
Modified:
trunk/bootscripts/Makefile
trunk/bootscripts/blfs/services/dhcpcd
Log:
Add service script for dhclient
Modified: trunk/bootscripts/Makefile
===================================================================
--- trunk/bootscripts/Makefile 2011-11-22 12:28:23 UTC (rev 9003)
+++ trunk/bootscripts/Makefile 2011-11-23 17:05:21 UTC (rev 9004)
@@ -20,7 +20,7 @@
install -d -m ${DIRMODE} ${LIBDIR}
install-service-dhclient: create-service-dir
- install -m ${MODE} blfs/sysconfig/network-devices/services/dhclient
${EXTDIR}/sysconfig/network-devices/services
+ install -m ${MODE} blfs/services/dhclient ${LIBDIR}
install-service-dhcpcd: create-service-dir
install -m ${MODE} blfs/services/dhcpcd ${LIBDIR}
Added: trunk/bootscripts/blfs/services/dhclient
===================================================================
--- trunk/bootscripts/blfs/services/dhclient (rev 0)
+++ trunk/bootscripts/blfs/services/dhclient 2011-11-23 17:05:21 UTC (rev
9004)
@@ -0,0 +1,86 @@
+#!/bin/bash
+# Begin services/dhclient
+
+# Origianlly based upon lfs-bootscripts-1.12 $NETWORK_DEVICES/if{down,up}
+# Rewritten by Nathan Coulson <[email protected]>
+# Adapted for dhclient by DJ Lucas <[email protected]>
+# Update for LFS 7.0 by Ken Moffat <[email protected]>
+
+# Call with: IFCONFIG=<filename> /lib/services/dhclient <IFACE> <up | down>
+
+#$LastChangedBy$
+#$Date$
+
+. /lib/lsb/init-functions
+. $IFCONFIG
+
+getipstats()
+{
+ # Print the last 16 lines of dhclient.leases
+ sed -e :a -e '$q;N;17,$D;ba' /var/state/dhclient.leases
+}
+
+case "$2" in
+ up)
+ log_info_msg "\nStarting dhclient on the $1 interface..."
+
+ /sbin/dhclient $1 $DHCP_START
+ # Save the return value
+ RET="$?"
+ # Print the assigned settings if requested
+ if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then
+ # Get info from dhclient.leases file
+ IPADDR=`getipstats | grep "fixed-address" | \
+ sed 's/ fixed-address //' | \
+ sed 's/\;//'`
+ NETMASK=`getipstats | grep "subnet-mask" | \
+ sed 's/ option subnet-mask //' | \
+ sed 's/\;//'`
+ GATEWAY=`getipstats | grep "routers" | \
+ sed 's/ option routers //' | \
+ sed 's/\;//'`
+ DNS=`getipstats | grep "domain-name-servers" | \
+ sed 's/ option domain-name-servers //' | \
+ sed 's/\;//' | sed 's/,/ and /'`
+
+ if [ "$PRINTALL" = "yes" ]; then
+ # this is messy, the messages are on one very
long
+ # line on the screen and in the log
+ log_info_msg " DHCP Assigned Settings
for $1:"
+ log_info_msg " IP Address:
$IPADDR"
+ log_info_msg " Subnet Mask:
$NETMASK"
+ log_info_msg " Default Gateway:
$GATEWAY"
+ log_info_msg " DNS Server: $DNS"
+ $(exit "$RET")
+ evaluate_retval
+ else
+ log_info_msg " IP Addresss:""$IPADDR"
+ $(exit "$RET")
+ evaluate_retval
+ fi
+ else
+ $(exit "$RET")
+ evaluate_retval
+ fi
+ ;;
+
+ down)
+ log_info_msg "Stopping dhclient on the $1 interface..."
+
+ if [ -z "$DHCP_STOP" ]; then
+ # This breaks multiple interfaces please provide
+ # the correct stop arguments.
+ killproc dhclient
+ else
+ /sbin/dhclient $1 $DHCP_STOP
+ evaluate_retval
+ fi
+ ;;
+
+ *)
+ echo "Usage: $0 [interface] {up|down}"
+ exit 1
+ ;;
+esac
+
+# End services/dhclient
Property changes on: trunk/bootscripts/blfs/services/dhclient
___________________________________________________________________
Added: svn:keywords
+ LastChangedBy Date
Modified: trunk/bootscripts/blfs/services/dhcpcd
===================================================================
--- trunk/bootscripts/blfs/services/dhcpcd 2011-11-22 12:28:23 UTC (rev
9003)
+++ trunk/bootscripts/blfs/services/dhcpcd 2011-11-23 17:05:21 UTC (rev
9004)
@@ -8,8 +8,8 @@
# Call with: IFCONFIG=<filename> /lib/services/dhcpcd <IFACE> <up | down>
-#$LastChangedBy: bdubbs $
-#$Date: 2005-08-01 13:29:19 -0600 (Mon, 01 Aug 2005) $
+#$LastChangedBy$
+#$Date$
. /lib/lsb/init-functions
. $IFCONFIG
@@ -38,7 +38,7 @@
;;
down)
- log_info_msg "Stoping dhcpcd on the $1 interface..."
+ log_info_msg "Stopping dhcpcd on the $1 interface..."
if [ -z "$DHCP_STOP" ]; then
killproc -p "${PIDFILE}" /sbin/dhcpcd
Property changes on: trunk/bootscripts/blfs/services/dhcpcd
___________________________________________________________________
Added: svn:keywords
+ LastChangedBy Date
--
http://linuxfromscratch.org/mailman/listinfo/blfs-book
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page