[Bug 223325] usr.sbin/service: Add support for interacting with services in jails.

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Oct 30 16:32:13 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223325

            Bug ID: 223325
           Summary: usr.sbin/service: Add support for interacting with
                    services in jails.
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: dor.bsd at xm0.uk

Created attachment 187586
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=187586&action=edit
Add jails support to /usr/sbin/service and update man page.

This patch adds support to `/usr/sbin/service` for interacting with services
within jails.

This is mostly useful when upgrading services within jails as it allows users
to stay within the usual flow and tools for upgrading packages and restarting
services.
I've been using this patch for a while now personally and everything seems to
work as intended.

Consider the following when operating on the jail host, this is the usual flow
when some services are updated:

---
# Upgrade all packages
pkg upgrade

# Restart a service that needs it
service named restart
---

If named is within a jail, the flow changes in an inconsistent way.

---
# Upgrade all packages within the dns jail
pkg -j dns upgrade

# Restart the named service within the dns jail.
# Just one of many, perhaps ezjail-admin or some other tool was used to execute
# commands within the jail.
jexec dns service named restart
---

With this patch, users can stay within the more familiar workflow of just using
the pkg and service utilities.

---
# Upgrade all packages within the dns jail.
pkg -j dns upgrade

# Restart the named service within the dns jail.
service -j dns named restart
---

The man page was updated to reflect this change and is included in the diff.

The patch to `service.sh` includes comments on was is happening around the -j
option, as we end up parsing the options twice.
The first time we check for `-j` and use it if we find it, the second time is
parsing the rest of the `service` arguments.
There may be a better way of achieving this, but my shell scripting is rusty.

-David

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list