convert all references from runscript to openrc-run

This commit is contained in:
William Hubbs 2015-04-26 13:31:49 -05:00
parent 4b1b457cd1
commit 8b93492086
9 changed files with 33 additions and 28 deletions

View File

@ -1,4 +1,4 @@
#!@PREFIX@/sbin/runscript #!@PREFIX@/sbin/openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name> # Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license. # Released under the 2-clause BSD license.
#FIXME: Modify for GNU/Hurd #FIXME: Modify for GNU/Hurd

2
sh/.gitignore vendored
View File

@ -1,7 +1,7 @@
functions.sh functions.sh
gendepends.sh gendepends.sh
rc-functions.sh rc-functions.sh
runscript.sh openrc-run.sh
cgroup-release-agent.sh cgroup-release-agent.sh
init.sh init.sh
init-early.sh init-early.sh

View File

@ -1,8 +1,8 @@
DIR= ${LIBEXECDIR}/sh DIR= ${LIBEXECDIR}/sh
SRCS= init.sh.in functions.sh.in gendepends.sh.in \ SRCS= init.sh.in functions.sh.in gendepends.sh.in \
rc-functions.sh.in runscript.sh.in tmpfiles.sh.in ${SRCS-${OS}} openrc-run.sh.in rc-functions.sh.in tmpfiles.sh.in ${SRCS-${OS}}
INC= rc-mount.sh functions.sh rc-functions.sh INC= rc-mount.sh functions.sh rc-functions.sh
BIN= gendepends.sh init.sh runscript.sh tmpfiles.sh ${BIN-${OS}} BIN= gendepends.sh init.sh openrc-run.sh tmpfiles.sh ${BIN-${OS}}
INSTALLAFTER= _installafter INSTALLAFTER= _installafter

View File

@ -1,5 +1,5 @@
#!@SHELL@ #!@SHELL@
# Shell wrapper for runscript # Shell wrapper for openrc-run
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name> # Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license. # Released under the 2-clause BSD license.

View File

