Page MenuHomeFreeBSD

D40369.id.diff
No OneTemporary

D40369.id.diff

diff --git a/usr.sbin/service/service.8 b/usr.sbin/service/service.8
--- a/usr.sbin/service/service.8
+++ b/usr.sbin/service/service.8
@@ -48,6 +48,7 @@
.Nm
.Op Fl j Ar jail
.Op Fl v
+.Op Fl E Ar var=value
.Ar script
.Ar command
.Sh DESCRIPTION
@@ -67,6 +68,13 @@
.Pp
The options are as follows:
.Bl -tag -width F1
+.It Fl E Ar var=value
+Set the environment variable
+.Ar var
+to the specified
+.Ar value
+before starting the script.
+This option can be used multiple times.
.It Fl e
List services that are enabled.
The list of scripts to check is compiled using
@@ -117,6 +125,9 @@
which is how they are set in
.Pa /etc/rc
at boot time.
+If the
+.Fl E
+option is used, the corresponding variable is set accordingly.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
@@ -126,6 +137,7 @@
.Bd -literal -offset -ident
service named status
service -j dns named status
+service -E LC_ALL=C.UTF-8 named start
service -rv
.Ed
.Pp
diff --git a/usr.sbin/service/service.sh b/usr.sbin/service/service.sh
--- a/usr.sbin/service/service.sh
+++ b/usr.sbin/service/service.sh
@@ -37,21 +37,23 @@
echo "${0##*/} [-j <jail name or id>] -e"
echo "${0##*/} [-j <jail name or id>] -R"
echo "${0##*/} [-j <jail name or id>] [-v] -l | -r"
- echo "${0##*/} [-j <jail name or id>] [-v] <rc.d script> start|stop|etc."
+ echo "${0##*/} [-j <jail name or id>] [-v] [-E var=value] <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"
- echo '-r Show the results of boot time rcorder'
- echo '-v Verbose'
+ echo "-j Perform actions within the named jail"
+ echo "-E n=val Set variable n to val before executing the rc.d script"
+ 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"
+ echo '-r Show the results of boot time rcorder'
+ echo '-v Verbose'
echo ''
}
-while getopts 'j:ehlrRv' COMMAND_LINE_ARGUMENT ; do
+while getopts 'j:E:ehlrRv' COMMAND_LINE_ARGUMENT ; do
case "${COMMAND_LINE_ARGUMENT}" in
j) JAIL="${OPTARG}" ;;
+ E) VARS="${VARS} ${OPTARG}" ;;
e) ENABLED=eopt ;;
h) usage ; exit 0 ;;
l) LIST=lopt ;;
@@ -72,6 +74,9 @@
[ -n "${RCORDER}" ] && args="${args} -r"
[ -n "${RESTART}" ] && args="${args} -R"
[ -n "${VERBOSE}" ] && args="${args} -v"
+ for var in ${VARS}; do
+ args="${args} -E ${var}"
+ done
# Call jexec(8) with the rebuild args and any positional args that
# were left in $@
@@ -171,7 +176,7 @@
for dir in /etc/rc.d $local_startup; do
if [ -x "$dir/$script" ]; then
[ -n "$VERBOSE" ] && echo "$script is located in $dir"
- exec env -i -L -/daemon HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin "$dir/$script" "$@"
+ exec env -i -L -/daemon HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin ${VARS} "$dir/$script" "$@"
fi
done

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 4:10 AM (4 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14477641
Default Alt Text
D40369.id.diff (2 KB)

Event Timeline