scripts/deploy: add --force-reboot
option
This commit is contained in:
@@ -14,6 +14,7 @@ usage() {
|
|||||||
echo "- --dry-run: show what would be done without actually doing it"
|
echo "- --dry-run: show what would be done without actually doing it"
|
||||||
echo "- --pre: alias for --action copy --variant all all"
|
echo "- --pre: alias for --action copy --variant all all"
|
||||||
echo "- --reboot: reboot the target machine after deploying (if deployed with no errors)"
|
echo "- --reboot: reboot the target machine after deploying (if deployed with no errors)"
|
||||||
|
echo "- --reboot-force: reboot the target machine after deploying (even on error)"
|
||||||
echo "- --variant light|min|''|all (default: '')"
|
echo "- --variant light|min|''|all (default: '')"
|
||||||
echo "- --wireguard always|never|opportunistic: deploy over wireguard"
|
echo "- --wireguard always|never|opportunistic: deploy over wireguard"
|
||||||
echo "- --ip <address>: deploy to the specific IP address"
|
echo "- --ip <address>: deploy to the specific IP address"
|
||||||
@@ -39,6 +40,7 @@ variants=()
|
|||||||
defaultVariant=
|
defaultVariant=
|
||||||
nixArgs=()
|
nixArgs=()
|
||||||
doReboot=
|
doReboot=
|
||||||
|
doRebootForce=
|
||||||
dryRun=
|
dryRun=
|
||||||
wireguard=opportunistic
|
wireguard=opportunistic
|
||||||
storePath=
|
storePath=
|
||||||
@@ -90,6 +92,10 @@ parseArgs() {
|
|||||||
(--reboot)
|
(--reboot)
|
||||||
doReboot=1
|
doReboot=1
|
||||||
;;
|
;;
|
||||||
|
(--reboot-force)
|
||||||
|
doReboot=1
|
||||||
|
doRebootForce=1
|
||||||
|
;;
|
||||||
(--variant)
|
(--variant)
|
||||||
addVariant "$1"
|
addVariant "$1"
|
||||||
shift
|
shift
|
||||||
@@ -211,11 +217,13 @@ deployOneHost() {
|
|||||||
if [ -n "$action" ] && [ "$action" != "copy" ]; then
|
if [ -n "$action" ] && [ "$action" != "copy" ]; then
|
||||||
info "activating profile... "
|
info "activating profile... "
|
||||||
destructive runOnTarget "$netHost" sudo nix-env -p /nix/var/nix/profiles/system --set "$myStorePath" || return 1
|
destructive runOnTarget "$netHost" sudo nix-env -p /nix/var/nix/profiles/system --set "$myStorePath" || return 1
|
||||||
destructive runOnTarget "$netHost" sudo "$myStorePath/bin/switch-to-configuration" "$action" || return 1
|
destructive runOnTarget "$netHost" sudo "$myStorePath/bin/switch-to-configuration" "$action"
|
||||||
if [ -n "$doReboot" ]; then
|
local rc=$?
|
||||||
|
if [[ -n "$doReboot" && ("$rc" -eq 0 || -n "$doRebootForce") ]]; then
|
||||||
info "rebooting $host"
|
info "rebooting $host"
|
||||||
destructive runOnTarget "$netHost" sane-reboot "$host"
|
destructive runOnTarget "$netHost" sane-reboot "$host" || return 1
|
||||||
fi
|
fi
|
||||||
|
return $rc
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user