@ -85,7 +85,7 @@ get_bootparam()
return 1 return 1
} }
# Called from runscript.sh or gendepends.sh # Called from openrc-run.sh or gendepends.sh
_depend() { _depend() {
depend depend
local _rc_svcname=$(shell_var "$RC_SVCNAME") _deptype= _depends= local _rc_svcname=$(shell_var "$RC_SVCNAME") _deptype= _depends=

View File

@ -99,7 +99,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
pid_t p; pid_t p;
char buffer[PATH_MAX]; char buffer[PATH_MAX];
struct stat sb; struct stat sb;
pid_t runscript_pid = 0; pid_t openrc_pid = 0;
char *pp; char *pp;
RC_PIDLIST *pids = NULL; RC_PIDLIST *pids = NULL;
RC_PID *pi; RC_PID *pi;
@ -108,7 +108,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
return NULL; return NULL;
/* /*
We never match RC_RUNSCRIPT_PID if present so we avoid the below We never match RC_OPENRC_PID if present so we avoid the below
scenario scenario
/etc/init.d/ntpd stop does /etc/init.d/ntpd stop does
@ -118,9 +118,9 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
nasty nasty
*/ */
if ((pp = getenv("RC_RUNSCRIPT_PID"))) { if ((pp = getenv("RC_OPENRC_PID"))) {
if (sscanf(pp, "%d", &runscript_pid) != 1) if (sscanf(pp, "%d", &openrc_pid) != 1)
runscript_pid = 0; openrc_pid = 0;
} }
/* /*
@ -146,7 +146,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
while ((entry = readdir(procdir)) != NULL) { while ((entry = readdir(procdir)) != NULL) {
if (sscanf(entry->d_name, "%d", &p) != 1) if (sscanf(entry->d_name, "%d", &p) != 1)
continue; continue;
if (runscript_pid != 0 && runscript_pid == p) if (openrc_pid != 0 && openrc_pid == p)
continue; continue;
if (pid != 0 && pid != p) if (pid != 0 && pid != p)
continue; continue;

View File

@ -1,8 +1,8 @@
PROG= openrc PROG= openrc
SRCS= checkpath.c fstabinfo.c mountinfo.c start-stop-daemon.c \ SRCS= checkpath.c fstabinfo.c mountinfo.c openrc-run.c \
rc-applets.c rc-depend.c rc-logger.c \ rc-applets.c rc-depend.c rc-logger.c \
rc-misc.c rc-plugin.c rc-service.c rc-status.c rc-update.c \ rc-misc.c rc-plugin.c rc-service.c rc-status.c rc-update.c \
runscript.c rc.c swclock.c rc.c start-stop-daemon.c swclock.c
ifeq (${MKSELINUX},yes) ifeq (${MKSELINUX},yes)
SRCS+= rc-selinux.c SRCS+= rc-selinux.c

View File

@ -1,5 +1,5 @@
/* /*
* runscript.c * openrc-run.c
* Handle launching of init scripts. * Handle launching of init scripts.
*/ */
@ -370,18 +370,18 @@ svc_exec(const char *arg1, const char *arg2)
dup2(slave_tty, STDERR_FILENO); dup2(slave_tty, STDERR_FILENO);
} }
if (exists(RC_SVCDIR "/runscript.sh")) { if (exists(RC_SVCDIR "/openrc-run.sh")) {
execl(RC_SVCDIR "/runscript.sh", execl(RC_SVCDIR "/openrc-run.sh",
RC_SVCDIR "/runscript.sh", RC_SVCDIR "/openrc-run.sh",
service, arg1, arg2, (char *) NULL); service, arg1, arg2, (char *) NULL);
eerror("%s: exec `" RC_SVCDIR "/runscript.sh': %s", eerror("%s: exec `" RC_SVCDIR "/openrc-run.sh': %s",
service, strerror(errno)); service, strerror(errno));
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} else { } else {
execl(RC_LIBEXECDIR "/sh/runscript.sh", execl(RC_LIBEXECDIR "/sh/openrc-run.sh",
RC_LIBEXECDIR "/sh/runscript.sh", RC_LIBEXECDIR "/sh/openrc-run.sh",
service, arg1, arg2, (char *) NULL); service, arg1, arg2, (char *) NULL);
eerror("%s: exec `" RC_LIBEXECDIR "/sh/runscript.sh': %s", eerror("%s: exec `" RC_LIBEXECDIR "/sh/openrc-run.sh': %s",
service, strerror(errno)); service, strerror(errno));
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
@ -1162,6 +1162,11 @@ openrc_run(int argc, char **argv)
subshells the init script may create so that our mark_service_* subshells the init script may create so that our mark_service_*
functions can always instruct us of this change */ functions can always instruct us of this change */
snprintf(pidstr, sizeof(pidstr), "%d", (int) getpid()); snprintf(pidstr, sizeof(pidstr), "%d", (int) getpid());
setenv("RC_OPENRC_PID", pidstr, 1);
/*
* RC_RUNSCRIPT_PID is deprecated, but we will keep it for a while
* for safety.
*/
setenv("RC_RUNSCRIPT_PID", pidstr, 1); setenv("RC_RUNSCRIPT_PID", pidstr, 1);
/* eprefix is kinda klunky, but it works for our purposes */ /* eprefix is kinda klunky, but it works for our purposes */

View File

@ -329,7 +329,7 @@ do_mark_service(int argc, char **argv)
bool ok = false; bool ok = false;
char *svcname = getenv("RC_SVCNAME"); char *svcname = getenv("RC_SVCNAME");
char *service = NULL; char *service = NULL;
char *runscript_pid; char *openrc_pid;
/* char *mtime; */ /* char *mtime; */
pid_t pid; pid_t pid;
RC_SERVICE bit; RC_SERVICE bit;
@ -350,7 +350,7 @@ do_mark_service(int argc, char **argv)
eerrorx("%s: unknown applet", applet); eerrorx("%s: unknown applet", applet);
/* If we're marking ourselves then we need to inform our parent /* If we're marking ourselves then we need to inform our parent
runscript process so they do not mark us based on our exit code */ openrc-run process so they do not mark us based on our exit code */
/* /*
* FIXME: svcname and service are almost always equal except called from a * FIXME: svcname and service are almost always equal except called from a
* shell with just argv[1] - So that doesn't seem to do what Roy initially * shell with just argv[1] - So that doesn't seem to do what Roy initially
@ -359,8 +359,8 @@ do_mark_service(int argc, char **argv)
* openrc@gentoo.org). * openrc@gentoo.org).
*/ */
if (ok && svcname && strcmp(svcname, service) == 0) { if (ok && svcname && strcmp(svcname, service) == 0) {
runscript_pid = getenv("RC_RUNSCRIPT_PID"); openrc_pid = getenv("RC_OPENRC_PID");
if (runscript_pid && sscanf(runscript_pid, "%d", &pid) == 1) if (openrc_pid && sscanf(openrc_pid, "%d", &pid) == 1)
if (kill(pid, SIGHUP) != 0) if (kill(pid, SIGHUP) != 0)
eerror("%s: failed to signal parent %d: %s", eerror("%s: failed to signal parent %d: %s",
applet, pid, strerror(errno)); applet, pid, strerror(errno));
@ -369,10 +369,10 @@ do_mark_service(int argc, char **argv)
in control as well */ in control as well */
/* /*
l = strlen(RC_SVCDIR "/exclusive") + strlen(svcname) + l = strlen(RC_SVCDIR "/exclusive") + strlen(svcname) +
strlen(runscript_pid) + 4; strlen(openrc_pid) + 4;
mtime = xmalloc(l); mtime = xmalloc(l);
snprintf(mtime, l, RC_SVCDIR "/exclusive/%s.%s", snprintf(mtime, l, RC_SVCDIR "/exclusive/%s.%s",
svcname, runscript_pid); svcname, openrc_pid);
if (exists(mtime) && unlink(mtime) != 0) if (exists(mtime) && unlink(mtime) != 0)
eerror("%s: unlink: %s", applet, strerror(errno)); eerror("%s: unlink: %s", applet, strerror(errno));
free(mtime); free(mtime);