From patchwork Sun Apr 19 07:03:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Fitzenreiter X-Patchwork-Id: 2987 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 494gmM17Ssz3xQy for ; Sun, 19 Apr 2020 07:04:03 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 494gmK3l0yz23T; Sun, 19 Apr 2020 07:04:01 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 494gmK1qzrz2yZc; Sun, 19 Apr 2020 07:04:01 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 494gmJ0hGsz2y4F for ; Sun, 19 Apr 2020 07:04:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 494gmG6Mwpz23T; Sun, 19 Apr 2020 07:03:58 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1587279839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=EhUL5YYuL0MtONYZjr6l56r3o2WeSAkO0jJEddfaJFw=; b=pvQibbJIPEzRRT8pxFmJhK8KbNoJ7U95gG9G86BAfXvu2Ipt4EuosyEksfTvHBEp+6YI2+ V4tDFdCeIgIHysBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1587279839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=EhUL5YYuL0MtONYZjr6l56r3o2WeSAkO0jJEddfaJFw=; b=PCNj4lhWbhT36g5uRLzApD4TLmyaZ9O9nXuv5Zt0SsmtjJFtXN5Ufbbw/5/sysW4Qlf+aC vgSg06eSjn4CTkmQJN8yikSBCjNKkGSsJ89d0KYtlCldnzRu+1DtSY1c+55cA394QDORUb BDqXlCbX/+y1TB2zL4E13P+WMpVKtvAxG4HyzQ8HayqVzlr/cFq2eTewlmc/XLDdaKSsU4 ZJHs1V5rtphclY12Mb/M2OxDqZuyXKVxccUyq8JH3MKguzxENSyOW1VVirQJm3On/LikvX BKtRngHe1ZXMAXLbYPWPVHEqLwlw1W6ZHAV57FWTqtKSaIWraB9BeMDrPdGnWA== 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> Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=arne_f@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arne Fitzenreiter Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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/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