Also that was wrong
This commit is contained in:
parent
6f063dc4bf
commit
8d5c19d7bf
23
shutdown
23
shutdown
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user