On Thu, Oct 21, 2021 at 04:45:47PM +0100, Stuart Henderson wrote:
> Sometimes I find it useful to list daemons which are set to 'disabled'
> but are actually running. Either those where I have started them by hand
> forgotten to enable in rc.conf.local, or to check for services which
> shouldn't be running but which are anyway. Any comments on this diff
> to add it to rcctl? It's pretty much the opposite of "rcctl ls failed".

Hi.

I have never had a use for this, so I don't really have an opinion...
I am not super fan of the "off-but-started" option name though.


> 
> Index: rcctl.8
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rcctl/rcctl.8,v
> retrieving revision 1.37
> diff -u -p -r1.37 rcctl.8
> --- rcctl.8   26 Jun 2021 18:02:48 -0000      1.37
> +++ rcctl.8   21 Oct 2021 15:42:13 -0000
> @@ -36,7 +36,7 @@
>  .Nm rcctl
>  .Cm ls
>  .Sm off
> -.Cm all | failed | on | off | started | stopped
> +.Cm all | failed | on | off | started | stopped | off-but-started
>  .Sm on
>  .Sh DESCRIPTION
>  The
> @@ -119,6 +119,8 @@ which can be one of:
>  all services and daemons
>  .It Cm failed
>  enabled but stopped daemons
> +.It Cm off-but-started
> +services and daemons which are disabled but currently running
>  .It Cm off
>  disabled services and daemons
>  .It Cm on
> Index: rcctl.sh
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rcctl/rcctl.sh,v
> retrieving revision 1.110
> diff -u -p -r1.110 rcctl.sh
> --- rcctl.sh  27 Feb 2021 09:28:04 -0000      1.110
> +++ rcctl.sh  21 Oct 2021 15:42:13 -0000
> @@ -35,7 +35,7 @@ usage()
>       "usage: rcctl get|getdef|set service | daemon [variable [arguments]]
>       rcctl [-df] ${_a} daemon ...
>       rcctl disable|enable|order [daemon ...]
> -     rcctl ls all|failed|off|on|started|stopped"
> +     rcctl ls all|failed|off|on|started|stopped|off-but-started"
>  }
>  
>  needs_root()
> @@ -212,6 +212,13 @@ svc_ls()
>                               echo ${_special_svcs} | tr "[:blank:]" "\n"
>                       ) | sort
>                       ;;
> +             off-but-started)
> +                     for _svc in $(svc_ls off); do
> +                             ! svc_is_special ${_svc} && \
> +                                     /etc/rc.d/${_svc} check >/dev/null && \
> +                                     echo ${_svc} && _ret=1
> +                     done
> +                     ;;
>               failed)
>                       for _svc in $(svc_ls on); do
>                               ! svc_is_special ${_svc} && \
> @@ -502,7 +509,7 @@ ret=0
>  case ${action} in
>       ls)
>               lsarg=$2
> -             [[ ${lsarg} == @(all|failed|off|on|started|stopped) ]] || usage
> +             [[ ${lsarg} == 
> @(all|failed|off|on|started|stopped|off-but-started) ]] || usage
>               ;;
>       order)
>               shift 1
> 

-- 
Antoine

Reply via email to