]>
git.ipfire.org Git - ipfire-3.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 # Test to see if there is a stale pid file
21 ps
`cat "$PIDFILE"` |
grep dhcpcd
> /dev
/null
24 rm -f /var
/run
/dhcpcd-
$1.pid
> /dev
/null
26 boot_mesg
"dhcpcd already running!" ${WARNING}
31 /sbin
/iptables
-A REDINPUT
-p tcp
--source-port 67 --destination-port 68 -i ${1} -j ACCEPT
32 /sbin
/iptables
-A REDINPUT
-p udp
--source-port 67 --destination-port 68 -i ${1} -j ACCEPT
33 DHCP_START
="-N -R -L /var/ipfire/dhcpc "
34 if [ -n "${DHCP_HOSTNAME}" ]; then
35 DHCP_START
+="-h ${DHCP_HOSTNAME}"
37 /sbin
/dhcpcd
$1 $DHCP_START
38 # Save the return value
40 # Print the assigned settings if requested
41 if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then
42 .
/var
/ipfire
/dhcpc
/dhcpcd-
$1.info
43 if [ "$PRINTALL" = "yes" ]; then
46 boot_mesg
" DHCP Assigned Settings for $1:"
48 boot_mesg
" IP Address: $IPADDR"
50 if [ -n "${DHCP_HOSTNAME}" ]; then
51 boot_mesg
" Hostname: $DHCP_HOSTNAME"
54 boot_mesg
" Subnet Mask: $NETMASK"
56 boot_mesg
" Default Gateway: $GATEWAY"
58 boot_mesg
" DNS Server: $DNS"
61 boot_mesg
" IP Addresss: ""$IPADDR"
72 boot_mesg
-n "Stopping dhcpcd on the $1 interface..."
73 # Do nothing with the client daemon if we have an infinate
74 # lease time as the client exits when started in this case,
81 if [ "$LEASETIME" = "4294967295" ]
83 # do nothing, just echo ok
87 if [ -n "$DHCP_STOP" ]
89 /sbin
/dhcpcd
$1 $DHCP_STOP &> /dev
/null
91 if [ "$RET" -eq 0 ]; then
94 elif [ "$RET" -eq 1 ]; then
95 boot_mesg
"dhcpcd not running!" ${WARNING}
107 boot_mesg
-n "LEASEINFO Test failed! - " ${WARNING}
108 boot_mesg
"dhcpcd is not running!" ${WARNING}
115 echo "Usage: $0 [interface] {up|down}"
120 # End $network_devices/services/dhcpcd