nix-files/pkgs/additional/sane-scripts/src/sane-reboot
Colin c50a4d1d71 static-nix-shell: fix mkBash scripts to actually be invokable from the CLI
they need the `bash` package! how did this work before?
2024-06-15 07:42:04 +00:00

19 lines
458 B
Plaintext
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p nettools -p systemd
target="$1"
shift
host="$(hostname)"
if [ "$host" = "$target" ]
then
# N.B.: anything other than just `reboot` with no args requires `sudo` privileges (to write to /run/systemd/).
# `systemctl reboot -i` tells systemd to ignore inhibitors (i.e. other users logged in).
reboot "$@" || \
systemctl reboot -i "$@"
else
echo "WRONG MACHINE. you're on $host."
exit 1
fi