Bug 255115 - Allow service(8) to run rc.d scripts without arguments
Summary: Allow service(8) to run rc.d scripts without arguments
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mateusz Piotrowski
URL: https://reviews.freebsd.org/D47328
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-16 10:59 UTC by sd
Modified: 2025-05-09 15:00 UTC (History)
5 users (show)

See Also:


Attachments
patch (649 bytes, patch)
2021-04-16 10:59 UTC, sd
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sd 2021-04-16 10:59:00 UTC
Created attachment 224157 [details]
patch

Current service(8) shows help message when running script without arguments (e.g. service motd). At the same time rc.d scripts allow no arguments and show script usage and their commands:
# /etc/rc.d/motd
Usage: /etc/rc.d/motd [fast|force|one|quiet](start|stop|restart|rcvar|enable|disable|delete|enabled|describe|extracommands)

It's quite useful when you want to see possible arguments for some service.
Comment 1 Mateusz Piotrowski freebsd_committer freebsd_triage 2022-07-26 15:03:06 UTC
That's a neat idea. I don't see any problems with this change.
Comment 2 Lars Engels freebsd_committer freebsd_triage 2022-08-01 09:45:16 UTC
Yes please. This is a welcome change.
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-05-09 14:59:36 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7ffedfe14ca85aa3474980092a732d4e49309c62

commit 7ffedfe14ca85aa3474980092a732d4e49309c62
Author:     sd@mostnet.ru <sd@mostnet.ru>
AuthorDate: 2025-05-09 14:48:27 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2025-05-09 14:56:58 +0000

    service(8): Allow for passing no arguments to the service script

    Currently, service(8) requires the user to provide a command to the
    rc service script. For example,

        service cron

    does not even run the cron rc service script but
    instead shows the usage message of service(8).

    This patch makes it so running the rc service script with no arguments
    via service(8) is closer to running the rc service script directly
    (e.g., /etc/rc.d/cron).

    Long story short, for most of the rc service scripts this change means
    that running "service FOO" now shows the usage message of FOO instead of
    the usage message of service(8).

    PR:             255115
    Reviewed by:    bnovkov, christos, imp, lme, markj
    Approved by:    bnovkov (mentor), christos (mentor), markj (mentor)
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D47328

 usr.sbin/service/service.8  | 4 ++--
 usr.sbin/service/service.sh | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 4 Mateusz Piotrowski freebsd_committer freebsd_triage 2025-05-09 15:00:43 UTC
Thanks!