source: bootscripts-standard/cblfs/sysconfig/network-devices/services/dhclient@ 2a64094

Last change on this file since 2a64094 was 7df280d, checked in by Joe Ciccone <jciccone@…>, 17 years ago

Change /bin/sh to /bin/bash in the bootscripts because the bootscripts use bashisms. Having ash linked to sh will cause errors. Thanks to Bigdassaved for providing the diff and Copper for bring up the issue.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1#!/bin/bash
2# Begin $network-devices/services/dhclient
3
4# Based upon lfs-bootscripts-1.12 $network_devices/if{down,up}
5# Rewritten by Nathan Coulson <nathan@linuxfromscratch.org>
6# Adapted for dhclient by DJ Lucas <dj@lucasit.com>
7
8#$LastChangedBy: dnicholson $
9#$Date: 2006-10-01 13:04:35 -0500 (Sun, 01 Oct 2006) $
10
11. /etc/sysconfig/rc
12. $rc_functions
13. $IFCONFIG
14
15getipstats()
16{
17 # Print the last 16 lines of dhclient.leases
18 sed -e :a -e '$q;N;17,$D;ba' /var/state/dhcp/dhclient.leases
19}
20
21case "$2" in
22 up)
23 boot_mesg "Starting dhclient on the $1 interface..."
24 /sbin/dhclient $1 $DHCP_START
25 # Save the return value
26 RET="$?"
27 # Print the assigned settings if requested
28 if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then
29 # Get info from dhclient.leases file
30 IPADDR=`getipstats | grep "fixed-address" | \
31 sed 's/ fixed-address //' | \
32 sed 's/\;//'`
33 NETMASK=`getipstats | grep "subnet-mask" | \
34 sed 's/ option subnet-mask //' | \
35 sed 's/\;//'`
36 GATEWAY=`getipstats | grep "routers" | \
37 sed 's/ option routers //' | \
38 sed 's/\;//'`
39 DNS=`getipstats | grep "domain-name-servers" | \
40 sed 's/ option domain-name-servers //' | \
41 sed 's/\;//' | sed 's/,/ and /'`
42
43 if [ "$PRINTALL" = "yes" ]; then
44 $(exit "$RET")
45 evaluate_retval
46 boot_mesg " DHCP Assigned Settings for $1:"
47 boot_mesg_flush
48 boot_mesg " IP Address: $IPADDR"
49 boot_mesg_flush
50 boot_mesg " Subnet Mask: $NETMASK"
51 boot_mesg_flush
52 boot_mesg " Default Gateway: $GATEWAY"
53 boot_mesg_flush
54 boot_mesg " DNS Server: $DNS"
55 boot_mesg_flush
56 else
57 boot_mesg " IP Addresss:""$IPADDR"
58 $(exit "$RET")
59 evaluate_retval
60 fi
61 else
62 $(exit "$RET")
63 evaluate_retval
64 fi
65 ;;
66
67 down)
68 boot_mesg "Stoping dhclient on the $1 interface..."
69 if [ "$DHCP_STOP" = "" ]; then
70 # This breaks multiple interfaces please provide
71 # the correct stop arguments.
72 killproc dhclient
73 else
74 /sbin/dhclient $1 $DHCP_STOP
75 evaluate_retval
76 fi
77 ;;
78
79 *)
80 echo "Usage: $0 [interface] {up|down}"
81 exit 1
82 ;;
83esac
84
85# End $network_devices/services/dhclient
Note: See TracBrowser for help on using the repository browser.