Compare commits

...

19 Commits

Author SHA1 Message Date
Roy Marples
0298e4ffa0 Remove leading and trailing space on the ctrl_interface line. 2009-01-05 09:37:38 +00:00
Roy Marples
a063035b37 Make _SVNVER_SH more readable. 2009-01-02 22:51:47 +00:00
Roy Marples
213cef1739 Fix version for releases. 2009-01-02 16:48:42 +00:00
Roy Marples
386ee57432 Fix compile, #136 2009-01-02 15:11:15 +00:00
Roy Marples
631acff7aa Document the --chuid option. 2009-01-01 14:32:09 +00:00
Roy Marples
877a328179 dmesg and sysfs won't work in a vserver, #137 thanks to Hollow. 2009-01-01 14:27:29 +00:00
Roy Marples
1efa64cae8 Typo. 2008-12-30 19:08:51 +00:00
Roy Marples
22959c3963 Fix working on zsh 2008-12-30 00:05:17 +00:00
Roy Marples
2464f9e93b Add parens, #134 thanks to Matthias Schwarzott. 2008-12-29 23:06:22 +00:00
Roy Marples
d91201cb94 Skip all forcefsck checking when stopping, #134. 2008-12-28 15:25:40 +00:00
Roy Marples
1c5ec9d161 Fake get_bootparam function so that we don't check for kernel options forcefsck when doing an fsck on shutdown. 2008-12-28 14:49:07 +00:00
Roy Marples
f4b8366942 Parse retry schedule correctly, #129. Thanks to vaeth. 2008-12-28 14:05:33 +00:00
Roy Marples
438665357b Release 0.4.1 2008-12-23 10:45:16 +00:00
Roy Marples
7ad40abf64 Our error messages don't have full stops at the end 2008-12-23 10:42:25 +00:00
Roy Marples
7e12abe035 Typo. 2008-12-23 10:41:33 +00:00
Roy Marples
4dba5b1ff1 Disallow hotplug to run during sysinit, but allow elsewhere. Fixes #131. 2008-12-23 10:40:27 +00:00
Roy Marples
1ff289e305 Whitespace. 2008-12-23 10:39:45 +00:00
Roy Marples
53e2bec385 We should match on the correct args for stopping daemons when pidfiles
are not being used.
2008-12-23 10:15:41 +00:00
Roy Marples
9d9f17aa52 Allow working with the new ctrl_iface=DIR=foo directive. 2008-12-23 10:13:58 +00:00
22 changed files with 127 additions and 91 deletions

View File

@@ -3,7 +3,7 @@
# All rights reserved. Released under the 2-clause BSD license.
NAME= openrc
VERSION= 0.4.0
VERSION= 0.4.1
PKG= ${NAME}-${VERSION}
SUBDIR= conf.d doc etc init.d man net sh src

View File

@@ -7,6 +7,7 @@ description="Set the dmesg level for a cleaner boot"
depend()
{
before dev modules
keyword novserver
}
start()

View File

