System Shutdown Script
Copyright (c) 2012, 2017, 2020 Ma_Sys.ma. For further info send an e-mail to Ma_Sys.email@example.com.
mahalt -- Shutdown system after invoking scripts.
mahalt [-f] [-r]
This script is intended to serve as a means of shutting down desktop systems.
The following features are added compared to a direct invocation of
systemctl poweroff (or similar):
- Regular users should be able to invoke shutdown. By including sudo configuration and a means to automatically restart the script with sudo, it becomes possible for users to conveniently invoke the script.
- To perform backups and other tasks that are best run individually without
other services interfering, directory
/usr/lib/mahalt.dis consulted for executable files. They are executed in the order reported by
find | sort.
- Before invoking the actual shutdown command, all Java applications are sent
- If immediately before invoking the actual shutdown,
/tmp/nohaltexists, the process is cancelled. This feature can be used by the scripts in
/usr/lib/mahalt.dor by users on the local machine who wish to interrupt the shutdown process without cancelling any of the running hooks from
Notes on hooks
- All executables form
/usr/lib/mahalt.dare passed parameter
- Outputs from hooks are written to file
/var/log/mahaltand can thus be analyzed after the next reboot.
WARNING: Sudo Configuration Included
This package includes a sudoers configuration allowing user
mahalt command which makes a
shutdown-style command available to a
user. Beware that this is not expected to be a safe operation on servers as
regular users may not have physical access.
-f Fast -- skip execution of hooks from
-r Reboot instead of shutdown
Similar to vifm-ext(32), this script could have been
written in a manner that would have avoided the use of sudo/full-blown root
privileges for shutdown. Modern desktop environments use
to invoke shutdown and the regular
systemctl poweroff nowdays often works for
unprivileged users if systemd detects that they are the only ones logged in to
the local system.
This route was not taken for the following reasons:
- Similar to mounting, the interface for “shutdown without root” often broke between release upgrades.
- Ma_Sys.ma Backups run as root as to avoid the problem of files being inaccessible due to missing permissions. Hence, that part would need to run with sudo anyways.
- File names from below
/usr/lib/mahalt.dmay not contain spaces.
killall -s TERM javainvocation may stop some processes that should better be managed by their respective “supervisors” like systemd or docker...