1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-11-05 20:27:09 +01:00

initd: automatically do a shutdown/reboot when the target is completed

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-08-24 16:59:28 +02:00
parent 2d54b32d24
commit 066efaa33e
5 changed files with 10 additions and 17 deletions

View file

@ -38,8 +38,6 @@ install-data-local:
$(LN_S) $(TEMPLATEDIR)/devfs $(DESTDIR)$(SVCDIR)/devfs $(LN_S) $(TEMPLATEDIR)/devfs $(DESTDIR)$(SVCDIR)/devfs
$(LN_S) $(TEMPLATEDIR)/tmpfs $(DESTDIR)$(SVCDIR)/tmpfs $(LN_S) $(TEMPLATEDIR)/tmpfs $(DESTDIR)$(SVCDIR)/tmpfs
$(LN_S) $(TEMPLATEDIR)/vfs $(DESTDIR)$(SVCDIR)/vfs $(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)/ifdown $(DESTDIR)$(SVCDIR)/ifdown@shutdown
$(LN_S) $(TEMPLATEDIR)/sync $(DESTDIR)$(SVCDIR)/sync@shutdown $(LN_S) $(TEMPLATEDIR)/sync $(DESTDIR)$(SVCDIR)/sync@shutdown
$(LN_S) $(TEMPLATEDIR)/sigkill $(DESTDIR)$(SVCDIR)/sigkill@shutdown $(LN_S) $(TEMPLATEDIR)/sigkill $(DESTDIR)$(SVCDIR)/sigkill@shutdown

View file

@ -103,7 +103,13 @@ void target_completed(int target)
if (ti_sock == -1) if (ti_sock == -1)
ti_sock = mksock(INITSOCK, SOCK_FLAG_ROOT_ONLY); ti_sock = mksock(INITSOCK, SOCK_FLAG_ROOT_ONLY);
break; break;
default: case TGT_SHUTDOWN:
for (;;)
reboot(RB_POWER_OFF);
break;
case TGT_REBOOT:
for (;;)
reboot(RB_AUTOBOOT);
break; break;
} }
} }

View file

@ -1,21 +1,20 @@
initdir = @TEMPLATEDIR@ initdir = @TEMPLATEDIR@
init_DATA = services/agetty services/hostname services/loopback init_DATA = services/agetty services/hostname services/loopback
init_DATA += services/sysctl services/hwclock services/sysinit 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/sigterm services/sync services/devfs
init_DATA += services/sysfs services/procfs services/tmpfs init_DATA += services/sysfs services/procfs services/tmpfs
init_DATA += services/vfs services/ifrename services/ifcfg init_DATA += services/vfs services/ifrename services/ifcfg
init_DATA += services/dhcpcd services/dhcpcdmaster services/unbound init_DATA += services/dhcpcd services/dhcpcdmaster services/unbound
init_DATA += services/dnsmasq services/ifdown services/modules init_DATA += services/dnsmasq services/ifdown services/modules
init_DATA += services/network services/hostapd services/swclock init_DATA += services/network services/hostapd services/swclock
init_DATA += services/swclocksave services/nft init_DATA += services/swclocksave services/nft services/sigkill
if USYSLOGD if USYSLOGD
init_DATA += services/usyslogd init_DATA += services/usyslogd
endif endif
EXTRA_DIST += services/sysinit services/vfs services/agetty services/hostname EXTRA_DIST += services/sysinit services/vfs services/agetty services/hostname
EXTRA_DIST += services/hwclock services/loopback services/reboot EXTRA_DIST += services/hwclock services/loopback
EXTRA_DIST += services/shutdown services/sync services/sysctl services/tmpfs EXTRA_DIST += services/sync services/sysctl services/tmpfs
EXTRA_DIST += services/dhcpcd services/dhcpcdmaster services/unbound EXTRA_DIST += services/dhcpcd services/dhcpcdmaster services/unbound
EXTRA_DIST += services/usyslogd services/dnsmasq services/network EXTRA_DIST += services/usyslogd services/dnsmasq services/network

View file

@ -1,5 +0,0 @@
description system reboot
exec shutdown -nrf
type wait
target reboot
after sync sigkill sigterm

View file

@ -1,5 +0,0 @@
description system shutdown
exec shutdown -npf
type wait
target shutdown
after sync sigkill sigterm