Message ID | 20190723102452.30621-1-ynezz@true.cz |
---|---|
State | Superseded |
Delegated to: | Petr Štetiar |
Headers | show |
Series | [OpenWrt-Devel,1/2] base-files: implement generic service_running | expand |
On Tue, 23 Jul 2019 at 18:25, Petr Štetiar <ynezz@true.cz> wrote: > > DRY is good, otherwise we're going to suffer with a copy&paste disease > in the init scripts. > > Signed-off-by: Petr Štetiar <ynezz@true.cz> > --- > package/base-files/files/etc/rc.common | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common > index 75dbeedf34d4..3bd382ae27ac 100755 > --- a/package/base-files/files/etc/rc.common > +++ b/package/base-files/files/etc/rc.common > @@ -95,7 +95,11 @@ service_data() { > } > > service_running() { > - return 0 > + [ -n "$USE_PROCD" ] || return 0 These xx_service() and service_xxx() functions as commented are for procd, so no need to check for USE_PROCD here. yousong > + > + local service="${1:-$(basename $initscript)}" > + local instance="${2:-*}" > + procd_running "$service" "${instance}" "$@" > } > > ${INIT_TRACE:+set -x} > @@ -104,6 +108,9 @@ ${INIT_TRACE:+set -x} > > [ -n "$USE_PROCD" ] && { > EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace" > + EXTRA_HELP="\ > + running Check if service is running > + " > > . $IPKG_INSTROOT/lib/functions/procd.sh > basescript=$(readlink "$initscript") > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index 75dbeedf34d4..3bd382ae27ac 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -95,7 +95,11 @@ service_data() { } service_running() { - return 0 + [ -n "$USE_PROCD" ] || return 0 + + local service="${1:-$(basename $initscript)}" + local instance="${2:-*}" + procd_running "$service" "${instance}" "$@" } ${INIT_TRACE:+set -x} @@ -104,6 +108,9 @@ ${INIT_TRACE:+set -x} [ -n "$USE_PROCD" ] && { EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace" + EXTRA_HELP="\ + running Check if service is running + " . $IPKG_INSTROOT/lib/functions/procd.sh basescript=$(readlink "$initscript")
DRY is good, otherwise we're going to suffer with a copy&paste disease in the init scripts. Signed-off-by: Petr Štetiar <ynezz@true.cz> --- package/base-files/files/etc/rc.common | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)