Compare commits
19 Commits
openrc-0.4
...
openrc-0.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0298e4ffa0 | ||
|
|
a063035b37 | ||
|
|
213cef1739 | ||
|
|
386ee57432 | ||
|
|
631acff7aa | ||
|
|
877a328179 | ||
|
|
1efa64cae8 | ||
|
|
22959c3963 | ||
|
|
2464f9e93b | ||
|
|
d91201cb94 | ||
|
|
1c5ec9d161 | ||
|
|
f4b8366942 | ||
|
|
438665357b | ||
|
|
7ad40abf64 | ||
|
|
7e12abe035 | ||
|
|
4dba5b1ff1 | ||
|
|
1ff289e305 | ||
|
|
53e2bec385 | ||
|
|
9d9f17aa52 |
2
Makefile
2
Makefile
@@ -3,7 +3,7 @@
|
|||||||
# All rights reserved. Released under the 2-clause BSD license.
|
# All rights reserved. Released under the 2-clause BSD license.
|
||||||
|
|
||||||
NAME= openrc
|
NAME= openrc
|
||||||
VERSION= 0.4.0
|
VERSION= 0.4.1
|
||||||
PKG= ${NAME}-${VERSION}
|
PKG= ${NAME}-${VERSION}
|
||||||
|
|
||||||
SUBDIR= conf.d doc etc init.d man net sh src
|
SUBDIR= conf.d doc etc init.d man net sh src
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ description="Set the dmesg level for a cleaner boot"
|
|||||||
depend()
|
depend()
|
||||||
{
|
{
|
||||||
before dev modules
|
before dev modules
|
||||||
|
keyword novserver
|
||||||
}
|
}
|
||||||
|
|
||||||
start()
|
start()
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ _reboot() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_forcefsck()
|
||||||
|
{
|
||||||
|
[ -e /forcefsck ] || get_bootparam forcefsck
|
||||||
|
}
|
||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
local fsck_opts= p= check_extra=
|
local fsck_opts= p= check_extra=
|
||||||
@@ -33,7 +38,7 @@ start()
|
|||||||
ewarn "Skipping fsck due to /fastboot"
|
ewarn "Skipping fsck due to /fastboot"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ -e /forcefsck ] || get_bootparam forcefsck; then
|
if _forcefsck; then
|
||||||
fsck_opts="${fsck_opts} -f"
|
fsck_opts="${fsck_opts} -f"
|
||||||
check_extra="(check forced)"
|
check_extra="(check forced)"
|
||||||
fi
|
fi
|
||||||
@@ -92,6 +97,7 @@ stop()
|
|||||||
# Fake function so we always shutdown correctly.
|
# Fake function so we always shutdown correctly.
|
||||||
_abort() { return 0; }
|
_abort() { return 0; }
|
||||||
_reboot() { return 0; }
|
_reboot() { return 0; }
|
||||||
|
_forcefsck() { return 1; }
|
||||||
|
|
||||||
yesno "${fsck_shutdown}" && start
|
yesno "${fsck_shutdown}" && start
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ ${routes}"
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local OIFS="${IFS}" SIFS=${IFS-y}
|
local OIFS="${IFS}" SIFS="${IFS-y}"
|
||||||
local IFS="$__IFS"
|
local IFS="$__IFS"
|
||||||
for cmd in ${routes}; do
|
for cmd in ${routes}; do
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ description="Mount the sys filesystem."
|
|||||||
|
|
||||||
depend()
|
depend()
|
||||||
{
|
{
|
||||||
keyword noprefix
|
keyword noprefix novserver
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_sys()
|
mount_sys()
|
||||||
|
|||||||
@@ -61,4 +61,4 @@ does the same and also prints the full path of the service to stdout.
|
|||||||
.Xr rc 8 ,
|
.Xr rc 8 ,
|
||||||
.Xr stdout 3
|
.Xr stdout 3
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -61,4 +61,4 @@ Show information only for the named
|
|||||||
.Xr rc 8 ,
|
.Xr rc 8 ,
|
||||||
.Xr rc-update 8
|
.Xr rc-update 8
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -77,4 +77,4 @@ Show all services.
|
|||||||
.Xr rc 8 ,
|
.Xr rc 8 ,
|
||||||
.Xr rc-status 8
|
.Xr rc-status 8
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -70,4 +70,4 @@ is set to
|
|||||||
.Xr rc_stringlist_free 3 ,
|
.Xr rc_stringlist_free 3 ,
|
||||||
.Xr sh 1
|
.Xr sh 1
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -110,4 +110,4 @@ when done.
|
|||||||
.Xr rc_stringlist_free 3 ,
|
.Xr rc_stringlist_free 3 ,
|
||||||
.Xr runscript 8
|
.Xr runscript 8
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -67,4 +67,4 @@ Each RC_PID should be freed in the list as well as the list itself when done.
|
|||||||
.Xr free 3 ,
|
.Xr free 3 ,
|
||||||
.Xr queue 3
|
.Xr queue 3
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -48,4 +48,4 @@ Plugins can affect the parent environemnt by writing NULL separated strings to
|
|||||||
.Xr rc 8 ,
|
.Xr rc 8 ,
|
||||||
.Xr runscript 8
|
.Xr runscript 8
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -63,4 +63,4 @@ Rinse and repeat for the other verbose functions.
|
|||||||
.Xr free 3
|
.Xr free 3
|
||||||
.Xr rc_stringlist_free 3
|
.Xr rc_stringlist_free 3
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -227,4 +227,4 @@ normally holds the volatile state data for services on a RAM backed disk.
|
|||||||
.Xr rc_stringlist_free 3 ,
|
.Xr rc_stringlist_free 3 ,
|
||||||
.Xr start-stop-daemon 8
|
.Xr start-stop-daemon 8
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -85,4 +85,4 @@ itself.
|
|||||||
.Xr queue 3 ,
|
.Xr queue 3 ,
|
||||||
.Xr strcmp 3
|
.Xr strcmp 3
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -461,4 +461,4 @@ Users are encouraged to use the is_newer_than function which returns correctly.
|
|||||||
.Xr start-stop-daemon 8 ,
|
.Xr start-stop-daemon 8 ,
|
||||||
.Xr uname 1
|
.Xr uname 1
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.\" Copyright 2007-2008 Roy Marples
|
.\" Copyright 2007-2009 Roy Marples
|
||||||
.\" All rights reserved
|
.\" All rights reserved
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 27, 2008
|
.Dd January 1, 2009
|
||||||
.Dt START-STOP-DAEMON 8 SMM
|
.Dt START-STOP-DAEMON 8 SMM
|
||||||
.Os OpenRC
|
.Os OpenRC
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -116,6 +116,10 @@ chdir to this directory before starting the daemon.
|
|||||||
.It Fl r , -chroot Ar path
|
.It Fl r , -chroot Ar path
|
||||||
chroot to this directory before starting the daemon. All other paths, such
|
chroot to this directory before starting the daemon. All other paths, such
|
||||||
as the path to the daemon, chdir and pidfile, should be relative to the chroot.
|
as the path to the daemon, chdir and pidfile, should be relative to the chroot.
|
||||||
|
.It Fl c , -chuid Ar user
|
||||||
|
Same as the
|
||||||
|
.Fl u , -user
|
||||||
|
option.
|
||||||
.It Fl e , -env Ar VAR=VALUE
|
.It Fl e , -env Ar VAR=VALUE
|
||||||
Set the environment variable VAR to VALUE.
|
Set the environment variable VAR to VALUE.
|
||||||
.It Fl g , -group Ar group
|
.It Fl g , -group Ar group
|
||||||
@@ -185,4 +189,4 @@ first appeared in Debian.
|
|||||||
This is a complete re-implementation with the process finding code in the
|
This is a complete re-implementation with the process finding code in the
|
||||||
OpenRC library (librc, -lrc) so other programs can make use of it.
|
OpenRC library (librc, -lrc) so other programs can make use of it.
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples" <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
|||||||
@@ -105,7 +105,15 @@ wpa_supplicant_pre_start()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Work out where the ctrl_interface dir is if it's not specified
|
# Work out where the ctrl_interface dir is if it's not specified
|
||||||
local ctrl_dir=$(sed -n -e 's/[[:space:]]*#.*//g;s/[[:space:]]*$//g;s/^ctrl_interface=//p' "${cfgfile}")
|
local ctrl_dir=$(sed -e 's/^ *//' \
|
||||||
|
-e '/^ctrl_interface=/!d' \
|
||||||
|
-e 's/^ctrl_interface=//' \
|
||||||
|
-e 's/^ *//' \
|
||||||
|
-e 's/^DIR=//' \
|
||||||
|
-e 's/^ *//' \
|
||||||
|
-e 's/GROUP=.*//' \
|
||||||
|
-e 's/ *$//' \
|
||||||
|
"${cfgfile}")
|
||||||
if [ -z "${ctrl_dir}" ]; then
|
if [ -z "${ctrl_dir}" ]; then
|
||||||
ctrl_dir=${opts##* -C}
|
ctrl_dir=${opts##* -C}
|
||||||
if [ -n "${ctrl_dir}" -a "${ctrl_dir}" != "${opts}" ]; then
|
if [ -n "${ctrl_dir}" -a "${ctrl_dir}" != "${opts}" ]; then
|
||||||
@@ -120,7 +128,6 @@ wpa_supplicant_pre_start()
|
|||||||
fi
|
fi
|
||||||
service_set_value ctrl_dir "${ctrl_dir}"
|
service_set_value ctrl_dir "${ctrl_dir}"
|
||||||
|
|
||||||
|
|
||||||
if [ -n "${wpac}" ]; then
|
if [ -n "${wpac}" ]; then
|
||||||
opts="${opts} -W"
|
opts="${opts} -W"
|
||||||
elif service_started devd; then
|
elif service_started devd; then
|
||||||
|
|||||||
@@ -43,11 +43,12 @@ include ${MK}/${MKTERMCAP}.mk
|
|||||||
LDADD+= ${LIBDL} ${LIBKVM}
|
LDADD+= ${LIBDL} ${LIBKVM}
|
||||||
include ${MK}/${MKPAM}.mk
|
include ${MK}/${MKPAM}.mk
|
||||||
|
|
||||||
_SVNVER_SH= if type svnversion >/dev/null 2>&1; then \
|
_SVNVER_SH= ret=""; \
|
||||||
echo "-svn-$$(svnversion)"; \
|
if type svnversion >/dev/null 2>&1; then \
|
||||||
else \
|
svnver="$$(svnversion)"; \
|
||||||
echo ""; \
|
[ "$${svnver}" != exported ] && ret="-svn-$${svnver}"; \
|
||||||
fi
|
fi; \
|
||||||
|
echo "$${ret}";
|
||||||
_SVNVER!= ${_SVNVER_SH}
|
_SVNVER!= ${_SVNVER_SH}
|
||||||
SVNVER= ${_SVNVER}$(shell ${_SVNVER_SH})
|
SVNVER= ${_SVNVER}$(shell ${_SVNVER_SH})
|
||||||
|
|
||||||
|
|||||||
@@ -918,8 +918,8 @@ main(int argc, char **argv)
|
|||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (going_down) {
|
if (going_down) {
|
||||||
|
|||||||
@@ -717,9 +717,9 @@ svc_start(bool deps)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
background = true;
|
background = true;
|
||||||
rc_service_mark(service, RC_SERVICE_HOTPLUGGED);
|
rc_service_mark(service, RC_SERVICE_HOTPLUGGED);
|
||||||
if (rc_runlevel_starting())
|
if (strcmp(runlevel, RC_LEVEL_SYSINIT) == 0)
|
||||||
ewarnx("WARNING: %s will be started when the runlevel"
|
ewarnx("WARNING: %s will be started in the"
|
||||||
" has finished.", applet);
|
" next runlevel", applet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state & RC_SERVICE_STARTED) {
|
if (state & RC_SERVICE_STARTED) {
|
||||||
@@ -1236,7 +1236,7 @@ runscript(int argc, char **argv)
|
|||||||
/* Change dir to / to ensure all init scripts don't use stuff in pwd */
|
/* Change dir to / to ensure all init scripts don't use stuff in pwd */
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
if ((runlevel = xstrdup (getenv ("RC_RUNLEVEL"))) == NULL) {
|
if ((runlevel = xstrdup(getenv("RC_RUNLEVEL"))) == NULL) {
|
||||||
env_filter();
|
env_filter();
|
||||||
env_config();
|
env_config();
|
||||||
runlevel = rc_runlevel_get();
|
runlevel = rc_runlevel_get();
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ static int run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
long nloops;
|
long nloops;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
|
const char *const *p;
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
if (exec)
|
if (exec)
|
||||||
@@ -376,8 +377,15 @@ static int run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
einfo("Will stop PID in pidfile `%s'", pidfile);
|
einfo("Will stop PID in pidfile `%s'", pidfile);
|
||||||
if (uid)
|
if (uid)
|
||||||
einfo("Will stop processes owned by UID %d", uid);
|
einfo("Will stop processes owned by UID %d", uid);
|
||||||
if (argv && *argv)
|
if (argv && *argv) {
|
||||||
einfo("Will stop processes of `%s'", *argv);
|
einfon("Will stop processes of `");
|
||||||
|
for (p = argv; p && *p; p++) {
|
||||||
|
if (p != argv)
|
||||||
|
printf(" ");
|
||||||
|
printf("%s", *p);
|
||||||
|
}
|
||||||
|
printf("'\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pidfile) {
|
if (pidfile) {
|
||||||
@@ -618,6 +626,7 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
char *startas = NULL;
|
char *startas = NULL;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
char *pidfile = NULL;
|
char *pidfile = NULL;
|
||||||
|
char *retry = NULL;
|
||||||
int sig = 0;
|
int sig = 0;
|
||||||
int nicelevel = 0;
|
int nicelevel = 0;
|
||||||
bool background = false;
|
bool background = false;
|
||||||
@@ -686,7 +695,7 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R': /* --retry <schedule>|<timeout> */
|
case 'R': /* --retry <schedule>|<timeout> */
|
||||||
parse_schedule(optarg, sig);
|
retry = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S': /* --start */
|
case 'S': /* --start */
|
||||||
@@ -840,13 +849,15 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
exec = name;
|
exec = name;
|
||||||
if (name && start)
|
if (name && start)
|
||||||
*argv = name;
|
*argv = name;
|
||||||
} else if (name && (start || **argv))
|
} else if (name)
|
||||||
*--argv = name;
|
*--argv = name;
|
||||||
else
|
else if (exec)
|
||||||
*--argv = exec;
|
*--argv = exec;
|
||||||
|
|
||||||
if (stop || sig) {
|
if (stop || sig != 0) {
|
||||||
if ( !*argv && !pidfile && !name && !uid)
|
if (sig == 0)
|
||||||
|
sig = SIGTERM;
|
||||||
|
if (!*argv && !pidfile && !name && !uid)
|
||||||
eerrorx("%s: --stop needs --exec, --pidfile,"
|
eerrorx("%s: --stop needs --exec, --pidfile,"
|
||||||
" --name or --user", applet);
|
" --name or --user", applet);
|
||||||
if (background)
|
if (background)
|
||||||
@@ -869,70 +880,44 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
" with --background", applet);
|
" with --background", applet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stop || sig) {
|
|
||||||
if (!sig)
|
|
||||||
sig = SIGTERM;
|
|
||||||
if (!stop)
|
|
||||||
oknodo = true;
|
|
||||||
if (!TAILQ_FIRST(&schedule)) {
|
|
||||||
if (test || oknodo)
|
|
||||||
parse_schedule("0", sig);
|
|
||||||
else
|
|
||||||
parse_schedule(NULL, sig);
|
|
||||||
}
|
|
||||||
i = run_stop_schedule(exec, (const char *const *)argv,
|
|
||||||
pidfile, uid, quiet, verbose, test);
|
|
||||||
|
|
||||||
if (i < 0)
|
|
||||||
/* We failed to stop something */
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
if (test || oknodo)
|
|
||||||
return i > 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
||||||
|
|
||||||
/* Even if we have not actually killed anything, we should
|
|
||||||
* remove information about it as it may have unexpectedly
|
|
||||||
* crashed out. We should also return success as the end
|
|
||||||
* result would be the same. */
|
|
||||||
if (pidfile && exists(pidfile))
|
|
||||||
unlink(pidfile);
|
|
||||||
if (svcname)
|
|
||||||
rc_service_daemon_set(svcname, exec,
|
|
||||||
(const char *const *)argv,
|
|
||||||
pidfile, false);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Expand ~ */
|
/* Expand ~ */
|
||||||
if (ch_dir && *ch_dir == '~')
|
if (ch_dir && *ch_dir == '~')
|
||||||
ch_dir = expand_home(home, ch_dir);
|
ch_dir = expand_home(home, ch_dir);
|
||||||
if (ch_root && *ch_root == '~')
|
if (ch_root && *ch_root == '~')
|
||||||
ch_root = expand_home(home, ch_root);
|
ch_root = expand_home(home, ch_root);
|
||||||
if (*exec == '~')
|
if (exec) {
|
||||||
exec = expand_home(home, exec);
|
if (*exec == '~')
|
||||||
|
exec = expand_home(home, exec);
|
||||||
|
|
||||||
/* Validate that the binary exists if we are starting */
|
/* Validate that the binary exists if we are starting */
|
||||||
if (*exec == '/' || *exec == '.') {
|
if (*exec == '/' || *exec == '.') {
|
||||||
/* Full or relative path */
|
/* Full or relative path */
|
||||||
if (ch_root)
|
|
||||||
snprintf(exec_file, sizeof(exec_file), "%s/%s", ch_root, exec);
|
|
||||||
else
|
|
||||||
snprintf(exec_file, sizeof(exec_file), "%s", exec);
|
|
||||||
} else {
|
|
||||||
/* Something in $PATH */
|
|
||||||
p = tmp = xstrdup(getenv("PATH"));
|
|
||||||
*exec_file = '\0';
|
|
||||||
while ((token = strsep(&p, ":"))) {
|
|
||||||
if (ch_root)
|
if (ch_root)
|
||||||
snprintf(exec_file, sizeof(exec_file), "%s/%s/%s", ch_root, token, exec);
|
snprintf(exec_file, sizeof(exec_file),
|
||||||
|
"%s/%s", ch_root, exec);
|
||||||
else
|
else
|
||||||
snprintf(exec_file, sizeof(exec_file), "%s/%s", token, exec);
|
snprintf(exec_file, sizeof(exec_file),
|
||||||
if (exists(exec_file))
|
"%s", exec);
|
||||||
break;
|
} else {
|
||||||
|
/* Something in $PATH */
|
||||||
|
p = tmp = xstrdup(getenv("PATH"));
|
||||||
*exec_file = '\0';
|
*exec_file = '\0';
|
||||||
|
while ((token = strsep(&p, ":"))) {
|
||||||
|
if (ch_root)
|
||||||
|
snprintf(exec_file, sizeof(exec_file),
|
||||||
|
"%s/%s/%s",
|
||||||
|
ch_root, token, exec);
|
||||||
|
else
|
||||||
|
snprintf(exec_file, sizeof(exec_file),
|
||||||
|
"%s/%s", token, exec);
|
||||||
|
if (exists(exec_file))
|
||||||
|
break;
|
||||||
|
*exec_file = '\0';
|
||||||
|
}
|
||||||
|
free(tmp);
|
||||||
}
|
}
|
||||||
free(tmp);
|
|
||||||
}
|
}
|
||||||
if (!exists(exec_file)) {
|
if (start && !exists(exec_file)) {
|
||||||
eerror("%s: %s does not exist", applet,
|
eerror("%s: %s does not exist", applet,
|
||||||
*exec_file ? exec_file : exec);
|
*exec_file ? exec_file : exec);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@@ -971,9 +956,41 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
margv = nav ? nav : argv;
|
margv = nav ? nav : argv;
|
||||||
|
|
||||||
|
if (stop || sig) {
|
||||||
|
if (sig == 0)
|
||||||
|
sig = SIGTERM;
|
||||||
|
if (!stop)
|
||||||
|
oknodo = true;
|
||||||
|
if (retry)
|
||||||
|
parse_schedule(retry, sig);
|
||||||
|
else if (test || oknodo)
|
||||||
|
parse_schedule("0", sig);
|
||||||
|
else
|
||||||
|
parse_schedule(NULL, sig);
|
||||||
|
i = run_stop_schedule(exec, (const char *const *)margv,
|
||||||
|
pidfile, uid, quiet, verbose, test);
|
||||||
|
|
||||||
|
if (i < 0)
|
||||||
|
/* We failed to stop something */
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
if (test || oknodo)
|
||||||
|
return i > 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
|
||||||
|
/* Even if we have not actually killed anything, we should
|
||||||
|
* remove information about it as it may have unexpectedly
|
||||||
|
* crashed out. We should also return success as the end
|
||||||
|
* result would be the same. */
|
||||||
|
if (pidfile && exists(pidfile))
|
||||||
|
unlink(pidfile);
|
||||||
|
if (svcname)
|
||||||
|
rc_service_daemon_set(svcname, exec,
|
||||||
|
(const char *const *)argv,
|
||||||
|
pidfile, false);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
if (pidfile)
|
if (pidfile)
|
||||||
pid = get_pid(pidfile, true);
|
pid = get_pid(pidfile, true);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user