1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-11-22 11:19:45 +01: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 "service.h"
#include "util.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, static int svc_desc(service_t *svc, char *arg,
const char *filename, size_t lineno) const char *filename, size_t lineno)
{ {
@ -166,7 +158,6 @@ static const struct {
int (*handle)(service_t *svc, char *arg, int (*handle)(service_t *svc, char *arg,
const char *filename, size_t lineno); const char *filename, size_t lineno);
} svc_params[] = { } svc_params[] = {
{ "name", svc_name },
{ "description", svc_desc }, { "description", svc_desc },
{ "exec", svc_exec }, { "exec", svc_exec },
{ "type", svc_type }, { "type", svc_type },
@ -207,6 +198,19 @@ service_t *rdsvc(int dirfd, const char *filename)
return NULL; 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) { for (lineno = 1; ; ++lineno) {
errno = 0; errno = 0;
line = rdline(fd); line = rdline(fd);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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