Also that was wrong

This commit is contained in:
Jack L. Frost 2016-04-14 17:58:33 +03:00
parent 6f063dc4bf
commit 8d5c19d7bf
1 changed files with 15 additions and 8 deletions

View File

@ -2,11 +2,21 @@
usage() { echo "Usage: shutdown <-p|-r>"; }
_poweroff() {
echo 'Shutting down.'
init_signal=USR1
}
_reboot() {
echo 'Rebooting.'
init_signal='INT'
}
main() {
while [ "$1" ]; do
case "$1" in
-p|--poweroff) init_signal='10';;
-r|--reboot) init_signal='2';;
-p|--poweroff) _poweroff;;
-r|--reboot) _reboot;;
-h|--help|--usage) usage; return;;
*) usage; return 1
@ -16,19 +26,16 @@ main() {
exe_name="${0##*/}"
[ "$init_signal" ] || {
if [ -z "$init_signal" ]; then
case "$exe_name" in
poweroff)
echo 'Shutting down.'
init_signal='USR1';;
poweroff) poff;;
reboot)
echo 'Rebooting.'
init_signal='INT';;
*) usage; return 1;;
esac
}
fi
kill -s "$init_signal" 1
}