This commit is contained in:
Jack L. Frost 2014-10-10 18:06:14 +04:00
commit 18c88e0717
2 changed files with 39 additions and 0 deletions

9
README.md Normal file
View File

@ -0,0 +1,9 @@
sinit-tools
===========
shutdown
--------
A script that provides a familiar command to poweroff or reboot your system.
It checks the exe name, so you can just make poweroff and reboot links in your $PATH.

30
shutdown Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
usage() { echo "Usage: shutdown <-p|-r>"; }
main() {
while [ "$1" ]; do
case "$1" in
-p|--poweroff) init_signal='10';;
-r|--reboot) init_signal='2';;
-h|--help|--usage) usage; return;;
*) usage; return 1
esac
shift
done
exe_name="${0##*/}"
[ "$init_signal" ] || {
case "$exe_name" in
poweroff) init_signal='USR1';;
reboot) init_signal='INT';;
*) usage; return 1;;
esac
}
kill -s "$init_signal" 1
}
main "$@"