]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/init.d/net/common/dhcpcd
f4f9218fed371adb8e6bb309f0f76f7eef59c29f
2 # Begin $network-devices/services/dhcpcd
4 # Based upon lfs-bootscripts-1.12 $network_devices/if{down,up}
5 # Rewritten by Nathan Coulson <nathan@linuxfromscratch.org>
6 # Adapted for dhcpcd by DJ Lucas <dj@lucasit.com>
7 # Made compatible for ipfire by Michael Tremer mitch@ipfire.org
12 PIDFILE
="/var/run/dhcpcd-$1.pid"
13 LEASEINFO
="/var/ipfire/dhcpc/dhcpcd-$1.info"
17 boot_mesg
-n "Starting dhcpcd on the $1 interface..."
18 echo -n "${1}" > /var
/ipfire
/red
/iface
20 # Test to see if there is a stale pid file
23 ps
`cat "$PIDFILE"` |
grep dhcpcd
> /dev
/null
26 rm -f /var
/run
/dhcpcd-
$1.pid
> /dev
/null
28 boot_mesg
"dhcpcd already running!" ${WARNING}
33 if [ "$NAME" == "red" ]; then
34 /sbin
/iptables
-A REDINPUT
-p tcp
--source-port 67 --destination-port 68 -i ${1} -j ACCEPT
35 /sbin
/iptables
-A REDINPUT
-p udp
--source-port 67 --destination-port 68 -i ${1} -j ACCEPT
38 DHCP_START
="-N -R -L /var/ipfire/dhcpc "
40 if [ -n "${DHCP_HOSTNAME}" ]; then
41 DHCP_START
+="-h ${DHCP_HOSTNAME} "
43 /sbin
/dhcpcd
$1 $DHCP_START >/dev
/null
2>&1
44 # Save the return value
46 # Print the assigned settings if requested
47 if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then
48 .
/var
/ipfire
/dhcpc
/dhcpcd-
$1.info
49 logger
-t ipfire
"DHCPCD Success"
50 if [ "$PRINTALL" = "yes" ]; then
53 boot_mesg
" DHCP Assigned Settings for $1:"
55 boot_mesg
" IP Address: $IPADDR"
57 if [ -n "${DHCP_HOSTNAME}" ]; then
58 boot_mesg
" Hostname: $DHCP_HOSTNAME"
61 boot_mesg
" Subnet Mask: $NETMASK"
63 boot_mesg
" Default Gateway: $GATEWAY"
65 boot_mesg
" DNS Server: $DNS"
68 boot_mesg
" IP Addresss: ""$IPADDR"
73 logger
-t ipfire
"DHCPCD Fail"
80 boot_mesg
-n "Stopping dhcpcd on the $1 interface..."
81 # Do nothing with the client daemon if we have an infinate
82 # lease time as the client exits when started in this case,
89 if [ "$LEASETIME" = "4294967295" ]
91 # do nothing, just echo ok
95 if [ -n "$DHCP_STOP" ]
97 /sbin
/dhcpcd
$1 $DHCP_STOP &> /dev
/null
99 if [ "$RET" -eq 0 ]; then
102 elif [ "$RET" -eq 1 ]; then
103 boot_mesg
"dhcpcd not running!" ${WARNING}
115 boot_mesg
-n "LEASEINFO Test failed! - " ${WARNING}
116 boot_mesg
"dhcpcd is not running!" ${WARNING}
123 echo "Usage: $0 [interface] {up|down}"
128 # End $network_devices/services/dhcpcd