]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/init.d/net/common/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 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 -c /var/ipfire/dhcpc/dhcpcd.exe "
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"
71 if [ "$DNS1" = "" ]; then
72 echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var
/ipfire
/red
/dns1
73 echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var
/ipfire
/red
/dns2
75 echo "$DNS1" > /var
/ipfire
/red
/dns1
76 echo "$DNS2" > /var
/ipfire
/red
/dns2
78 .
/var
/ipfire
/dhcpc
/dhcpcd-
${1}.info
79 echo "$IPADDR" > /var
/ipfire
/red
/local-ipaddress
80 echo "$GATEWAY" > /var
/ipfire
/red
/remote-ipaddress
83 logger
-t ipfire
"DHCPCD Fail"
90 boot_mesg
-n "Stopping dhcpcd on the $1 interface..."
91 # Do nothing with the client daemon if we have an infinate
92 # lease time as the client exits when started in this case,
94 DHCP_STOP
="-k -c /var/ipfire/dhcpc/dhcpcd.exe "
99 if [ "$LEASETIME" = "4294967295" ]
101 # do nothing, just echo ok
105 if [ -n "$DHCP_STOP" ]
107 /sbin
/dhcpcd
$1 $DHCP_STOP &> /dev
/null
109 if [ "$RET" -eq 0 ]; then
112 elif [ "$RET" -eq 1 ]; then
113 boot_mesg
"dhcpcd not running!" ${WARNING}
125 boot_mesg
-n "LEASEINFO Test failed! - " ${WARNING}
126 boot_mesg
"dhcpcd is not running!" ${WARNING}
133 echo "Usage: $0 [interface] {up|down}"
138 # End $network_devices/services/dhcpcd