]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/init.d/net/red/dhcpcd
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 /sbin
/iptables
-A REDINPUT
-p tcp
--source-port 67 --destination-port 68 -i ${1} -j ACCEPT
34 /sbin
/iptables
-A REDINPUT
-p udp
--source-port 67 --destination-port 68 -i ${1} -j ACCEPT
35 DHCP_START
="-N -R -L /var/ipfire/dhcpc "
36 if [ -n "${DHCP_HOSTNAME}" ]; then
37 DHCP_START
+="-h ${DHCP_HOSTNAME}"
39 /sbin
/dhcpcd
$1 $DHCP_START >/dev
/null
2>&1
40 # Save the return value
42 # Print the assigned settings if requested
43 if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then
44 .
/var
/ipfire
/dhcpc
/dhcpcd-
$1.info
45 logger
-t ipfire
"DHCPCD Success"
46 if [ "$PRINTALL" = "yes" ]; then
49 boot_mesg
" DHCP Assigned Settings for $1:"
51 boot_mesg
" IP Address: $IPADDR"
53 if [ -n "${DHCP_HOSTNAME}" ]; then
54 boot_mesg
" Hostname: $DHCP_HOSTNAME"
57 boot_mesg
" Subnet Mask: $NETMASK"
59 boot_mesg
" Default Gateway: $GATEWAY"
61 boot_mesg
" DNS Server: $DNS"
64 boot_mesg
" IP Addresss: ""$IPADDR"
69 logger
-t ipfire
"DHCPCD Fail"
76 boot_mesg
-n "Stopping dhcpcd on the $1 interface..."
77 # Do nothing with the client daemon if we have an infinate
78 # lease time as the client exits when started in this case,
85 if [ "$LEASETIME" = "4294967295" ]
87 # do nothing, just echo ok
91 if [ -n "$DHCP_STOP" ]
93 /sbin
/dhcpcd
$1 $DHCP_STOP &> /dev
/null
95 if [ "$RET" -eq 0 ]; then
98 elif [ "$RET" -eq 1 ]; then
99 boot_mesg
"dhcpcd not running!" ${WARNING}
111 boot_mesg
-n "LEASEINFO Test failed! - " ${WARNING}
112 boot_mesg
"dhcpcd is not running!" ${WARNING}
119 echo "Usage: $0 [interface] {up|down}"
124 # End $network_devices/services/dhcpcd