README.md (1364B)
1 shinit 2 ====== 3 4 Basic init daemon in POSIX sh with only 5 lines of code. It supports acting upon 5 signals. 6 7 On USR1 signal it will poweroff, and on INT signal it will reboot. 8 9 10 Installing 11 ---------- 12 13 Before installing, edit the second command to use your boot/poweroff script. If 14 you are using Carbs Linux or KISS, you don't need to change it. 15 16 You can then install with `make`. 17 18 make install 19 20 21 Note on halting the system 22 -------------------------- 23 24 shinit does **NOT** deal with system halting. You will need an extra utility for 25 that given purpose. `ubase halt` deals with this. You can also use compile 26 this really simple C program that tells to kernel to shutdown or reboot. 27 28 ``` c 29 #include <sys/reboot.h> 30 31 int 32 main(int argc, char *argv[]) 33 { 34 switch ((int) argv[argc < 2 ? 0 : 1][0]) { 35 case 'p': reboot(RB_POWER_OFF); break; 36 case 'r': reboot(RB_AUTOBOOT); break; 37 default: return 1; 38 } 39 return 0; 40 } 41 ``` 42 43 You can compile the following program to something named `halt` or whatever you 44 like. If you call `halt p` it will power off, if you call `halt r` it will 45 reboot. Just note that this needs to be at the end of your init script, because 46 this command will shut your computer down straight away. You can do the 47 following check at the end of your init script: 48 49 ``` sh 50 case "$1" in 51 poweroff) halt p ;; 52 reboot) halt r ;; 53 esac 54 ```