Page MenuHomeFreeBSD

Add new switches to service(8): enable, disable, rcopts and rcdelete
ClosedPublic

Authored by allanjude on Jul 19 2014, 3:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 28, 8:02 PM
Unknown Object (File)
Tue, Nov 26, 8:03 AM
Unknown Object (File)
Sat, Nov 23, 4:54 PM
Unknown Object (File)
Nov 16 2024, 9:21 AM
Unknown Object (File)
Nov 16 2024, 6:16 AM
Unknown Object (File)
Nov 12 2024, 7:52 PM
Unknown Object (File)
Nov 8 2024, 3:59 AM
Unknown Object (File)
Nov 6 2024, 5:32 AM

Details

Summary

The patch adds new switches to service(8). This is what can be done with it:

$ service sshd rcopts
Available rc.conf options for sshd:

\#
\# sshd_enable (bool): Set to "NO" by default.
\# Set it to "YES" to enable sshd
\# sshd_rsa1_enable (bool): Set to "YES" by default.
\# Seit it to "NO" to disable rsa1 host key
\# sshd_rsa_enable (bool): Set to "YES" by default.
\# Seit it to "NO" to disable rsa host key
\# sshd_dsa_enable (bool): Set to "YES" by default.
\# Seit it to "NO" to disable dsa host key
\# sshd_ecdsa_enable (bool): Set to "YES" by default.
\# Seit it to "NO" to disable ecdsa host key

$ service sshd disable stop
sshd disabled in /etc/rc.conf
Stopping sshd.
Waiting for PIDS: 1728.

$ service sshd rcdelete
sshd deleted in /etc/rc.conf

$ service sshd enable
sshd enabled in /etc/rc.conf

$ service sshd start
Performing sanity check on sshd configuration.
Starting sshd.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 3431
Build 3470: arc lint + arc unit

Event Timeline

lme retitled this revision from to Add new switches to service(8): enable, disable, rcopts and rcdelete.
lme updated this object.
lme edited the test plan for this revision. (Show Details)
lme added reviewers: delphij, eadler.
lme updated this object.
lme edited the test plan for this revision. (Show Details)
lme edited the test plan for this revision. (Show Details)

It will be nice not to touch rc.conf but rather use /etc/rc.conf.d

I'm a bit biased on that.
One big plus for FreeBSD is that you have all service config settings in a single /etc/rc.conf file.
On the other hand there are tools like puppet and ansible which can add separate files in a /etc/rc.conf.d/ directory.
I will see how to handle this.

Here's an updated patch.

It introduces the -s flag so that instead of /etc/rc.conf /etc/rc.conf.d/$script is used.

bapt requested changes to this revision.Jul 22 2014, 3:20 PM
bapt added a reviewer: bapt.

imho the default should be to not touch /etc/rc.conf and always use rc.conf.d

This revision now requires changes to proceed.Jul 22 2014, 3:20 PM

I strictly use rc.conf.local on my systems. The rc.conf is shared among all through a config management system. If I were to disable a service on 1 I expect it to use rc.conf.local (or at least not rc.conf) because my config management will just replace rc.conf back to the global one anyhow.

does bsdconfig(8) not handle this use case?

AFAIK it cannot. At least at the time of writing the patch.

allanjude added a reviewer: lme.

I have an enhanced version of this patch for review

allanjude edited edge metadata.
allanjude updated this object.

Reimplemented some of lme@'s changes to use newer features of sysrc

Added some new features of my own (-s to get the status of all enabled services)

Depends on D3551 for sysrc -s support

Update with feedback from Pierre Pronchery (netbsd)

and a run through http://www.shellcheck.net/

I'm fine with it.

But I don't think that it is a good idea to add new functionality and change `` to $() in one step.

I'm still a bit worried about the duplication with regard to sysrc(8)…

It's not really duplicated. I find it really useful to just run "service apache24 enable start" instead of running "sysrc apache24_enable=yes; service apache24 start"

allanjude edited edge metadata.

Updated to use /etc/rc.conf unless /etc/rc.conf.d exists of CONFFILE is set

lme edited edge metadata.
allanjude edited edge metadata.
allanjude added a parent revision: D5846: Fix for ports/208534.

Integrate D5846

Depends on D5846

allanjude edited edge metadata.

Fix the variable for the filename

bapt edited edge metadata.
This revision is now accepted and ready to land.Apr 24 2016, 7:54 PM