#!/bin/bash # Begin services/dhcpcd # Originally based upon lfs-bootscripts-1.12 $NETWORK_DEVICES/if{down,up} # Rewritten by Nathan Coulson # Adapted for dhcpcd by DJ Lucas # Update for LFS 7.0 by Bruce Dubbs # Call with: IFCONFIG= /lib/services/dhcpcd . /lib/lsb/init-functions . $IFCONFIG pidfile_old="/run/dhcpcd-$1.pid" pidfile_new="/run/dhcpcd/$1.pid" case "$2" in up) log_info_msg "Starting dhcpcd on the $1 interface..." # Test to see if there is a stale pid file, for versions before 9.0.0 if [ -f "$pidfile_old" ]; then ps `cat "$pidfile_old"` | grep dhcpcd > /dev/null if [ $? != 0 ]; then rm -f $pidfile_old > /dev/null else log_warning_msg "dhcpcd is already running!" exit 2 fi fi # Test to see if there is a stale pid file if [ -f "$pidfile_new" ]; then ps `cat "$pidfile_new"` | grep dhcpcd > /dev/null if [ $? != 0 ]; then rm -f $pidfile_new > /dev/null else log_warning_msg "dhcpcd is already running!" exit 2 fi fi /sbin/dhcpcd $DHCP_START $1 evaluate_retval ;; down) log_info_msg "Stopping dhcpcd on the $1 interface..." if [ -z "$DHCP_STOP" ]; then if [ -f "${pidfile_old}" ]; then killproc -p "${pidfile}" /sbin/dhcpcd elif [ -f "${pidfile_new}" ]; then killproc -p "${pidfile_new}" /sbin/dhcpcd fi else /sbin/dhcpcd $DHCP_STOP $1 &> /dev/null if [ "$?" -eq 1 ]; then log_warning_msg "dhcpcd not running!" exit 2 fi fi evaluate_retval ;; *) echo "Usage: $0 [interface] {up|down}" exit 1 ;; esac # End services/dhcpcd