summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-26 01:05:17 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-26 01:08:42 +0200
commitdc5afbc7712b49ec130088d0ccae327db61bd97b (patch)
tree0c485fe2f058b9fff0b970b9df626d80aee306ca
parent160ef94e8b6aa580225555a9c38a99af2d4e27d2 (diff)
Deduce service name from file name
Remove redundant name keyword from service files Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
-rw-r--r--lib/src/rdsvc.c22
-rw-r--r--services/agetty.in1
-rw-r--r--services/hostname.in1
-rw-r--r--services/hwclock.in1
-rw-r--r--services/loopback.in1
-rw-r--r--services/reboot.in1
-rw-r--r--services/shutdown.in1
-rw-r--r--services/sigkill.in1
-rw-r--r--services/sigterm.in1
-rw-r--r--services/sync.in1
-rwxr-xr-xservices/sysctl.in1
-rw-r--r--services/sysinit1
12 files changed, 13 insertions, 20 deletions
diff --git a/lib/src/rdsvc.c b/lib/src/rdsvc.c
index 54c6d24..ee898c3 100644
--- a/lib/src/rdsvc.c
+++ b/lib/src/rdsvc.c
@@ -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);
diff --git a/services/agetty.in b/services/agetty.in
index b4aeebd..c0ae21b 100644
--- a/services/agetty.in
+++ b/services/agetty.in
@@ -1,4 +1,3 @@
-name = "agetty"
description = "agetty on %0"
exec = "@SBINPATH@/agetty %0 linux"
type = respawn
diff --git a/services/hostname.in b/services/hostname.in
index 4ff5acd..be0020d 100644
--- a/services/hostname.in
+++ b/services/hostname.in
@@ -1,4 +1,3 @@
-name = "hostname"
description = "reload hostname"
exec = "@BINPATH@/hostname --file /etc/hostname"
type = wait
diff --git a/services/hwclock.in b/services/hwclock.in
index b558493..e8a2513 100644
--- a/services/hwclock.in
+++ b/services/hwclock.in
@@ -1,4 +1,3 @@
-name = "hwclock"
description = "restore time from RTC"
exec = "@SBINPATH@/hwclock --hctosys --utc"
type = wait
diff --git a/services/loopback.in b/services/loopback.in
index 2720e3c..741ed1c 100644
--- a/services/loopback.in
+++ b/services/loopback.in
@@ -1,4 +1,3 @@
-name = "loopback"
description = "configure network loopback device"
type = wait
target = boot
diff --git a/services/reboot.in b/services/reboot.in
index f913013..94d1b78 100644
--- a/services/reboot.in
+++ b/services/reboot.in
@@ -1,4 +1,3 @@
-name = "reboot"
description = "system reboot"
exec = "@SBINPATH@/shutdown -nrf"
type = wait
diff --git a/services/shutdown.in b/services/shutdown.in
index c97cde9..560dd47 100644
--- a/services/shutdown.in
+++ b/services/shutdown.in
@@ -1,4 +1,3 @@
-name = "shutdown"
description = "system shutdown"
exec = "@SBINPATH@/shutdown -npf"
type = wait
diff --git a/services/sigkill.in b/services/sigkill.in
index 24677e4..10e96b4 100644
--- a/services/sigkill.in
+++ b/services/sigkill.in
@@ -1,4 +1,3 @@
-name = "sigkill"
description = "send SIGKILL to remaining processes"
exec = "@SCRIPTDIR@/killall5 9"
type = wait
diff --git a/services/sigterm.in b/services/sigterm.in
index c98e037..126d144 100644
--- a/services/sigterm.in
+++ b/services/sigterm.in
@@ -1,4 +1,3 @@
-name = "sigterm"
description = "send SIGTERM to all processes"
exec = "@SCRIPTDIR@/killall5 15"
exec = "@BINPATH@/sleep 5"
diff --git a/services/sync.in b/services/sync.in
index 7371b56..69571cf 100644
--- a/services/sync.in
+++ b/services/sync.in
@@ -1,4 +1,3 @@
-name = "sync"
description = "sync"
exec = "@BINPATH@/sync"
type = wait
diff --git a/services/sysctl.in b/services/sysctl.in
index 5f76328..cd7b217 100755
--- a/services/sysctl.in
+++ b/services/sysctl.in
@@ -1,4 +1,3 @@
-name = "sysctl"
description = "configure kernel paramters"
exec = "@SBINPATH@/sysctl --system"
type = wait
diff --git a/services/sysinit b/services/sysinit
index 37645a5..12e5c55 100644
--- a/services/sysinit
+++ b/services/sysinit
@@ -1,4 +1,3 @@
-name = "sysinit"
description = "basic system initialization"
type = once
target = boot