script appears to work
This commit is contained in:
parent
974418bf8c
commit
9d7df09ba1
|
@ -13,6 +13,8 @@ echo " image: ${qcow2}"
|
|||
|
||||
sleep 5
|
||||
|
||||
build_nixos_vm () {
|
||||
|
||||
echo "[+] updating NixOS config"
|
||||
cd /etc/nixos
|
||||
doas git pull --rebase local master
|
||||
|
@ -53,7 +55,47 @@ doas mount /dev/nbd0 "${mount_point}"
|
|||
rsync --progress -auvz "${HOME}/" "${mount_point}/home/kyle/"
|
||||
|
||||
echo "[+] finished, cleaning up"
|
||||
doas unmount "${mount_point}"
|
||||
doas umount "${mount_point}"
|
||||
doas qemu-nbd --disconnect /dev/nbd0
|
||||
doas rmdir "${mount_point}"
|
||||
doas rm -r "${build_dir}"
|
||||
}
|
||||
|
||||
cleanup () {
|
||||
if [[ -d "${build_dir}" ]]
|
||||
then
|
||||
echo "[+] removing ${build_dir}"
|
||||
sleep 2
|
||||
rm -r "${build_dir}"
|
||||
fi
|
||||
|
||||
if [[ ! -z "$(mount | grep /dev/nbd0)" ]]
|
||||
then
|
||||
echo "[+] unmounting network block device"
|
||||
doas umount /dev/nbd0
|
||||
fi
|
||||
|
||||
echo "[+] disconnecting network block device"
|
||||
echo " it's okay if this fails"
|
||||
doas qemu-nbd --disconnect /dev/nbd0
|
||||
|
||||
if [[ -d "${mount_point}" ]]
|
||||
then
|
||||
echo "[+] removing ${mount_point}"
|
||||
sleep 2
|
||||
rm -r "${mount_point}"
|
||||
fi
|
||||
}
|
||||
|
||||
case "${1:-build}" in
|
||||
build)
|
||||
build_nixos_vm
|
||||
;;
|
||||
cleanup)
|
||||
cleanup
|
||||
;;
|
||||
*)
|
||||
echo "[!] Valid commands are build, cleanup"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue