1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-05-19 04:06:13 +02:00

Deduce service name from file name

Remove redundant name keyword from service files

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-03-26 01:05:17 +02:00
parent 160ef94e8b
commit dc5afbc771
12 changed files with 13 additions and 20 deletions

View file

@ -28,14 +28,6 @@
#include "service.h"
#include "util.h"
static int svc_name(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
(void)filename; (void)lineno;
svc->name = arg;
return 0;
}
static int svc_desc(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
@ -166,7 +158,6 @@ static const struct {
int (*handle)(service_t *svc, char *arg,
const char *filename, size_t lineno);
} svc_params[] = {
{ "name", svc_name },
{ "description", svc_desc },
{ "exec", svc_exec },
{ "type", svc_type },
@ -207,6 +198,19 @@ service_t *rdsvc(int dirfd, const char *filename)
return NULL;
}
if (arg != NULL) {
svc->name = strndup(filename, arg - filename);
} else {
svc->name = strdup(filename);
}
if (svc->name == NULL) {
free(svc);
fputs("out of memory\n", stderr);
close(fd);
return NULL;
}
for (lineno = 1; ; ++lineno) {
errno = 0;
line = rdline(fd);

View file

@ -1,4 +1,3 @@
name = "agetty"
description = "agetty on %0"
exec = "@SBINPATH@/agetty %0 linux"
type = respawn

View file

@ -1,4 +1,3 @@
name = "hostname"
description = "reload hostname"
exec = "@BINPATH@/hostname --file /etc/hostname"
type = wait

View file

@ -1,4 +1,3 @@
name = "hwclock"
description = "restore time from RTC"
exec = "@SBINPATH@/hwclock --hctosys --utc"
type = wait

View file

@ -1,4 +1,3 @@
name = "loopback"
description = "configure network loopback device"
type = wait
target = boot

View file

@ -1,4 +1,3 @@
name = "reboot"
description = "system reboot"
exec = "@SBINPATH@/shutdown -nrf"
type = wait

View file

@ -1,4 +1,3 @@
name = "shutdown"
description = "system shutdown"
exec = "@SBINPATH@/shutdown -npf"
type = wait

View file

@ -1,4 +1,3 @@
name = "sigkill"
description = "send SIGKILL to remaining processes"
exec = "@SCRIPTDIR@/killall5 9"
type = wait

View file

@ -1,4 +1,3 @@
name = "sigterm"
description = "send SIGTERM to all processes"
exec = "@SCRIPTDIR@/killall5 15"
exec = "@BINPATH@/sleep 5"

View file

@ -1,4 +1,3 @@
name = "sync"
description = "sync"
exec = "@BINPATH@/sync"
type = wait

View file

@ -1,4 +1,3 @@
name = "sysctl"
description = "configure kernel paramters"
exec = "@SBINPATH@/sysctl --system"
type = wait

View file

@ -1,4 +1,3 @@
name = "sysinit"
description = "basic system initialization"
type = once
target = boot