The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=25fca243f2b7ca0c523aa1cf26aaea25035e68d2

commit 25fca243f2b7ca0c523aa1cf26aaea25035e68d2
Author:     Dag-Erling Smørgrav <d...@freebsd.org>
AuthorDate: 2025-08-02 23:59:26 +0000
Commit:     Dag-Erling Smørgrav <d...@freebsd.org>
CommitDate: 2025-08-02 23:59:26 +0000

    service: Add an option to enable debugging
    
    * Add and document a -d option which enables rc script debugging.
    * Sort and document existing options correctly.
    
    MFC after:      1 week
    Reviewed by:    imp, emaste
    Differential Revision:  https://reviews.freebsd.org/D51700
---
 usr.sbin/service/service.8  | 13 ++++++++-----
 usr.sbin/service/service.sh | 19 +++++++++++++------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/usr.sbin/service/service.8 b/usr.sbin/service/service.8
index 06f8cd989bfc..3858e608b785 100644
--- a/usr.sbin/service/service.8
+++ b/usr.sbin/service/service.8
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 9, 2025
+.Dd August 2, 2025
 .Dt SERVICE 8
 .Os
 .Sh NAME
@@ -34,6 +34,7 @@
 .Fl e
 .Nm
 .Op Fl j Ar jail
+.Op Fl q
 .Fl R
 .Nm
 .Op Fl j Ar jail
@@ -45,8 +46,7 @@
 .Fl r
 .Nm
 .Op Fl j Ar jail
-.Op Fl q
-.Op Fl v
+.Op Fl dqv
 .Op Fl E Ar var=value
 .Ar script
 .Op Ar command
@@ -74,6 +74,8 @@ scripts, see
 .Pp
 The options are as follows:
 .Bl -tag -width F1
+.It Fl d
+Enable debugging.
 .It Fl E Ar var=value
 Set the environment variable
 .Ar var
@@ -106,6 +108,9 @@ this is usually
 .Pa /usr/local/etc/rc.d .
 All files will be listed whether they are an actual
 rc.d script or not.
+.It Fl q
+Be quiet, redirecting output to
+.Pa /dev/null .
 .It Fl R
 Restart all enabled local services.
 .It Fl r
@@ -116,8 +121,6 @@ as in
 above, but list all of the files, not just what is enabled.
 .It Fl v
 Be slightly more verbose.
-.It Fl q
-Be quiet, redirecting output to /dev/null.
 .El
 .Sh ENVIRONMENT
 When used to run rc.d scripts the
diff --git a/usr.sbin/service/service.sh b/usr.sbin/service/service.sh
index 5f456418da49..9387a49051d6 100755
--- a/usr.sbin/service/service.sh
+++ b/usr.sbin/service/service.sh
@@ -27,17 +27,19 @@
 #  SUCH DAMAGE.
 
 . /etc/rc.subr
-load_rc_config 'XXX'
+load_rc_config
 
 usage () {
        echo ''
        echo 'Usage:'
        echo "${0##*/} [-j <jail name or id>] -e"
-       echo "${0##*/} [-j <jail name or id>] -R"
-       echo "${0##*/} [-j <jail name or id>] [-v] -l | -r"
-       echo "${0##*/} [-j <jail name or id>] [-v] [-E var=value] <rc.d script> 
start|stop|etc."
+       echo "${0##*/} [-j <jail name or id>] [-q] -R"
+       echo "${0##*/} [-j <jail name or id>] [-v] -l"
+       echo "${0##*/} [-j <jail name or id>] [-v] -r"
+       echo "${0##*/} [-j <jail name or id>] [-dqv] [-E var=value] <rc.d 
script> start|stop|etc."
        echo "${0##*/} -h"
        echo ''
+       echo "-d                Enable debugging of rc.d scripts"
        echo "-j                Perform actions within the named jail"
        echo "-E n=val  Set variable n to val before executing the rc.d script"
        echo '-e                Show services that are enabled'
@@ -49,12 +51,13 @@ usage () {
        echo ''
 }
 
-while getopts 'j:E:ehlqrRv' COMMAND_LINE_ARGUMENT ; do
+while getopts 'dE:ehj:lqrRv' COMMAND_LINE_ARGUMENT ; do
        case "${COMMAND_LINE_ARGUMENT}" in
-       j)      JAIL="${OPTARG}" ;;
+       d)      DEBUG=dopt ;;
        E)      VARS="${VARS} ${OPTARG}" ;;
        e)      ENABLED=eopt ;;
        h)      usage ; exit 0 ;;
+       j)      JAIL="${OPTARG}" ;;
        l)      LIST=lopt ;;
        q)      QUIET=qopt ;;
        r)      RCORDER=ropt ;;
@@ -85,6 +88,10 @@ if [ -n "${JAIL}" ]; then
        exit $?
 fi
 
+if [ -n "$DEBUG" ]; then
+       VARS="${VARS} rc_debug=yes"
+fi
+
 if [ -n "$RESTART" ]; then
        skip="-s nostart"
        if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then

Reply via email to