~cemkeylan/shinit

1927bc62666cd1c3dd62bd81acb4beb926855f93 — Cem Keylan 4 years ago 9fe01a8
shinit: add shutdown script support
2 files changed, 15 insertions(+), 4 deletions(-)

M README.md
M shinit
M README.md => README.md +6 -3
@@ 1,14 1,17 @@
shinit
======

Basic init daemon in POSIX sh with only 3 lines of code.
Basic init daemon in POSIX sh with only 5 lines of code. It supports
acting upon signals.

On USR1 signal it will poweroff, and on INT signal it will reboot.


Installing
----------

Before installing, edit the second command to use your boot script. If you
are using Carbs Linux or KISS, you don't need to change it.
Before installing, edit the second command to use your boot/poweroff
script. If you are using Carbs Linux or KISS, you don't need to change it.

You can then install with `make`.


M shinit => shinit +9 -1
@@ 6,10 6,18 @@
# Run the boot script
/lib/init/rc.boot

# Add signal traps for poweroff and reboot
trap '/lib/init/rc.shutdown poweroff' USR1
trap '/lib/init/rc.shutdown reboot'   INT

# Sleep for a day. As sleep is not a builtin for every
# shell, we don't want to keep spawning processes, hence
# the long sleep time.
#
# We also don't want to run 'while :; do :; done' as
# it would lead to high cpu usage.
while :; do sleep 86400; done
#
# Since we want to trap signals, We fork and wait for the
# sleep. If sleep is not forked, signals will not be acted
# upon.
while :; do sleep 86400 & wait ; done