@@ -25,6 +25,11 @@ _reboot() {
fi
}
_forcefsck()
{
[ -e /forcefsck ] || get_bootparam forcefsck
}
start()
{
local fsck_opts= p= check_extra=
@@ -33,7 +38,7 @@ start()
ewarn "Skipping fsck due to /fastboot"
return 0
fi
if [ -e /forcefsck ] || get_bootparam forcefsck; then
if _forcefsck; then
fsck_opts="${fsck_opts} -f"
check_extra="(check forced)"
fi
@@ -92,6 +97,7 @@ stop()
# Fake function so we always shutdown correctly.
_abort() { return 0; }
_reboot() { return 0; }
_forcefsck() { return 1; }
yesno "${fsck_shutdown}" && start
return 0

View File

@@ -595,7 +595,7 @@ ${routes}"
fi
fi
local OIFS="${IFS}" SIFS=${IFS-y}
local OIFS="${IFS}" SIFS="${IFS-y}"
local IFS="$__IFS"
for cmd in ${routes}; do
unset IFS

View File

@@ -6,7 +6,7 @@ description="Mount the sys filesystem."
depend()
{
keyword noprefix
keyword noprefix novserver
}
mount_sys()

View File

@@ -61,4 +61,4 @@ does the same and also prints the full path of the service to stdout.
.Xr rc 8 ,
.Xr stdout 3
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -61,4 +61,4 @@ Show information only for the named
.Xr rc 8 ,
.Xr rc-update 8
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -77,4 +77,4 @@ Show all services.
.Xr rc 8 ,
.Xr rc-status 8
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -70,4 +70,4 @@ is set to
.Xr rc_stringlist_free 3 ,
.Xr sh 1
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -110,4 +110,4 @@ when done.
.Xr rc_stringlist_free 3 ,
.Xr runscript 8
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -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 queue 3
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -48,4 +48,4 @@ Plugins can affect the parent environemnt by writing NULL separated strings to
.Xr rc 8 ,
.Xr runscript 8
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -63,4 +63,4 @@ Rinse and repeat for the other verbose functions.
.Xr free 3
.Xr rc_stringlist_free 3
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -227,4 +227,4 @@ normally holds the volatile state data for services on a RAM backed disk.
.Xr rc_stringlist_free 3 ,
.Xr start-stop-daemon 8
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -85,4 +85,4 @@ itself.
.Xr queue 3 ,
.Xr strcmp 3
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -461,4 +461,4 @@ Users are encouraged to use the is_newer_than function which returns correctly.
.Xr start-stop-daemon 8 ,
.Xr uname 1
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -1,4 +1,4 @@
.\" Copyright 2007-2008 Roy Marples
.\" Copyright 2007-2009 Roy Marples
.\" All rights reserved
.\"
.\" 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
.\" SUCH DAMAGE.
.\"
.Dd September 27, 2008
.Dd January 1, 2009
.Dt START-STOP-DAEMON 8 SMM
.Os OpenRC
.Sh NAME
@@ -116,6 +116,10 @@ chdir to this directory before starting the daemon.
.It Fl r , -chroot Ar path
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.
.It Fl c , -chuid Ar user
Same as the
.Fl u , -user
option.
.It Fl e , -env Ar VAR=VALUE
Set the environment variable VAR to VALUE.
.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
OpenRC library (librc, -lrc) so other programs can make use of it.
.Sh AUTHORS
.An Roy Marples" <roy@marples.name>
.An Roy Marples <roy@marples.name>

View File

@@ -105,7 +105,15 @@ wpa_supplicant_pre_start()
fi
# 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
ctrl_dir=${opts##* -C}
if [ -n "${ctrl_dir}" -a "${ctrl_dir}" != "${opts}" ]; then
@@ -120,7 +128,6 @@ wpa_supplicant_pre_start()
fi
service_set_value ctrl_dir "${ctrl_dir}"
if [ -n "${wpac}" ]; then
opts="${opts} -W"
elif service_started devd; then

View File

@@ -43,11 +43,12 @@ include ${MK}/${MKTERMCAP}.mk
LDADD+= ${LIBDL} ${LIBKVM}
include ${MK}/${MKPAM}.mk
_SVNVER_SH= if type svnversion >/dev/null 2>&1; then \
echo "-svn-$$(svnversion)"; \
else \
echo ""; \
fi
_SVNVER_SH= ret=""; \
if type svnversion >/dev/null 2>&1; then \
svnver="$$(svnversion)"; \
[ "$${svnver}" != exported ] && ret="-svn-$${svnver}"; \
fi; \
echo "$${ret}";
_SVNVER!= ${_SVNVER_SH}
SVNVER= ${_SVNVER}$(shell ${_SVNVER_SH})

View File

@@ -918,8 +918,8 @@ main(int argc, char **argv)
free(p);
}
}
}
#endif
}
}
if (going_down) {

View File

@@ -717,9 +717,9 @@ svc_start(bool deps)
exit(EXIT_FAILURE);
background = true;
rc_service_mark(service, RC_SERVICE_HOTPLUGGED);
if (rc_runlevel_starting())
ewarnx("WARNING: %s will be started when the runlevel"
" has finished.", applet);
if (strcmp(runlevel, RC_LEVEL_SYSINIT) == 0)
ewarnx("WARNING: %s will be started in the"
" next runlevel", applet);
}
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 */
chdir("/");
if ((runlevel = xstrdup (getenv ("RC_RUNLEVEL"))) == NULL) {
if ((runlevel = xstrdup(getenv("RC_RUNLEVEL"))) == NULL) {
env_filter();
env_config();
runlevel = rc_runlevel_get();

View File

@@ -368,6 +368,7 @@ static int run_stop_schedule(const char *exec, const char *const *argv,
long nloops;
struct timespec ts;
pid_t pid = 0;
const char *const *p;
if (verbose) {
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);
if (uid)
einfo("Will stop processes owned by UID %d", uid);
if (argv && *argv)
einfo("Will stop processes of `%s'", *argv);
if (argv && *argv) {
einfon("Will stop processes of `");
for (p = argv; p && *p; p++) {
if (p != argv)
printf(" ");
printf("%s", *p);
}
printf("'\n");
}
}
if (pidfile) {
@@ -618,6 +626,7 @@ int start_stop_daemon(int argc, char **argv)
char *startas = NULL;
char *name = NULL;
char *pidfile = NULL;
char *retry = NULL;
int sig = 0;
int nicelevel = 0;
bool background = false;
@@ -686,7 +695,7 @@ int start_stop_daemon(int argc, char **argv)
break;
case 'R': /* --retry <schedule>|<timeout> */
parse_schedule(optarg, sig);
retry = optarg;
break;
case 'S': /* --start */
@@ -840,13 +849,15 @@ int start_stop_daemon(int argc, char **argv)
exec = name;
if (name && start)
*argv = name;
} else if (name && (start || **argv))
} else if (name)
*--argv = name;
else
else if (exec)
*--argv = exec;
if (stop || sig) {
if ( !*argv && !pidfile && !name && !uid)
if (stop || sig != 0) {
if (sig == 0)
sig = SIGTERM;
if (!*argv && !pidfile && !name && !uid)
eerrorx("%s: --stop needs --exec, --pidfile,"
" --name or --user", applet);
if (background)
@@ -869,70 +880,44 @@ int start_stop_daemon(int argc, char **argv)
" 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 ~ */
if (ch_dir && *ch_dir == '~')
ch_dir = expand_home(home, ch_dir);
if (ch_root && *ch_root == '~')
ch_root = expand_home(home, ch_root);
if (*exec == '~')
exec = expand_home(home, exec);
if (exec) {
if (*exec == '~')
exec = expand_home(home, exec);
/* Validate that the binary exists if we are starting */
if (*exec == '/' || *exec == '.') {
/* 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, ":"))) {
/* Validate that the binary exists if we are starting */
if (*exec == '/' || *exec == '.') {
/* Full or relative path */
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
snprintf(exec_file, sizeof(exec_file), "%s/%s", token, exec);
if (exists(exec_file))
break;
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)
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,
*exec_file ? exec_file : exec);
exit(EXIT_FAILURE);
@@ -971,9 +956,41 @@ int start_stop_daemon(int argc, char **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)
pid = get_pid(pidfile, true);
else