summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-08-24 16:59:28 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-08-24 21:17:31 +0200
commit066efaa33e7641d378ac4d8a1419a525df6f70d2 (patch)
tree0ad5b67757d876cd9db6fe58de796a44f57d78c9
parent2d54b32d2406de4ad624c011bf4b30ed45dabdaf (diff)
initd: automatically do a shutdown/reboot when the target is completed
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
-rw-r--r--Makefile.am2
-rw-r--r--initd/main.c8
-rw-r--r--services/Makemodule.am7
-rw-r--r--services/reboot5
-rw-r--r--services/shutdown5
5 files changed, 10 insertions, 17 deletions
diff --git a/Makefile.am b/Makefile.am
index 1a34912..f8d6c04 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,8 +38,6 @@ install-data-local:
$(LN_S) $(TEMPLATEDIR)/devfs $(DESTDIR)$(SVCDIR)/devfs
$(LN_S) $(TEMPLATEDIR)/tmpfs $(DESTDIR)$(SVCDIR)/tmpfs
$(LN_S) $(TEMPLATEDIR)/vfs $(DESTDIR)$(SVCDIR)/vfs
- $(LN_S) $(TEMPLATEDIR)/shutdown $(DESTDIR)$(SVCDIR)/shutdown
- $(LN_S) $(TEMPLATEDIR)/reboot $(DESTDIR)$(SVCDIR)/reboot
$(LN_S) $(TEMPLATEDIR)/ifdown $(DESTDIR)$(SVCDIR)/ifdown@shutdown
$(LN_S) $(TEMPLATEDIR)/sync $(DESTDIR)$(SVCDIR)/sync@shutdown
$(LN_S) $(TEMPLATEDIR)/sigkill $(DESTDIR)$(SVCDIR)/sigkill@shutdown
diff --git a/initd/main.c b/initd/main.c
index 08e314f..b50c09c 100644
--- a/initd/main.c
+++ b/initd/main.c
@@ -103,7 +103,13 @@ void target_completed(int target)
if (ti_sock == -1)
ti_sock = mksock(INITSOCK, SOCK_FLAG_ROOT_ONLY);
break;
- default:
+ case TGT_SHUTDOWN:
+ for (;;)
+ reboot(RB_POWER_OFF);
+ break;
+ case TGT_REBOOT:
+ for (;;)
+ reboot(RB_AUTOBOOT);
break;
}
}
diff --git a/services/Makemodule.am b/services/Makemodule.am
index ab79414..5b12ca4 100644
--- a/services/Makemodule.am
+++ b/services/Makemodule.am
@@ -1,21 +1,20 @@
initdir = @TEMPLATEDIR@
init_DATA = services/agetty services/hostname services/loopback
init_DATA += services/sysctl services/hwclock services/sysinit
-init_DATA += services/reboot services/shutdown services/sigkill
init_DATA += services/sigterm services/sync services/devfs
init_DATA += services/sysfs services/procfs services/tmpfs
init_DATA += services/vfs services/ifrename services/ifcfg
init_DATA += services/dhcpcd services/dhcpcdmaster services/unbound
init_DATA += services/dnsmasq services/ifdown services/modules
init_DATA += services/network services/hostapd services/swclock
-init_DATA += services/swclocksave services/nft
+init_DATA += services/swclocksave services/nft services/sigkill
if USYSLOGD
init_DATA += services/usyslogd
endif
EXTRA_DIST += services/sysinit services/vfs services/agetty services/hostname
-EXTRA_DIST += services/hwclock services/loopback services/reboot
-EXTRA_DIST += services/shutdown services/sync services/sysctl services/tmpfs
+EXTRA_DIST += services/hwclock services/loopback
+EXTRA_DIST += services/sync services/sysctl services/tmpfs
EXTRA_DIST += services/dhcpcd services/dhcpcdmaster services/unbound
EXTRA_DIST += services/usyslogd services/dnsmasq services/network
diff --git a/services/reboot b/services/reboot
deleted file mode 100644
index 65a8eac..0000000
--- a/services/reboot
+++ /dev/null
@@ -1,5 +0,0 @@
-description system reboot
-exec shutdown -nrf
-type wait
-target reboot
-after sync sigkill sigterm
diff --git a/services/shutdown b/services/shutdown
deleted file mode 100644
index 679ffbd..0000000
--- a/services/shutdown
+++ /dev/null
@@ -1,5 +0,0 @@
-description system shutdown
-exec shutdown -npf
-type wait
-target shutdown
-after sync sigkill sigterm