nixos.sh: add sending power action to target
This commit is contained in:
parent
2ebe8b6b28
commit
3a626b6429
2 changed files with 14 additions and 4 deletions
options/custom/scripts
|
@ -132,6 +132,7 @@ in {
|
||||||
nix
|
nix
|
||||||
nixos-rebuild
|
nixos-rebuild
|
||||||
nvd
|
nvd
|
||||||
|
openssh
|
||||||
systemd
|
systemd
|
||||||
])
|
])
|
||||||
(bash "power" [
|
(bash "power" [
|
||||||
|
|
|
@ -47,13 +47,22 @@ _build() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: Send to remote target if specified
|
# Use systemd to act on system
|
||||||
# Invoke systemd to shutdown system
|
|
||||||
# Assumes errexit shell option is set
|
# Assumes errexit shell option is set
|
||||||
if [[ "${argc_poweroff:-}" ]]; then
|
if [[ "${argc_poweroff:-}" ]]; then
|
||||||
sudo systemctl poweroff
|
action=(systemctl poweroff)
|
||||||
elif [[ "${argc_reboot:-}" ]]; then
|
elif [[ "${argc_reboot:-}" ]]; then
|
||||||
sudo systemctl reboot
|
action=(systemctl reboot)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Invoke action on remote target if specified
|
||||||
|
if [[ -v action ]]; then
|
||||||
|
if [[ "${argc_target:-}" ]]; then
|
||||||
|
# shellcheck disable=SC2029
|
||||||
|
ssh root@"${argc_target}" "${action[@]}"
|
||||||
|
else
|
||||||
|
sudo "${action[@]}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue