aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/openrc-run.83
-rw-r--r--sh/runscript.sh.in6
2 files changed, 8 insertions, 1 deletions
diff --git a/man/openrc-run.8 b/man/openrc-run.8
index c8bf24d4..3308f244 100644
--- a/man/openrc-run.8
+++ b/man/openrc-run.8
@@ -120,6 +120,9 @@ Set this to "true", "yes" or "1" (case-insensitive) to force the daemon into
the background. This implies the "--make-pidfile" and "--pidfile" option of
.Xr start-stop-daemon 8
so the pidfile variable must be set.
+.It Ar chroot
+.Xr start-stop-daemon 8
+will chroot into this path before writing the pid file or starting the daemon.
.It Ar pidfile
Pidfile to use for the above defined command.
.It Ar name
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index b89c4607..06d51d07 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -142,12 +142,14 @@ start()
fi
eval start-stop-daemon --start \
--exec $command \
+ ${chroot:+--chroot} $chroot \
${procname:+--name} $procname \
${pidfile:+--pidfile} $pidfile \
$_background $start_stop_daemon_args \
-- $command_args
if eend $? "Failed to start $RC_SVCNAME"; then
service_set_value "command" "${command}"
+ [ -n "${chroot}" ] && service_set_value "chroot" "${chroot}"
[ -n "${pidfile}" ] && service_set_value "pidfile" "${pidfile}"
[ -n "${procname}" ] && service_set_value "procname" "${procname}"
return 0
@@ -163,9 +165,11 @@ start()
stop()
{
local startcommand="$(service_get_value "command")"
+ local startchroot="$(service_get_value "chroot")"
local startpidfile="$(service_get_value "pidfile")"
local startprocname="$(service_get_value "procname")"
command="${startcommand:-$command}"
+ chroot="${startchroot:-$chroot}"
pidfile="${startpidfile:-$pidfile}"
procname="${startprocname:-$procname}"
[ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0
@@ -174,7 +178,7 @@ stop()
${retry:+--retry} $retry \
${command:+--exec} $command \
${procname:+--name} $procname \
- ${pidfile:+--pidfile} $pidfile \
+ ${pidfile:+--pidfile} $chroot$pidfile \
${stopsig:+--signal} $stopsig
eend $? "Failed to stop $RC_SVCNAME"
}