Compare commits
No commits in common. "1.0.2" and "master" have entirely different histories.
13
LICENSE
Normal file
13
LICENSE
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Copyright (c) 2012-2014, Jack L. Frost <fbt@fleshless.org>
|
||||||
|
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without
|
||||||
|
fee is hereby granted, provided that the above copyright notice and this permission notice appear
|
||||||
|
in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||||
|
SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||||
|
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
OF THIS SOFTWARE.
|
23
shutdown
23
shutdown
@ -2,11 +2,21 @@
|
|||||||
|
|
||||||
usage() { echo "Usage: shutdown <-p|-r>"; }
|
usage() { echo "Usage: shutdown <-p|-r>"; }
|
||||||
|
|
||||||
|
_poweroff() {
|
||||||
|
echo 'Shutting down.'
|
||||||
|
init_signal=USR1
|
||||||
|
}
|
||||||
|
|
||||||
|
_reboot() {
|
||||||
|
echo 'Rebooting.'
|
||||||
|
init_signal='INT'
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
while [ "$1" ]; do
|
while [ "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-p|--poweroff) init_signal='10';;
|
-p|--poweroff) _poweroff;;
|
||||||
-r|--reboot) init_signal='2';;
|
-r|--reboot) _reboot;;
|
||||||
|
|
||||||
-h|--help|--usage) usage; return;;
|
-h|--help|--usage) usage; return;;
|
||||||
*) usage; return 1
|
*) usage; return 1
|
||||||
@ -16,13 +26,14 @@ main() {
|
|||||||
|
|
||||||
exe_name="${0##*/}"
|
exe_name="${0##*/}"
|
||||||
|
|
||||||
[ "$init_signal" ] || {
|
if [ -z "$init_signal" ]; then
|
||||||
case "$exe_name" in
|
case "$exe_name" in
|
||||||
poweroff) init_signal='USR1';;
|
poweroff) _poweroff;;
|
||||||
reboot) init_signal='INT';;
|
reboot) _reboot;;
|
||||||
|
|
||||||
*) usage; return 1;;
|
*) usage; return 1;;
|
||||||
esac
|
esac
|
||||||
}
|
fi
|
||||||
|
|
||||||
kill -s "$init_signal" 1
|
kill -s "$init_signal" 1
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user