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.
|
||||
|
||||
NAME= openrc
|
||||
VERSION= 0.4.0
|
||||
VERSION= 0.4.1
|
||||
PKG= ${NAME}-${VERSION}
|
||||
|
||||
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()
|
||||
{
|
||||
before dev modules
|
||||
keyword novserver
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,7 +6,7 @@ description="Mount the sys filesystem."
|
||||
|
||||
depend()
|
||||
{
|
||||
keyword noprefix
|
||||
keyword noprefix novserver
|
||||
}
|
||||
|
||||
mount_sys()
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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})
|
||||
|
||||
|
||||
@@ -918,9 +918,9 @@ main(int argc, char **argv)
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (going_down) {
|
||||
#ifdef __FreeBSD__
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,44 +880,12 @@ 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) {
|
||||
if (*exec == '~')
|
||||
exec = expand_home(home, exec);
|
||||
|
||||
@@ -914,25 +893,31 @@ int start_stop_daemon(int argc, char **argv)
|
||||
if (*exec == '/' || *exec == '.') {
|
||||
/* Full or relative path */
|
||||
if (ch_root)
|
||||
snprintf(exec_file, sizeof(exec_file), "%s/%s", ch_root, exec);
|
||||
snprintf(exec_file, sizeof(exec_file),
|
||||
"%s/%s", ch_root, exec);
|
||||
else
|
||||
snprintf(exec_file, sizeof(exec_file), "%s", exec);
|
||||
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);
|
||||
snprintf(exec_file, sizeof(exec_file),
|
||||
"%s/%s/%s",
|
||||
ch_root, token, exec);
|
||||
else
|
||||
snprintf(exec_file, sizeof(exec_file), "%s/%s", token, exec);
|
||||
snprintf(exec_file, sizeof(exec_file),
|
||||
"%s/%s", token, exec);
|
||||
if (exists(exec_file))
|
||||
break;
|
||||
*exec_file = '\0';
|
||||
}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user