diff --git a/scripts/deploy b/scripts/deploy index de1ede02b..696629a34 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -14,6 +14,7 @@ usage() { echo "- --dry-run: show what would be done without actually doing it" echo "- --pre: alias for --action copy --variant all all" 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 "- --wireguard always|never|opportunistic: deploy over wireguard" echo "- --ip
: deploy to the specific IP address" @@ -39,6 +40,7 @@ variants=() defaultVariant= nixArgs=() doReboot= +doRebootForce= dryRun= wireguard=opportunistic storePath= @@ -90,6 +92,10 @@ parseArgs() { (--reboot) doReboot=1 ;; + (--reboot-force) + doReboot=1 + doRebootForce=1 + ;; (--variant) addVariant "$1" shift @@ -211,11 +217,13 @@ deployOneHost() { if [ -n "$action" ] && [ "$action" != "copy" ]; then info "activating profile... " 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 - if [ -n "$doReboot" ]; then + destructive runOnTarget "$netHost" sudo "$myStorePath/bin/switch-to-configuration" "$action" + local rc=$? + if [[ -n "$doReboot" && ("$rc" -eq 0 || -n "$doRebootForce") ]]; then info "rebooting $host" - destructive runOnTarget "$netHost" sane-reboot "$host" + destructive runOnTarget "$netHost" sane-reboot "$host" || return 1 fi + return $rc fi }