public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH] dhcpcd: version 9.x not has pidfiles
@ 2020-04-19  7:03 Arne Fitzenreiter
  2020-04-19  8:36 ` Arne Fitzenreiter
  0 siblings, 1 reply; 2+ messages in thread
From: Arne Fitzenreiter @ 2020-04-19  7:03 UTC (permalink / raw)
  To: development

[-- Attachment #1: Type: text/plain, Size: 4774 bytes --]

the new dhcpcd not use pidfiles so i have removed
all pidfile checks in our initskripts.

Signed-off-by: Arne Fitzenreiter <arne_f(a)ipfire.org>
---
 src/initscripts/networking/functions.network | 67 +++-----------------
 src/initscripts/networking/red               | 20 ------
 2 files changed, 8 insertions(+), 79 deletions(-)

diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network
index 17191e7a9..b5495854b 100644
--- a/src/initscripts/networking/functions.network
+++ b/src/initscripts/networking/functions.network
@@ -20,37 +20,6 @@
 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
 eval $(/usr/local/bin/readhash /var/ipfire/dns/settings)
 
-dhcpcd_get_pid() {
-		# This function returns the pid of a dhcpcd by a given
-		# network device, if a pidfile exists.
-
-		local device="$1"
-		local pidfile="/var/run/dhcpcd-${device}.pid"
-
-		# Check if a pid file exists.
-		if [ -f "${pidfile}" ] ; then
-
-			# Get the pid from the file.
-			local pid="$(<"${pidfile}")"
-
-			echo "${pid}"
-		fi
-}
-
-dhcpcd_is_running() {
-	# This functions checks if a dhcpcd is running by a given pid.
-
-	local pid="$1"
-
-	# Check if a dhcpcd is running.
-	if [ -n "${pid}" -a -d "/proc/${pid}" ]; then
-		# Return "0" (True) if a dhcpcd is running.
-		return 0
-	fi
-
-	# Return 1 (False) no dhcpcd is running.
-	return 1
-}
 
 dhcpcd_start() {
 	# This function will start a dhcpcd on a speciefied device.
@@ -60,15 +29,6 @@ dhcpcd_start() {
 
 	boot_mesg -n "Starting dhcpcd on the ${device} interface..."
 
-	# Check if a dhcpcd is already running.
-	local pid="$(dhcpcd_get_pid "${device}")"
-
-	if  dhcpcd_is_running "${pid}"; then
-		boot_mesg "dhcpcd already running!" ${WARNING}
-		echo_warning
-		exit 2
-	fi
-
 	# Check if a DHCP hostname has been set.
 	if [ -n "${RED_DHCP_HOSTNAME}" ]; then
 		dhcp_start+="-h ${RED_DHCP_HOSTNAME}"
@@ -122,32 +82,21 @@ dhcpcd_stop() {
 
 	boot_mesg -n "Stopping dhcpcd on the ${device} interface..."
 
-	# Check if a dhcpcd is running.
-	local pid="$(dhcpcd_get_pid "${device}")"
-
-	if ! dhcpcd_is_running "${pid}"; then
-		boot_mesg "    Not running." ${WARNING}
-		echo_warning
-		exit 1
-	fi
-
 	# Stop dhcpcd.
-	/sbin/dhcpcd ${dhcp_stop} ${device} &> /dev/null
-	ret="$?"
-
-	# Wait until dhcpd has stopped.
-	while [ -d "/proc/${pid}" ]; do
+	for ((i=1;i<31;i++)) do
+		/sbin/dhcpcd ${dhcp_stop} ${device} &> /dev/null
+		if [ ${?} -eq 1 ]; then
+			break;
+		fi
 		sleep 1
+		echo -n "."
 	done
 
 	# Display console message, depended on the exit code
-	# of the stopped dhcpcd.
-	if [ "${ret}" -eq 0 ]; then
+
+	if [ $i -lt 30 ]; then
 		boot_mesg
 		echo_ok
-	elif [ "${ret}" -eq 1 ]; then
-		boot_mesg "failed to stop dhcpcd!" ${WARNING}
-		echo_warning
 	else
 		boot_mesg
 		echo_failure
diff --git a/src/initscripts/networking/red b/src/initscripts/networking/red
index e154cc8b1..cf6d87413 100644
--- a/src/initscripts/networking/red
+++ b/src/initscripts/networking/red
@@ -228,17 +228,8 @@ case "${1}" in
 				TYPE="pppoe"
 			fi
 			if [ "${IPTV}" == "enable" ]; then
-				PIDFILE="/var/run/dhcpcd-${DEVICE}.${IPTV_VLAN}.pid"
 				LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.${IPTV_VLAN}.info"
-				# 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}.${IPTV_VLAN}.pid > /dev/null
-					fi
-				fi
 
-				if [ ! -f "$PIDFILE" ]; then
 					boot_mesg "Creating VLAN Interface ${DEVICE}.${IPTV_VLAN} ..."
 					modprobe 8021q
 					vconfig add ${DEVICE} ${IPTV_VLAN}
@@ -273,7 +264,6 @@ case "${1}" in
 						$(exit "$RET")
 						evaluate_retval
 					fi
-				fi
 			fi
 			if [ "$TYPE" == "pppoe" ] || [ "$TYPE" == "pptp" ]; then
 				if [ "$PPP_NIC" == "" ]; then
@@ -285,15 +275,6 @@ case "${1}" in
 				ip addr flush dev $PPP_NIC >/dev/null 2>&1
 				if [ "$TYPE" == "pptp" ]; then
 					if [ "$PPTP_NICCFG" == "dhcp" ]; then
-						# 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
-							fi
-						fi
-
-						if [ ! -f "$PIDFILE" ]; then
 							boot_mesg -n "Starting dhcpcd on the ${DEVICE} interface..."
 							/sbin/dhcpcd ${DEVICE} ${DHCP_START} >/dev/null 2>&1
 							RET="$?"
@@ -320,7 +301,6 @@ case "${1}" in
 								$(exit "$RET")
 								evaluate_retval
 							fi
-						fi
 					else
 						ip addr add $PPTP_NICCFG dev $PPP_NIC
 					fi
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-19  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-19  7:03 [PATCH] dhcpcd: version 9.x not has pidfiles Arne Fitzenreiter
2020-04-19  8:36 ` Arne Fitzenreiter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox