Page MenuHomeFreeBSD

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

Authored by allanjude on Jul 19 2014, 3:52 PM.

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

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

lme updated this revision to Diff 773.Jul 19 2014, 3:52 PM
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 updated this object.Jul 19 2014, 4:00 PM
lme edited the test plan for this revision. (Show Details)
lme updated this object.Jul 19 2014, 4:07 PM
bapt added a subscriber: bapt.Jul 19 2014, 7:17 PM

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

lme added a comment.Jul 20 2014, 6:07 PM

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.

lme updated this revision to Diff 787.Jul 21 2014, 3:44 PM

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.

eadler edited edge metadata.Jun 6 2015, 5:17 AM

does bsdconfig(8) not handle this use case?

lme added a comment.Jun 7 2015, 7:08 PM

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

allanjude edited edge metadata.Aug 27 2015, 9:35 PM
allanjude added a subscriber: allanjude.
allanjude commandeered this revision.Sep 9 2015, 4:53 AM
allanjude added a reviewer: lme.

I have an enhanced version of this patch for review

allanjude updated this revision to Diff 8617.EditedSep 9 2015, 5:16 AM
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

allanjude updated this revision to Diff 8630.Sep 10 2015, 12:28 AM

Update with feedback from Pierre Pronchery (netbsd)

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

lme edited edge metadata.Sep 28 2015, 9:17 AM

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.

roberto added a subscriber: roberto.Nov 4 2015, 1:07 PM

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

lme added a comment.Nov 6 2015, 5:19 PM

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 updated this revision to Diff 15553.Apr 24 2016, 12:02 PM
allanjude edited edge metadata.

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

allanjude updated this revision to Diff 15554.Apr 24 2016, 12:18 PM
allanjude edited edge metadata.

Sync

lme accepted this revision.Apr 24 2016, 12:32 PM
lme edited edge metadata.
allanjude updated this revision to Diff 15556.Apr 24 2016, 12:57 PM
allanjude edited edge metadata.
allanjude added a parent revision: D5846: Fix for ports/208534.

Integrate D5846

Depends on D5846

allanjude updated this revision to Diff 15558.Apr 24 2016, 1:21 PM
allanjude edited edge metadata.

Fix the variable for the filename

roberto accepted this revision.Apr 24 2016, 2:24 PM
roberto added a reviewer: roberto.
bapt accepted this revision.Apr 24 2016, 7:54 PM
bapt edited edge metadata.
This revision is now accepted and ready to land.Apr 24 2016, 7:54 PM
lme added a comment.May 30 2017, 3:05 PM

Could someone commit this?

lme closed this revision.Sep 10 2018, 7:47 PM

A new version of this patch is created as https://reviews.freebsd.org/D17113