mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
Add support for SysV-only scripts in runparts
This patch extens the SysV compatibility support in Finit by adding support for limiting `runparts` to run only SNNfoo, or KNNfoo, style scripts from a directory. Additionally, by default `runparts` now runs entirely in the background without any progress. To enable progress, an optional argument has been added to the runparts command line. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
846806747b
commit
6ae1083c99
17 files changed
+118
-42
No files matched your search
+13
-5
@@ -83,7 +83,7 @@ static void run_env(const char *env[])
|
||||
}
|
||||
}
|
||||
|
||||
int run_parts(char *dir, char *cmd, const char *env[], int progress)
|
||||
int run_parts(char *dir, char *cmd, const char *env[], int progress, int sysv)
|
||||
{
|
||||
size_t cmdlen = cmd ? strlen(cmd) : strlen("start");
|
||||
struct dirent **d;
|
||||
@@ -127,6 +127,11 @@ int run_parts(char *dir, char *cmd, const char *env[], int progress)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sysv && name[0] != 'S' && name[0] != 'K') {
|
||||
dbg("S-only flag set, skipping non-SysV script: %s", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the callee didn't supply a run_parts() argument */
|
||||
if (!cmd) {
|
||||
/* Check if S<NUM>service or K<NUM>service notation is used */
|
||||
@@ -179,16 +184,16 @@ int run_parts(char *dir, char *cmd, const char *env[], int progress)
|
||||
#ifndef __FINIT__
|
||||
static int usage(int rc)
|
||||
{
|
||||
warnx("usage: runparts [-dh?] DIRECTORY");
|
||||
warnx("usage: runparts [-dhps?] DIRECTORY");
|
||||
return rc;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc, c, progress = 0;
|
||||
int rc, c, progress = 0, sysv = 0;
|
||||
char *dir;
|
||||
|
||||
while ((c = getopt(argc, argv, "dh?p")) != EOF) {
|
||||
while ((c = getopt(argc, argv, "dh?ps")) != EOF) {
|
||||
switch(c) {
|
||||
case 'd':
|
||||
debug = 1;
|
||||
@@ -199,6 +204,9 @@ int main(int argc, char *argv[])
|
||||
case 'p':
|
||||
progress = 1;
|
||||
break;
|
||||
case 's':
|
||||
sysv = 1;
|
||||
break;
|
||||
default:
|
||||
return usage(1);
|
||||
}
|
||||
@@ -213,7 +221,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
prctl(PR_SET_CHILD_SUBREAPER, 1);
|
||||
|
||||
rc = run_parts(dir, NULL, NULL, progress);
|
||||
rc = run_parts(dir, NULL, NULL, progress, sysv);
|
||||
if (rc == -1)
|
||||
err(1, "failed run-parts %s", dir);
|
||||
|
||||
|
||||
Reference in new issue
Block a user