- # Test to see if there is a stale pid file
- if [ -f "$PIDFILE" ]; then
- ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
- if [ $? != 0 ]; then
- rm -f /var/run/dhcpcd-${DEVICE}.pid > /dev/null
- else
- boot_mesg "dhcpcd already running!" ${WARNING}
- echo_warning
- exit 2
- fi
- fi
-
- iptables -A REDINPUT -p tcp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT
- iptables -A REDINPUT -p udp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT
-
- if [ -n "${RED_DHCP_HOSTNAME}" ]; then
- DHCP_START+="-h ${RED_DHCP_HOSTNAME} "
- fi
-
- /sbin/dhcpcd ${DEVICE} ${DHCP_START} >/dev/null 2>&1
- RET="$?"
-
- if [ "$RET" = "0" ]; then
- . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info
- echo ""
- echo_ok
- boot_mesg " DHCP Assigned Settings for ${DEVICE}:"
- boot_mesg_flush
- boot_mesg " IP Address: $IPADDR"
- boot_mesg_flush
- if [ -n "${RED_DHCP_HOSTNAME}" ]; then
- boot_mesg " Hostname: $RED_DHCP_HOSTNAME"
- boot_mesg_flush
- fi
- boot_mesg " Subnet Mask: $NETMASK"
- boot_mesg_flush
- boot_mesg " Default Gateway: $GATEWAY"
- boot_mesg_flush
- boot_mesg " DNS Server: $DNS"
- boot_mesg_flush
-
- echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var/ipfire/red/dns1
- echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var/ipfire/red/dns2
-
- . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info
- echo "$IPADDR" > /var/ipfire/red/local-ipaddress
- grep -v "gateway" /etc/hosts > /tmp/hosts
- echo "$GATEWAY gateway" >> /tmp/hosts
- mv /tmp/hosts /etc/hosts
- echo "$GATEWAY" > /var/ipfire/red/remote-ipaddress
- else
- echo ""
- $(exit "$RET")
- evaluate_retval
- fi
-