commit eef7392bff5be9d2f27c07e0ae7ce01811660f2c Author: fbt Date: Tue Apr 30 19:12:30 2019 +0300 Fixing a borked repo Signed-off-by: fbt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..94998e0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2012-2014, Jack L. Frost + + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a4386b8 --- /dev/null +++ b/README.md @@ -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. diff --git a/shutdown b/shutdown new file mode 100755 index 0000000..0984d3b --- /dev/null +++ b/shutdown @@ -0,0 +1,41 @@ +#!/bin/sh + +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) _poweroff;; + -r|--reboot) _reboot;; + + -h|--help|--usage) usage; return;; + *) usage; return 1 + esac + shift + done + + exe_name="${0##*/}" + + if [ -z "$init_signal" ]; then + case "$exe_name" in + poweroff) _poweroff;; + reboot) _reboot;; + + *) usage; return 1;; + esac + fi + + kill -s "$init_signal" 1 +} + +main "$@"