#!/usr/bin/env nix #!nix shell nixpkgs#rsync nixpkgs#zsh --command zsh setopt ERR_EXIT PIPE_FAIL # load module to parse command line arguments zmodload zsh/zutil # parse any possible additional drive declarations zparseopts -D -E -A opts -- h x # enable XTRACE shell option for full debugging output of scripts if (( ${+opts[-x]} )); then set -x fi DIR="${0:h}" FLAKE="https://arrakis.bitgnome.net/nipsy/git/nix/" HOSTNAME="${1}" TARGET="${2}" if [[ -z "${TARGET}" ]] || (( ${+opts[-h]} )); then <&2 usage: ${0:t} [ -h ] [ -x ] hostname target -h this message -x enable shell debug hostname hostname of nixosConfigurations defined host in our flake target PXE booted, SSH root accessible, installation target EOF exit 1 fi <&2 ssh root@${TARGET} mount | grep -v zfs | awk '$3 ~ /^\/mnt\// {print $3}' | xargs -i{} ssh root@${TARGET} umount -lf {} echo 'Unmounting ZFS file systems...' >&2 while ! ssh root@${TARGET} umount -t zfs -a; do echo 'attempting to umount all ZFS file systems' >&2; sleep 1; done echo 'Exporting zpool...' >&2 while ! ssh root@${TARGET} zpool export -a; do echo 'attempting to export all zpools' >&2; sleep 1; done echo 'Rebooting!' >&2 ssh root@${TARGET} reboot fi fi