From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arne Fitzenreiter To: development@lists.ipfire.org Subject: [PATCH] dhcpcd: version 9.x not has pidfiles Date: Sun, 19 Apr 2020 09:03:42 +0200 Message-ID: <20200419070342.20226-1-arne_f@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2855007531488737011==" List-Id: --===============2855007531488737011== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable the new dhcpcd not use pidfiles so i have removed all pidfile checks in our initskripts. Signed-off-by: Arne Fitzenreiter --- 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/n= etworking/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) =20 -dhcpcd_get_pid() { - # This function returns the pid of a dhcpcd by a given - # network device, if a pidfile exists. - - local device=3D"$1" - local pidfile=3D"/var/run/dhcpcd-${device}.pid" - - # Check if a pid file exists. - if [ -f "${pidfile}" ] ; then - - # Get the pid from the file. - local pid=3D"$(<"${pidfile}")" - - echo "${pid}" - fi -} - -dhcpcd_is_running() { - # This functions checks if a dhcpcd is running by a given pid. - - local pid=3D"$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 -} =20 dhcpcd_start() { # This function will start a dhcpcd on a speciefied device. @@ -60,15 +29,6 @@ dhcpcd_start() { =20 boot_mesg -n "Starting dhcpcd on the ${device} interface..." =20 - # Check if a dhcpcd is already running. - local pid=3D"$(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+=3D"-h ${RED_DHCP_HOSTNAME}" @@ -122,32 +82,21 @@ dhcpcd_stop() { =20 boot_mesg -n "Stopping dhcpcd on the ${device} interface..." =20 - # Check if a dhcpcd is running. - local pid=3D"$(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=3D"$?" - - # Wait until dhcpd has stopped. - while [ -d "/proc/${pid}" ]; do + for ((i=3D1;i<31;i++)) do + /sbin/dhcpcd ${dhcp_stop} ${device} &> /dev/null + if [ ${?} -eq 1 ]; then + break; + fi sleep 1 + echo -n "." done =20 # 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=3D"pppoe" fi if [ "${IPTV}" =3D=3D "enable" ]; then - PIDFILE=3D"/var/run/dhcpcd-${DEVICE}.${IPTV_VLAN}.pid" LEASEINFO=3D"/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 [ $? !=3D 0 ]; then - rm -f /var/run/dhcpcd-${DEVICE}.${IPTV_VLAN}.pid > /dev/null - fi - fi =20 - 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" =3D=3D "pppoe" ] || [ "$TYPE" =3D=3D "pptp" ]; then if [ "$PPP_NIC" =3D=3D "" ]; then @@ -285,15 +275,6 @@ case "${1}" in ip addr flush dev $PPP_NIC >/dev/null 2>&1 if [ "$TYPE" =3D=3D "pptp" ]; then if [ "$PPTP_NICCFG" =3D=3D "dhcp" ]; then - # Test to see if there is a stale pid file - if [ -f "$PIDFILE" ]; then - ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null - if [ $? !=3D 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=3D"$?" @@ -320,7 +301,6 @@ case "${1}" in $(exit "$RET") evaluate_retval fi - fi else ip addr add $PPTP_NICCFG dev $PPP_NIC fi --=20 2.17.1 --===============2855007531488737011==--