[OpenWrt-Devel] [PATCH] base-files: add list-enabled/disabled to service function in /etc/profile

Michael Jones mike at meshplusplus.com
Wed Jun 3 14:33:51 EDT 2020


On Wed, Jun 3, 2020 at 6:42 AM Stan Grishin <stangri at melmac.net> wrote:

> Implement service list-enabled and service list-disabled to provide an
> easy way
> for users to list enabled/disabled services from CLI.
>
> Signed-off-by: Stan Grishin <stangri at melmac.net>
> ---
>  package/base-files/files/etc/profile | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/package/base-files/files/etc/profile
> b/package/base-files/files/etc/profile
> index 0beff1608f..e8350cfd6a 100644
> --- a/package/base-files/files/etc/profile
> +++ b/package/base-files/files/etc/profile
> @@ -38,3 +38,24 @@ in order to prevent unauthorized SSH logins.
>  --------------------------------------------------
>  EOF
>  fi
> +
> +service() {
> +        if [ "$1" = "list-enabled" ]; then
> +                for F in /etc/init.d/* ; do
> +                        $F enabled && echo "$F enabled"
> +                done;
> +        elif [ "$1" = "list-disabled" ]; then
> +                for F in /etc/init.d/* ; do
> +                        $F enabled || echo "$F disabled"
> +                done;
> +        elif [ -f "/etc/init.d/$1" ]; then
> +                /etc/init.d/$@
> +        else
> +                echo "Usage: service
> list-disabled|list-enabled|<service> [command]"
> +                if [ -n "$1" ]; then
> +                        echo "service "'"'"$1"'"'" not found, the
> following services are available:"
> +                        ls "/etc/init.d"
> +                fi
> +                return 1
> +        fi
> +}
> --
> 2.25.1
>
>
Could you provide examples of how this would be used?

What about "list-start" and "list-stop" as well?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20200603/168ff082/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list