From: Arne Fitzenreiter <arne_f@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: [PATCH] dhcpcd: version 9.x not has pidfiles
Date: Sun, 19 Apr 2020 10:36:42 +0200 [thread overview]
Message-ID: <97c6ff12d7ed668de57d86f3ff9c2983@ipfire.org> (raw)
In-Reply-To: <20200419070342.20226-1-arne_f@ipfire.org>
[-- Attachment #1: Type: text/plain, Size: 5064 bytes --]
I had to revise this. The pidfiles are only moved to /var/run/dhcpcd/
and has a different name.
Am 2020-04-19 09:03, schrieb Arne Fitzenreiter:
> 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
prev parent reply other threads:[~2020-04-19 8:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-19 7:03 Arne Fitzenreiter
2020-04-19 8:36 ` Arne Fitzenreiter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97c6ff12d7ed668de57d86f3ff9c2983@ipfire.org \
--to=arne_f@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox