Show only usable commands in rc.subr usage

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Show only usable commands in rc.subr usage

Vadim Zhukov
This patch makes rc.subr show only supported operations in usage.
This avoids some sort of confusion when, e.g., /etc/rc.d/smtpd
shows that "reload" command is allowed, but when you try it,
you get "reload not supported" error.

okay?

--
  WBR,
    Vadim Zhukov


Index: rc.subr
===================================================================
RCS file: /cvs/src/etc/rc.d/rc.subr,v
retrieving revision 1.68
diff -u -p -r1.68 rc.subr
--- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
+++ rc.subr 3 Apr 2013 11:35:58 -0000
@@ -25,7 +25,13 @@ rc_err() {
 }
 
 rc_usage() {
- rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
+ local _a _allsup _enotsup
+ for _a in start check reload restart stop; do
+ eval _enotsup=\${rc_${_a}}
+ [ X"${_enotsup}" != X"NO" ] && _allsup="$_allsup $_a"
+ done
+ _allsup="`echo $_allsup | sed -e 's/ /|/g'`"
+ rc_err "usage: $0 [-df] {${_allsup}}"
 }
 
 rc_write_runfile() {

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Alexander Hall-3
On 04/03/13 13:42, Vadim Zhukov wrote:
> This patch makes rc.subr show only supported operations in usage.
> This avoids some sort of confusion when, e.g., /etc/rc.d/smtpd
> shows that "reload" command is allowed, but when you try it,
> you get "reload not supported" error.
>
> okay?

I approve of the idea. Nits inline.

> --
>    WBR,
>      Vadim Zhukov
>
>
> Index: rc.subr
> ===================================================================
> RCS file: /cvs/src/etc/rc.d/rc.subr,v
> retrieving revision 1.68
> diff -u -p -r1.68 rc.subr
> --- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
> +++ rc.subr 3 Apr 2013 11:35:58 -0000
> @@ -25,7 +25,13 @@ rc_err() {
>   }
>  
>   rc_usage() {
> - rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
> + local _a _allsup _enotsup
> + for _a in start check reload restart stop; do
> + eval _enotsup=\${rc_${_a}}
> + [ X"${_enotsup}" != X"NO" ] && _allsup="$_allsup $_a"

maybe
                [ X"${_enotsup}" != X"NO" ] && _allsup="${_allsup+$_allsup|}$_a"

> + done

> + _allsup="`echo $_allsup | sed -e 's/ /|/g'`"

and skip the line above

> + rc_err "usage: $0 [-df] {${_allsup}}"
>   }
>  
>   rc_write_runfile() {
>

Also, you mix $var and ${var} notation. While I prefer the former
unless ${...} is needed for clarity or functionality, we should at
least be consequent where possible.

/Alexander

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Antoine Jacoutot-7
On Wed, Apr 03, 2013 at 05:14:10PM +0200, Alexander Hall wrote:
> On 04/03/13 13:42, Vadim Zhukov wrote:
> > This patch makes rc.subr show only supported operations in usage.
> > This avoids some sort of confusion when, e.g., /etc/rc.d/smtpd
> > shows that "reload" command is allowed, but when you try it,
> > you get "reload not supported" error.
> >
> > okay?
>
> I approve of the idea. Nits inline.

No need to check for 'check' => this is a mandatory action.
No need to check for 'restart' => it is 'start'+'stop'

> >    WBR,
> >      Vadim Zhukov
> >
> >
> > Index: rc.subr
> > ===================================================================
> > RCS file: /cvs/src/etc/rc.d/rc.subr,v
> > retrieving revision 1.68
> > diff -u -p -r1.68 rc.subr
> > --- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
> > +++ rc.subr 3 Apr 2013 11:35:58 -0000
> > @@ -25,7 +25,13 @@ rc_err() {
> >   }
> >  
> >   rc_usage() {
> > - rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
> > + local _a _allsup _enotsup
> > + for _a in start check reload restart stop; do
> > + eval _enotsup=\${rc_${_a}}
> > + [ X"${_enotsup}" != X"NO" ] && _allsup="$_allsup $_a"
>
> maybe
> [ X"${_enotsup}" != X"NO" ] && _allsup="${_allsup+$_allsup|}$_a"
>
> > + done
>
> > + _allsup="`echo $_allsup | sed -e 's/ /|/g'`"
>
> and skip the line above
>
> > + rc_err "usage: $0 [-df] {${_allsup}}"
> >   }
> >  
> >   rc_write_runfile() {
> >
>
> Also, you mix $var and ${var} notation. While I prefer the former
> unless ${...} is needed for clarity or functionality, we should at
> least be consequent where possible.
>
> /Alexander

--
Antoine

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Vadim Zhukov
03.04.2013 19:24 пользователь "Antoine Jacoutot" <[hidden email]>
написал:

>
> On Wed, Apr 03, 2013 at 05:14:10PM +0200, Alexander Hall wrote:
> > On 04/03/13 13:42, Vadim Zhukov wrote:
> > > This patch makes rc.subr show only supported operations in usage.
> > > This avoids some sort of confusion when, e.g., /etc/rc.d/smtpd
> > > shows that "reload" command is allowed, but when you try it,
> > > you get "reload not supported" error.
> > >
> > > okay?
> >
> > I approve of the idea. Nits inline.

I'll send a new diff ASAP.

> No need to check for 'check' => this is a mandatory action.
> No need to check for 'restart' => it is 'start'+'stop'

I've took logic from the rc_cmd(), it doesn't go smart either. Should it be
fixed, too? Should we add general explicit check (to rc_cmd()?) that
"check" and "restart" are not disabled?

> > >    WBR,
> > >      Vadim Zhukov
> > >
> > >
> > > Index: rc.subr
> > > ===================================================================
> > > RCS file: /cvs/src/etc/rc.d/rc.subr,v
> > > retrieving revision 1.68
> > > diff -u -p -r1.68 rc.subr
> > > --- rc.subr 19 Nov 2012 07:10:59 -0000      1.68
> > > +++ rc.subr 3 Apr 2013 11:35:58 -0000
> > > @@ -25,7 +25,13 @@ rc_err() {
> > >   }
> > >
> > >   rc_usage() {
> > > -   rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
> > > +   local _a _allsup _enotsup
> > > +   for _a in start check reload restart stop; do
> > > +           eval _enotsup=\${rc_${_a}}
> > > +           [ X"${_enotsup}" != X"NO" ] && _allsup="$_allsup $_a"
> >
> > maybe
> >               [ X"${_enotsup}" != X"NO" ] &&
_allsup="${_allsup+$_allsup|}$_a"

> >
> > > +   done
> >
> > > +   _allsup="`echo $_allsup | sed -e 's/ /|/g'`"
> >
> > and skip the line above
> >
> > > +   rc_err "usage: $0 [-df] {${_allsup}}"
> > >   }
> > >
> > >   rc_write_runfile() {
> > >
> >
> > Also, you mix $var and ${var} notation. While I prefer the former
> > unless ${...} is needed for clarity or functionality, we should at
> > least be consequent where possible.
> >
> > /Alexander
>
> --
> Antoine
Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Vadim Zhukov
In reply to this post by Vadim Zhukov
Second iteration after input from halex@ (${...+} trick is cool!).


Index: rc.subr
===================================================================
RCS file: /cvs/src/etc/rc.d/rc.subr,v
retrieving revision 1.68
diff -u -p -r1.68 rc.subr
--- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
+++ rc.subr 3 Apr 2013 15:50:32 -0000
@@ -25,7 +25,12 @@ rc_err() {
 }
 
 rc_usage() {
- rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
+ local _a _allsup _enotsup
+ for _a in start check reload restart stop; do
+ eval _enotsup=\${rc_${_a}}
+ [ X"${_enotsup}" != X"NO" ] && _allsup="${_allsup+$_allsup|}${_a}"
+ done
+ rc_err "usage: $0 [-df] {${_allsup}}"
 }
 
 rc_write_runfile() {

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Antoine Jacoutot-7
On Wed, Apr 03, 2013 at 08:17:27PM +0400, Vadim Zhukov wrote:
> Second iteration after input from halex@ (${...+} trick is cool!).

ok aja@ with nitpicks

Please sort the list this way:
start, stop, restart, reload, check

Please make the output this way:
rc_err "usage: $0 [-df] (${_allsup})"

i.e. {} -> () which is more standard imho

> Index: rc.subr
> ===================================================================
> RCS file: /cvs/src/etc/rc.d/rc.subr,v
> retrieving revision 1.68
> diff -u -p -r1.68 rc.subr
> --- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
> +++ rc.subr 3 Apr 2013 15:50:32 -0000
> @@ -25,7 +25,12 @@ rc_err() {
>  }
>  
>  rc_usage() {
> - rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
> + local _a _allsup _enotsup
> + for _a in start check reload restart stop; do
> + eval _enotsup=\${rc_${_a}}
> + [ X"${_enotsup}" != X"NO" ] && _allsup="${_allsup+$_allsup|}${_a}"
> + done
> + rc_err "usage: $0 [-df] {${_allsup}}"
>  }
>  
>  rc_write_runfile() {
>

--
Antoine

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Todd T. Fries-2
In reply to this post by Antoine Jacoutot-7
Penned by Antoine Jacoutot on 20130403 10:24.19, we have:
| On Wed, Apr 03, 2013 at 05:14:10PM +0200, Alexander Hall wrote:
| > On 04/03/13 13:42, Vadim Zhukov wrote:
| > > This patch makes rc.subr show only supported operations in usage.
| > > This avoids some sort of confusion when, e.g., /etc/rc.d/smtpd
| > > shows that "reload" command is allowed, but when you try it,
| > > you get "reload not supported" error.
| > >
| > > okay?
| >
| > I approve of the idea. Nits inline.
|
| No need to check for 'check' => this is a mandatory action.
| No need to check for 'restart' => it is 'start'+'stop'

amd does not support stop.
 
| > >    WBR,
| > >      Vadim Zhukov
| > >
| > >
| > > Index: rc.subr
| > > ===================================================================
| > > RCS file: /cvs/src/etc/rc.d/rc.subr,v
| > > retrieving revision 1.68
| > > diff -u -p -r1.68 rc.subr
| > > --- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
| > > +++ rc.subr 3 Apr 2013 11:35:58 -0000
| > > @@ -25,7 +25,13 @@ rc_err() {
| > >   }
| > >  
| > >   rc_usage() {
| > > - rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
| > > + local _a _allsup _enotsup
| > > + for _a in start check reload restart stop; do
| > > + eval _enotsup=\${rc_${_a}}
| > > + [ X"${_enotsup}" != X"NO" ] && _allsup="$_allsup $_a"
| >
| > maybe
| > [ X"${_enotsup}" != X"NO" ] && _allsup="${_allsup+$_allsup|}$_a"
| >
| > > + done
| >
| > > + _allsup="`echo $_allsup | sed -e 's/ /|/g'`"
| >
| > and skip the line above
| >
| > > + rc_err "usage: $0 [-df] {${_allsup}}"
| > >   }
| > >  
| > >   rc_write_runfile() {
| > >
| >
| > Also, you mix $var and ${var} notation. While I prefer the former
| > unless ${...} is needed for clarity or functionality, we should at
| > least be consequent where possible.
| >
| > /Alexander
|
| --
| Antoine

--
Todd Fries .. [hidden email]

 ____________________________________________
|                                            \  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC                \  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com            \  1.866.792.3418 (FAX)
| PO Box 16169, Oklahoma City, OK 73113      \  sip:[hidden email]
| "..in support of free software solutions." \  sip:[hidden email]
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                                                 
              37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
                        http://todd.fries.net/pgp.txt

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Antoine Jacoutot-7
On Wed, Apr 03, 2013 at 12:30:05PM -0500, Todd T. Fries wrote:

> Penned by Antoine Jacoutot on 20130403 10:24.19, we have:
> | On Wed, Apr 03, 2013 at 05:14:10PM +0200, Alexander Hall wrote:
> | > On 04/03/13 13:42, Vadim Zhukov wrote:
> | > > This patch makes rc.subr show only supported operations in usage.
> | > > This avoids some sort of confusion when, e.g., /etc/rc.d/smtpd
> | > > shows that "reload" command is allowed, but when you try it,
> | > > you get "reload not supported" error.
> | > >
> | > > okay?
> | >
> | > I approve of the idea. Nits inline.
> |
> | No need to check for 'check' => this is a mandatory action.
> | No need to check for 'restart' => it is 'start'+'stop'
>
> amd does not support stop.

What does it have to do with anything? :)


>  
> | > >    WBR,
> | > >      Vadim Zhukov
> | > >
> | > >
> | > > Index: rc.subr
> | > > ===================================================================
> | > > RCS file: /cvs/src/etc/rc.d/rc.subr,v
> | > > retrieving revision 1.68
> | > > diff -u -p -r1.68 rc.subr
> | > > --- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
> | > > +++ rc.subr 3 Apr 2013 11:35:58 -0000
> | > > @@ -25,7 +25,13 @@ rc_err() {
> | > >   }
> | > >  
> | > >   rc_usage() {
> | > > - rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
> | > > + local _a _allsup _enotsup
> | > > + for _a in start check reload restart stop; do
> | > > + eval _enotsup=\${rc_${_a}}
> | > > + [ X"${_enotsup}" != X"NO" ] && _allsup="$_allsup $_a"
> | >
> | > maybe
> | > [ X"${_enotsup}" != X"NO" ] && _allsup="${_allsup+$_allsup|}$_a"
> | >
> | > > + done
> | >
> | > > + _allsup="`echo $_allsup | sed -e 's/ /|/g'`"
> | >
> | > and skip the line above
> | >
> | > > + rc_err "usage: $0 [-df] {${_allsup}}"
> | > >   }
> | > >  
> | > >   rc_write_runfile() {
> | > >
> | >
> | > Also, you mix $var and ${var} notation. While I prefer the former
> | > unless ${...} is needed for clarity or functionality, we should at
> | > least be consequent where possible.
> | >
> | > /Alexander
> |
> | --
> | Antoine
>
> --
> Todd Fries .. [hidden email]
>
>  ____________________________________________
> |                                            \  1.636.410.0632 (voice)
> | Free Daemon Consulting, LLC                \  1.405.227.9094 (voice)
> | http://FreeDaemonConsulting.com            \  1.866.792.3418 (FAX)
> | PO Box 16169, Oklahoma City, OK 73113      \  sip:[hidden email]
> | "..in support of free software solutions." \  sip:[hidden email]
>  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
>                                                  
>               37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
>                         http://todd.fries.net/pgp.txt
>

--
Antoine

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Vadim Zhukov
In reply to this post by Todd T. Fries-2
03.04.2013 21:30 пользователь "Todd T. Fries" <[hidden email]> написал:

>
> Penned by Antoine Jacoutot on 20130403 10:24.19, we have:
> | On Wed, Apr 03, 2013 at 05:14:10PM +0200, Alexander Hall wrote:
> | > On 04/03/13 13:42, Vadim Zhukov wrote:
> | > > This patch makes rc.subr show only supported operations in usage.
> | > > This avoids some sort of confusion when, e.g., /etc/rc.d/smtpd
> | > > shows that "reload" command is allowed, but when you try it,
> | > > you get "reload not supported" error.
> | > >
> | > > okay?
> | >
> | > I approve of the idea. Nits inline.
> |
> | No need to check for 'check' => this is a mandatory action.
> | No need to check for 'restart' => it is 'start'+'stop'
>
> amd does not support stop.

Good point. New diff is on the way.

> | > >    WBR,
> | > >      Vadim Zhukov
> | > >
> | > >
> | > > Index: rc.subr
> | > > ===================================================================
> | > > RCS file: /cvs/src/etc/rc.d/rc.subr,v
> | > > retrieving revision 1.68
> | > > diff -u -p -r1.68 rc.subr
> | > > --- rc.subr       19 Nov 2012 07:10:59 -0000      1.68
> | > > +++ rc.subr       3 Apr 2013 11:35:58 -0000
> | > > @@ -25,7 +25,13 @@ rc_err() {
> | > >   }
> | > >
> | > >   rc_usage() {
> | > > - rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
> | > > + local _a _allsup _enotsup
> | > > + for _a in start check reload restart stop; do
> | > > +         eval _enotsup=\${rc_${_a}}
> | > > +         [ X"${_enotsup}" != X"NO" ] && _allsup="$_allsup $_a"
> | >
> | > maybe
> | >             [ X"${_enotsup}" != X"NO" ] &&
_allsup="${_allsup+$_allsup|}$_a"

> | >
> | > > + done
> | >
> | > > + _allsup="`echo $_allsup | sed -e 's/ /|/g'`"
> | >
> | > and skip the line above
> | >
> | > > + rc_err "usage: $0 [-df] {${_allsup}}"
> | > >   }
> | > >
> | > >   rc_write_runfile() {
> | > >
> | >
> | > Also, you mix $var and ${var} notation. While I prefer the former
> | > unless ${...} is needed for clarity or functionality, we should at
> | > least be consequent where possible.
> | >
> | > /Alexander
> |
> | --
> | Antoine
>
> --
> Todd Fries .. [hidden email]
>
>  ____________________________________________
> |                                            \  1.636.410.0632 (voice)
> | Free Daemon Consulting, LLC                \  1.405.227.9094 (voice)
> | http://FreeDaemonConsulting.com            \  1.866.792.3418 (FAX)
> | PO Box 16169, Oklahoma City, OK 73113      \  sip:[hidden email]
> | "..in support of free software solutions." \  sip:[hidden email]
>  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
>
>               37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
>                         http://todd.fries.net/pgp.txt
Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Vadim Zhukov
In reply to this post by Vadim Zhukov
Third iteration, after input from ajacoutot@, todd@ and marc@.

Now rc_restart becomes unavailable if either start or stop is disabled.


Index: rc.subr
===================================================================
RCS file: /cvs/src/etc/rc.d/rc.subr,v
retrieving revision 1.68
diff -u -p -r1.68 rc.subr
--- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
+++ rc.subr 3 Apr 2013 17:55:00 -0000
@@ -24,8 +24,18 @@ rc_err() {
  exit 1
 }
 
+rc_is_supported() {
+ local _enotsup
+ eval _enotsup=\${rc_${1}}
+ [ X"${_enotsup}" != X"NO" ]
+}
+
 rc_usage() {
- rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
+ local _a _allsup
+ for _a in start stop restart reload check; do
+ rc_is_supported ${_a} && _allsup="${_allsup:+$_allsup|}${_a}"
+ done
+ rc_err "usage: $0 [-df] (${_allsup})"
 }
 
 rc_write_runfile() {
@@ -95,14 +105,17 @@ rc_wait() {
 }
 
 rc_cmd() {
- local _bg _enotsup _n
+ local _bg _n
 
  [ "$(id -u)" -eq 0 ] || \
  [ X"${rc_usercheck}" != X"NO" -a X"$1" = "Xcheck" ] || \
  rc_err "$0: need root privileges"
 
- eval _enotsup=\${rc_${1}}
- if [ X"${_enotsup}" = X"NO" ]; then
+ if ! (rc_is_supported start && rc_is_supported stop); then
+ rc_restart=NO
+ fi
+
+ if ! rc_is_supported $1; then
  [ -n "${INRC}" ] && exit 1
  rc_err "$0: $1 is not supported"
  fi

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Alexander Hall


Vadim Zhukov <[hidden email]> wrote:

>Third iteration, after input from ajacoutot@, todd@ and marc@.
>
>Now rc_restart becomes unavailable if either start or stop is disabled.
>
>
>Index: rc.subr
>===================================================================
>RCS file: /cvs/src/etc/rc.d/rc.subr,v
>retrieving revision 1.68
>diff -u -p -r1.68 rc.subr
>--- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
>+++ rc.subr 3 Apr 2013 17:55:00 -0000
>@@ -24,8 +24,18 @@ rc_err() {
> exit 1
> }
>
>+rc_is_supported() {
>+ local _enotsup
>+ eval _enotsup=\${rc_${1}}

${1} just hurts my eyes too much... :-)

Bikeshedding my way. Tin roof.

/A

>+ [ X"${_enotsup}" != X"NO" ]
>+}
>+
> rc_usage() {
>- rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
>+ local _a _allsup
>+ for _a in start stop restart reload check; do
>+ rc_is_supported ${_a} && _allsup="${_allsup:+$_allsup|}${_a}"
>+ done
>+ rc_err "usage: $0 [-df] (${_allsup})"
> }
>
> rc_write_runfile() {
>@@ -95,14 +105,17 @@ rc_wait() {
> }
>
> rc_cmd() {
>- local _bg _enotsup _n
>+ local _bg _n
>
> [ "$(id -u)" -eq 0 ] || \
> [ X"${rc_usercheck}" != X"NO" -a X"$1" = "Xcheck" ] || \
> rc_err "$0: need root privileges"
>
>- eval _enotsup=\${rc_${1}}
>- if [ X"${_enotsup}" = X"NO" ]; then
>+ if ! (rc_is_supported start && rc_is_supported stop); then
>+ rc_restart=NO
>+ fi
>+
>+ if ! rc_is_supported $1; then
> [ -n "${INRC}" ] && exit 1
> rc_err "$0: $1 is not supported"
> fi

Reply | Threaded
Open this post in threaded view
|

Re: Show only usable commands in rc.subr usage

Todd T. Fries-3
In reply to this post by Vadim Zhukov
This makes a lot of sense to me.

Penned by Vadim Zhukov on 20130403 12:59.08, we have:
| Third iteration, after input from ajacoutot@, todd@ and marc@.
|
| Now rc_restart becomes unavailable if either start or stop is disabled.
|
|
| Index: rc.subr
| ===================================================================
| RCS file: /cvs/src/etc/rc.d/rc.subr,v
| retrieving revision 1.68
| diff -u -p -r1.68 rc.subr
| --- rc.subr 19 Nov 2012 07:10:59 -0000 1.68
| +++ rc.subr 3 Apr 2013 17:55:00 -0000
| @@ -24,8 +24,18 @@ rc_err() {
|   exit 1
|  }
|  
| +rc_is_supported() {
| + local _enotsup
| + eval _enotsup=\${rc_${1}}
| + [ X"${_enotsup}" != X"NO" ]
| +}
| +
|  rc_usage() {
| - rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
| + local _a _allsup
| + for _a in start stop restart reload check; do
| + rc_is_supported ${_a} && _allsup="${_allsup:+$_allsup|}${_a}"
| + done
| + rc_err "usage: $0 [-df] (${_allsup})"
|  }
|  
|  rc_write_runfile() {
| @@ -95,14 +105,17 @@ rc_wait() {
|  }
|  
|  rc_cmd() {
| - local _bg _enotsup _n
| + local _bg _n
|  
|   [ "$(id -u)" -eq 0 ] || \
|   [ X"${rc_usercheck}" != X"NO" -a X"$1" = "Xcheck" ] || \
|   rc_err "$0: need root privileges"
|  
| - eval _enotsup=\${rc_${1}}
| - if [ X"${_enotsup}" = X"NO" ]; then
| + if ! (rc_is_supported start && rc_is_supported stop); then
| + rc_restart=NO
| + fi
| +
| + if ! rc_is_supported $1; then
|   [ -n "${INRC}" ] && exit 1
|   rc_err "$0: $1 is not supported"
|   fi

--
Todd Fries .. [hidden email]

 ____________________________________________
|                                            \  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC                \  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com            \  1.866.792.3418 (FAX)
| PO Box 16169, Oklahoma City, OK 73113      \  sip:[hidden email]
| "..in support of free software solutions." \  sip:[hidden email]
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                                                 
              37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
                        http://todd.fries.net/pgp.txt