.gitignore | ||
Makefile | ||
poweroff_guard.8 | ||
poweroff_guard.c | ||
README.md |
poweroff_guard
This utility is a proxy for poweroff
to prevent you from accidentally shutting down
the wrong system. It does this by printing a warning message and asking for confirmation
followed by a countdown before executing the actual command.
It is most useful when creating an alias for poweroff
in your shell, like:
alias poweroff=/usr/local/sbin/poweroff_guard
Important Consideration
If the standard output is not a tty, this behaves exactly like the regular poweroff
.
Build
Open a shell in this directory and type make
.
Optionally, you may want to append any of the following options:
POWEROFF_PATH=/path/to/poweroff
: Specify a custom (absolute) path for the the realpoweroff
command. The default is to use the one in your$PATH
.COUNTDOWN_SECS=n
: Start the countdown timer atn
seconds, the default is 10.EXTRA_CFLAGS=...
: Append extra flags to the C compiler.
For example:
# build with default options
make
# build with all custom options
make \
POWEROFF_PATH=/bin/custom_poweroff \
COUNTDOWN_SECS=5 \
EXTRA_CFLAGS="-O2 -march=native"
Watch out:
If you want to recompile with different options, you MUST execute a make clean
first.
Make will erroneously think the binary is already up to date otherwise.
Installation
Do the exact same as building, but append install
at the end of the command.
For example:
# build and install with default options
make install
# build and install with all custom options
make \
POWEROFF_PATH=/sbin/custom_poweroff \
COUNTDOWN_SECS=5 \
EXTRA_CFLAGS="-O2 -march=native" \
install
License and Copyright
Copyright © 2022 anna .
This program is licensed under the 2-clause BSD license.
The license text is at the end of the poweroff_guard.c
file.