4 Commits
1.0.2 ... 1.0.6

Author SHA1 Message Date
fbt
376b78e935 How did that happen 2016-04-14 18:01:14 +03:00
fbt
8d5c19d7bf Also that was wrong 2016-04-14 17:58:33 +03:00
fbt
6f063dc4bf Don't be completely silent, people think it's not working 2016-04-14 17:56:00 +03:00
fbt
ea6348fb99 license 2014-10-16 13:28:18 +04:00
2 changed files with 30 additions and 6 deletions

13
LICENSE Normal file
View 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.

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,13 +26,14 @@ main() {
exe_name="${0##*/}"
[ "$init_signal" ] || {
if [ -z "$init_signal" ]; then
case "$exe_name" in
poweroff) init_signal='USR1';;
reboot) init_signal='INT';;
poweroff) _poweroff;;
reboot) _reboot;;
*) usage; return 1;;
esac
}
fi
kill -s "$init_signal" 1
}