mirror of
https://github.com/pygos/init.git
synced 2024-11-22 11:19:45 +01:00
Allow aggregating command lines in blocks
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
parent
20e08db1a5
commit
38ad6f1b2f
7 changed files with 66 additions and 29 deletions
|
@ -202,15 +202,17 @@ static int svc_target(service_t *svc, char *arg, rdline_t *rd)
|
||||||
static const struct svc_param {
|
static const struct svc_param {
|
||||||
const char *key;
|
const char *key;
|
||||||
|
|
||||||
|
unsigned int allow_block : 1;
|
||||||
|
|
||||||
int (*handle)(service_t *svc, char *arg, rdline_t *rd);
|
int (*handle)(service_t *svc, char *arg, rdline_t *rd);
|
||||||
} svc_params[] = {
|
} svc_params[] = {
|
||||||
{ "description", svc_desc },
|
{ "description", 0, svc_desc },
|
||||||
{ "exec", svc_exec },
|
{ "exec", 1, svc_exec },
|
||||||
{ "type", svc_type },
|
{ "type", 0, svc_type },
|
||||||
{ "target", svc_target },
|
{ "target", 0, svc_target },
|
||||||
{ "tty", svc_tty },
|
{ "tty", 0, svc_tty },
|
||||||
{ "before", svc_before },
|
{ "before", 0, svc_before },
|
||||||
{ "after", svc_after },
|
{ "after", 0, svc_after },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int splitkv(rdline_t *rd, char **k, char **v)
|
static int splitkv(rdline_t *rd, char **k, char **v)
|
||||||
|
@ -297,8 +299,27 @@ service_t *rdsvc(int dirfd, const char *filename)
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (p->handle(svc, value, &rd))
|
if (p->allow_block && *value == '{') {
|
||||||
|
for (++value; *value == ' '; ++value)
|
||||||
|
;
|
||||||
|
if (*value != '\0' && p->handle(svc, value, &rd))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
while ((ret = rdline(&rd)) == 0) {
|
||||||
|
if (strcmp(rd.buffer, "}") == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (p->handle(svc, rd.buffer, &rd))
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
goto fail;
|
||||||
|
if (ret > 0)
|
||||||
|
goto fail_bra;
|
||||||
|
} else if (p->handle(svc, value, &rd)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -306,6 +327,9 @@ service_t *rdsvc(int dirfd, const char *filename)
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return svc;
|
return svc;
|
||||||
|
fail_bra:
|
||||||
|
fprintf(stderr, "%s: missing '}' before end-of-file\n", filename);
|
||||||
|
goto fail;
|
||||||
fail_oom:
|
fail_oom:
|
||||||
fputs("out of memory\n", stderr);
|
fputs("out of memory\n", stderr);
|
||||||
fail:
|
fail:
|
||||||
|
|
|
@ -4,5 +4,7 @@ target boot
|
||||||
before sysinit
|
before sysinit
|
||||||
after hwclock hostname vfs
|
after hwclock hostname vfs
|
||||||
|
|
||||||
exec "@SBINPATH@/ip" addr add 127.0.0.1/8 dev lo brd +
|
exec {
|
||||||
exec "@SBINPATH@/ip" link set lo up
|
"@SBINPATH@/ip" addr add 127.0.0.1/8 dev lo brd +
|
||||||
|
"@SBINPATH@/ip" link set lo up
|
||||||
|
}
|
||||||
|
|
|
@ -3,5 +3,7 @@ type wait
|
||||||
target boot
|
target boot
|
||||||
before vfs
|
before vfs
|
||||||
|
|
||||||
exec "@SBINPATH@/mount" -t proc proc /proc
|
exec {
|
||||||
exec "@SCRIPTDIR@/trymount.sh" "/proc/sys/fs/binfmt_misc" "binfmt_misc" "nodev,noexec,nosuid"
|
"@SBINPATH@/mount" -t proc proc /proc
|
||||||
|
"@SCRIPTDIR@/trymount.sh" /proc/sys/fs/binfmt_misc binfmt_misc nodev,noexec,nosuid
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
description send SIGTERM to all processes
|
description send SIGTERM to all processes
|
||||||
exec "@SCRIPTDIR@/killall5" 15
|
|
||||||
exec "@BINPATH@/sleep" 5
|
|
||||||
type wait
|
type wait
|
||||||
target %0
|
target %0
|
||||||
before sigkill sync reboot shutdown
|
before sigkill sync reboot shutdown
|
||||||
|
|
||||||
|
exec {
|
||||||
|
"@SCRIPTDIR@/killall5" 15
|
||||||
|
"@BINPATH@/sleep" 5
|
||||||
|
}
|
||||||
|
|
|
@ -4,8 +4,10 @@ target boot
|
||||||
after procfs
|
after procfs
|
||||||
before vfs
|
before vfs
|
||||||
|
|
||||||
exec "@SBINPATH@/mount" -t sysfs sysfs /sys
|
exec {
|
||||||
exec "@SCRIPTDIR@/trymount.sh" "/sys/kernel/security" "securityfs" "nodev,noexec,nosuid"
|
"@SBINPATH@/mount" -t sysfs sysfs /sys
|
||||||
exec "@SCRIPTDIR@/trymount.sh" "/sys/kernel/config" "configfs" "nodev,noexec,nosuid"
|
"@SCRIPTDIR@/trymount.sh" /sys/kernel/security securityfs nodev,noexec,nosuid
|
||||||
exec "@SCRIPTDIR@/trymount.sh" "/sys/fs/fuse/connections" "fusectl" "nodev,noexec,nosuid"
|
"@SCRIPTDIR@/trymount.sh" /sys/kernel/config configfs nodev,noexec,nosuid
|
||||||
exec "@SCRIPTDIR@/trymount.sh" "/sys/firmware/efi/efivars" "efivarfs" "ro"
|
"@SCRIPTDIR@/trymount.sh" /sys/fs/fuse/connections fusectl nodev,noexec,nosuid
|
||||||
|
"@SCRIPTDIR@/trymount.sh" /sys/firmware/efi/efivars efivarfs ro
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ type wait
|
||||||
target boot
|
target boot
|
||||||
before vfs
|
before vfs
|
||||||
after tmpfsvar
|
after tmpfsvar
|
||||||
exec "@SBINPATH@/mount" -t tmpfs none /run
|
exec {
|
||||||
exec "@BINPATH@/mkdir" /run/lock -m 0755
|
"@SBINPATH@/mount" -t tmpfs none /run
|
||||||
exec "@BINPATH@/ln" -s /run /var/run
|
"@BINPATH@/mkdir" /run/lock -m 0755
|
||||||
exec "@BINPATH@/ln" -s /run/lock /var/lock
|
"@BINPATH@/ln" -s /run /var/run
|
||||||
|
"@BINPATH@/ln" -s /run/lock /var/lock
|
||||||
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@ description "mount /var"
|
||||||
type wait
|
type wait
|
||||||
target boot
|
target boot
|
||||||
before vfs
|
before vfs
|
||||||
exec "@SBINPATH@/mount" -t tmpfs none /var
|
exec {
|
||||||
exec "@BINPATH@/mkdir" /var/log -m 0755
|
"@SBINPATH@/mount" -t tmpfs none /var
|
||||||
exec "@BINPATH@/mkdir" /var/spool -m 0755
|
"@BINPATH@/mkdir" /var/log -m 0755
|
||||||
exec "@BINPATH@/mkdir" /var/lib -m 0755
|
"@BINPATH@/mkdir" /var/spool -m 0755
|
||||||
exec "@BINPATH@/mkdir" /var/tmp -m 0755
|
"@BINPATH@/mkdir" /var/lib -m 0755
|
||||||
exec "@SCRIPTDIR@/overlay.sh" var_lib /var/lib
|
"@BINPATH@/mkdir" /var/tmp -m 0755
|
||||||
|
"@SCRIPTDIR@/overlay.sh" var_lib /var/lib
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue