From dceb955917ed04c7b7a0aa641417b2978478e9ef Mon Sep 17 00:00:00 2001 From: HgO Date: Wed, 16 Aug 2023 21:04:42 +0200 Subject: [PATCH] ensure process from pid is running and remove pid file --- conf/ynh-hotspot | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conf/ynh-hotspot b/conf/ynh-hotspot index d3c732b..8883f2f 100644 --- a/conf/ynh-hotspot +++ b/conf/ynh-hotspot @@ -73,13 +73,13 @@ is_forwarding_set() { is_dhcpd6_running() { local i=${1} - [[ -e "/run/dnsmasq/dnsmasq-dhcpdv6-ssid${i}.pid" ]] + [[ -e "/run/dnsmasq/dnsmasq-dhcpdv6-ssid${i}.pid" ]] && ps -p $(cat "/run/dnsmasq/dnsmasq-dhcpdv6-ssid${i}.pid") > /dev/null } is_dhcpd4_running() { local i=${1} - [[ -e "/run/dnsmasq/dnsmasq-dhcpdv4-ssid${i}.pid" ]] + [[ -e "/run/dnsmasq/dnsmasq-dhcpdv4-ssid${i}.pid" ]] && ps -p $(cat "/run/dnsmasq/dnsmasq-dhcpdv4-ssid${i}.pid") > /dev/null } is_hostapd_running() { @@ -249,12 +249,14 @@ stop_dhcpd() { if is_dhcpd6_running ${i}; then echo "hotspot${i}: Stop the NDP and DHCPv6 server (dnsmasq)" kill $(cat /run/dnsmasq/dnsmasq-dhcpdv6-ssid${i}.pid) + rm -f /run/dnsmasq/dnsmasq-dhcpdv6-ssid${1}.pid rm -f /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf fi if is_dhcpd4_running ${i}; then echo "hotspot${i}: Stop the DHCPv4 server (dnsmasq)" kill $(cat /run/dnsmasq/dnsmasq-dhcpdv4-ssid${i}.pid) + rm -f /run/dnsmasq/dnsmasq-dhcpdv4-ssid${1}.pid rm -f /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf fi }