On 2021/10/22 12:56, Stuart Henderson wrote:
> On 2021/10/22 12:20, Antoine Jacoutot wrote:
> > 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.
> 
> I hate the name but every other idea I had was worse :)

Ingo had a nice suggestion:

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     22 Oct 2021 18:26:40 -0000
@@ -36,7 +36,7 @@
 .Nm rcctl
 .Cm ls
 .Sm off
-.Cm all | failed | on | off | started | stopped
+.Cm all | failed | on | off | rogue | started | stopped
 .Sm on
 .Sh DESCRIPTION
 The
@@ -123,6 +123,8 @@ enabled but stopped daemons
 disabled services and daemons
 .It Cm on
 enabled services and daemons
+.It Cm rogue
+services and daemons which are disabled but currently running
 .It Cm started
 running daemons
 .It Cm stopped
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    22 Oct 2021 18:26:40 -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|rogue|started|stopped"
 }
 
 needs_root()
@@ -228,6 +228,13 @@ svc_ls()
                                unset _on
                        done
                        ;;
+               rogue)
+                       for _svc in $(svc_ls off); do
+                               ! svc_is_special ${_svc} && \
+                                       /etc/rc.d/${_svc} check >/dev/null && \
+                                       echo ${_svc} && _ret=1
+                       done
+                       ;;
                started|stopped)
                        for _svc in $(ls_rcscripts); do
                                /etc/rc.d/${_svc} check >/dev/null && _started=1
@@ -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|rogue|started|stopped) ]] || 
usage
                ;;
        order)
                shift 1

Reply via email to