FreeBSD Bugzilla – Attachment 187586 Details for
Bug 223325
usr.sbin/service: Add support for interacting with services in jails.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Add jails support to /usr/sbin/service and update man page.
usr.sbin-service.jails_support.diff (text/plain), 2.81 KB, created by
David O'Rourke
on 2017-10-30 16:32:12 UTC
(
hide
)
Description:
Add jails support to /usr/sbin/service and update man page.
Filename:
MIME Type:
Creator:
David O'Rourke
Created:
2017-10-30 16:32:12 UTC
Size:
2.81 KB
patch
obsolete
>diff --git a/usr.sbin/service/service.8 b/usr.sbin/service/service.8 >index 81d24a035c4..da4659c1d7b 100644 >--- a/usr.sbin/service/service.8 >+++ b/usr.sbin/service/service.8 >@@ -32,13 +32,17 @@ > .Nd "control (start/stop/etc.) or list system services" > .Sh SYNOPSIS > .Nm >+.Op Fl j Ao jail Ac > .Fl e > .Nm >+.Op Fl j Ao jail Ac > .Fl R > .Nm >+.Op Fl j Ao jail Ac > .Op Fl v > .Fl l | r > .Nm >+.Op Fl j Ao jail Ac > .Op Fl v > .Ar <rc.d script> start|stop|etc. > .Sh DESCRIPTION >@@ -54,6 +58,8 @@ the scripts using various criteria. > .Pp > The options are as follows: > .Bl -tag -width F1 >+.It Fl j Ao jail Ac >+Perform the given actions under the named jail. > .It Fl e > List services that are enabled. > The list of scripts to check is compiled using >@@ -107,6 +113,7 @@ The following are examples of typical usage of the > command: > .Pp > .Dl "service named status" >+.Dl "service -j dns named status" > .Dl "service -rv" > .Pp > The following programmable completion entry can be use in >diff --git a/usr.sbin/service/service.sh b/usr.sbin/service/service.sh >index 7aaecff3b25..8f32e9ace21 100755 >--- a/usr.sbin/service/service.sh >+++ b/usr.sbin/service/service.sh >@@ -32,12 +32,13 @@ load_rc_config 'XXX' > usage () { > echo '' > echo 'Usage:' >- echo "${0##*/} -e" >- echo "${0##*/} -R" >- echo "${0##*/} [-v] -l | -r" >- echo "${0##*/} [-v] <rc.d script> start|stop|etc." >+ echo "${0##*/} [-j jail] -e" >+ echo "${0##*/} [-j jail] -R" >+ echo "${0##*/} [-j jail] [-v] -l | -r" >+ echo "${0##*/} [-j jail] [-v] <rc.d script> start|stop|etc." > echo "${0##*/} -h" > echo '' >+ echo "-j Perform actions within the named jail" > echo '-e Show services that are enabled' > echo "-R Stop and start enabled $local_startup services" > echo "-l List all scripts in /etc/rc.d and $local_startup" >@@ -46,6 +47,32 @@ usage () { > echo '' > } > >+# Only deal with the -j option here. If found, JAIL is set and the opt and >+# arg are shifted out. OPTIND is left untouched. >+while getopts 'jehlrRv' COMMAND_LINE_ARGUMENT ; do >+ case "${COMMAND_LINE_ARGUMENT}" in >+ j) JAIL="$2" ; shift ; shift ;; >+ esac >+done >+ >+# If -j was provided, then we pass everthing along to the jexec command >+# and execute `service` within the named JAIL. Provided that the jail >+# actually exists, as checked by `jls`. >+# We do this so that if the jail does exist, we can then return the exit >+# code of `jexec` and it should be the exit code of whatever ran in the jail. >+# There is a race condition here in that the jail might exist at `jls` time >+# and be gone by `jexec` time, but it shouldn't be a big deal. >+if [ -n "$JAIL" ]; then >+ /usr/sbin/jls -j "$JAIL" 2>/dev/null >/dev/null >+ if [ $? -ne 0 ]; then >+ echo "Jail '$JAIL' does not exist." >+ exit 1 >+ fi >+ >+ /usr/sbin/jexec -l "$JAIL" /usr/sbin/service $* >+ exit $? >+fi >+ > while getopts 'ehlrRv' COMMAND_LINE_ARGUMENT ; do > case "${COMMAND_LINE_ARGUMENT}" in > e) ENABLED=eopt ;;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 223325
: 187586