Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cemkeylan/shinit
Basic Init Daemon in POSIX sh
https://github.com/cemkeylan/shinit
daemon init posix-sh poweroff reboot shell signal
Last synced: about 2 months ago
JSON representation
Basic Init Daemon in POSIX sh
- Host: GitHub
- URL: https://github.com/cemkeylan/shinit
- Owner: cemkeylan
- License: mit
- Created: 2020-03-24T10:39:46.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T12:02:57.000Z (about 4 years ago)
- Last Synced: 2024-07-28T20:37:03.780Z (about 2 months ago)
- Topics: daemon, init, posix-sh, poweroff, reboot, shell, signal
- Language: Shell
- Homepage:
- Size: 7.81 KB
- Stars: 21
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-kiss - shinit - Basic init daemon in POSIX sh with only 5 lines of code. (Software)
README
shinit
======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/poweroff script. If
you are using Carbs Linux or KISS, you don't need to change it.You can then install with `make`.
make install
Note on halting the system
--------------------------shinit does **NOT** deal with system halting. You will need an extra utility for
that given purpose. `ubase halt` deals with this. You can also use compile
this really simple C program that tells to kernel to shutdown or reboot.``` c
#includeint
main(int argc, char *argv[])
{
switch ((int) argv[argc < 2 ? 0 : 1][0]) {
case 'p': reboot(RB_POWER_OFF); break;
case 'r': reboot(RB_AUTOBOOT); break;
default: return 1;
}
return 0;
}
```You can compile the following program to something named `halt` or whatever you
like. If you call `halt p` it will power off, if you call `halt r` it will
reboot. Just note that this needs to be at the end of your init script, because
this command will shut your computer down straight away. You can do the
following check at the end of your init script:``` sh
case "$1" in
poweroff) halt p ;;
reboot) halt r ;;
esac
```