diff mbox series

[OpenWrt-Devel,2/2] netifd, lldpd, rpcd, log: use generic service_running

Message ID 20190723102452.30621-2-ynezz@true.cz
State Superseded
Delegated to: Petr Štetiar
Headers show
Series [OpenWrt-Devel,1/2] base-files: implement generic service_running | expand

Commit Message

Petr Štetiar July 23, 2019, 10:24 a.m. UTC
commit eb204d14f75c ("base-files: implement generic service_running")
introduced generic service_running so it's not needed to copy&paste same
3 lines over and over again.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 package/network/config/netifd/files/etc/init.d/network | 5 -----
 package/network/services/lldpd/files/lldpd.init        | 4 ----
 package/system/rpcd/files/rpcd.init                    | 4 ----
 package/system/ubox/files/log.init                     | 4 ----
 4 files changed, 17 deletions(-)

Comments

Yousong Zhou July 23, 2019, 11:51 a.m. UTC | #1
On Tue, 23 Jul 2019 at 18:25, Petr Štetiar <ynezz@true.cz> wrote:
>
> commit eb204d14f75c ("base-files: implement generic service_running")
> introduced generic service_running so it's not needed to copy&paste same
> 3 lines over and over again.
>
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> ---
>  package/network/config/netifd/files/etc/init.d/network | 5 -----
>  package/network/services/lldpd/files/lldpd.init        | 4 ----
>  package/system/rpcd/files/rpcd.init                    | 4 ----
>  package/system/ubox/files/log.init                     | 4 ----
>  4 files changed, 17 deletions(-)
>
> diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
> index 2321a309a5ce..dc208c4ce0a1 100755
> --- a/package/network/config/netifd/files/etc/init.d/network
> +++ b/package/network/config/netifd/files/etc/init.d/network
> @@ -40,11 +40,6 @@ stop_service() {
>         sleep 1
>  }
>
> -service_running() {
> -       ubus -t 30 wait_for network.interface
> -       /sbin/wifi reload_legacy
> -}
> -

Likely we should keep this.  If not, a note in the commit message could help.

                yousong

>  validate_atm_bridge_section()
>  {
>         uci_validate_section network "atm-bridge" "${1}" \
> diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
> index bc429de484d3..9fb3a8255995 100644
> --- a/package/network/services/lldpd/files/lldpd.init
> +++ b/package/network/services/lldpd/files/lldpd.init
> @@ -96,10 +96,6 @@ start_service() {
>         procd_close_instance
>  }
>
> -service_running() {
> -       pgrep -x /usr/sbin/lldpd &> /dev/null
> -}
> -
>  reload_service() {
>         running || return 1
>         $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF
> diff --git a/package/system/rpcd/files/rpcd.init b/package/system/rpcd/files/rpcd.init
> index 77ebcbe6cb7b..447133c67a5a 100755
> --- a/package/system/rpcd/files/rpcd.init
> +++ b/package/system/rpcd/files/rpcd.init
> @@ -18,7 +18,3 @@ start_service() {
>  reload_service() {
>         procd_send_signal rpcd
>  }
> -
> -service_running() {
> -       procd_running rpcd
> -}
> diff --git a/package/system/ubox/files/log.init b/package/system/ubox/files/log.init
> index ba9c124c8ba6..250f805b4406 100644
> --- a/package/system/ubox/files/log.init
> +++ b/package/system/ubox/files/log.init
> @@ -96,7 +96,3 @@ start_service()
>         config_foreach validate_log_section system start_service_file
>         config_foreach validate_log_section system start_service_remote
>  }
> -
> -service_running() {
> -       procd_running log
> -}
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Petr Štetiar July 23, 2019, 12:02 p.m. UTC | #2
Yousong Zhou <yszhou4tech@gmail.com> [2019-07-23 19:51:34]:

> > -service_running() {
> > -       ubus -t 30 wait_for network.interface
> > -       /sbin/wifi reload_legacy
> > -}
> > -
> 
> Likely we should keep this.  If not, a note in the commit message could help.

It's broken anyway:

 $ /etc/init.d/network stop; service network running && echo "yes" || echo "nope"
 Command failed: Request timed out
 yes

I'll add this information to the commit message, thanks!

-- ynezz
diff mbox series

Patch

diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
index 2321a309a5ce..dc208c4ce0a1 100755
--- a/package/network/config/netifd/files/etc/init.d/network
+++ b/package/network/config/netifd/files/etc/init.d/network
@@ -40,11 +40,6 @@  stop_service() {
 	sleep 1
 }
 
-service_running() {
-	ubus -t 30 wait_for network.interface
-	/sbin/wifi reload_legacy
-}
-
 validate_atm_bridge_section()
 {
 	uci_validate_section network "atm-bridge" "${1}" \
diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
index bc429de484d3..9fb3a8255995 100644
--- a/package/network/services/lldpd/files/lldpd.init
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -96,10 +96,6 @@  start_service() {
 	procd_close_instance
 }
 
-service_running() {
-	pgrep -x /usr/sbin/lldpd &> /dev/null
-}
-
 reload_service() {
 	running || return 1
 	$LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF
diff --git a/package/system/rpcd/files/rpcd.init b/package/system/rpcd/files/rpcd.init
index 77ebcbe6cb7b..447133c67a5a 100755
--- a/package/system/rpcd/files/rpcd.init
+++ b/package/system/rpcd/files/rpcd.init
@@ -18,7 +18,3 @@  start_service() {
 reload_service() {
 	procd_send_signal rpcd
 }
-
-service_running() {
-	procd_running rpcd
-}
diff --git a/package/system/ubox/files/log.init b/package/system/ubox/files/log.init
index ba9c124c8ba6..250f805b4406 100644
--- a/package/system/ubox/files/log.init
+++ b/package/system/ubox/files/log.init
@@ -96,7 +96,3 @@  start_service()
 	config_foreach validate_log_section system start_service_file
 	config_foreach validate_log_section system start_service_remote
 }
-
-service_running() {
-	procd_running log
-}