1
Fork 0

Update emergency script

This commit is contained in:
prescientmoon 2024-08-26 19:17:13 +02:00
parent 896bd7b217
commit b9ba99c6f4
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -3,24 +3,24 @@
#!nix-shell -i bash #!nix-shell -i bash
# Check if at least one argument is provided # Check if at least one argument is provided
if [ "$#" -eq 0 ]; then if [ "$#" != "1" ] && [ "$#" != "2" ]; then
echo "Usage: $0 <disko-mode> [action]" echo "Usage: $0 $1 <disko-mode> [action]"
exit 1 exit 1
fi fi
# Ensure correct first argument type # Ensure correct first argument type
if [ "$1" != "disko" ] && [ "$1" != "mount" ]; then if [ "$2" != "disko" ] && [ "$2" != "mount" ]; then
echo "Disko action must be either 'disko' or 'mount'" echo "Disko action must be either 'disko' or 'mount'"
exit 1 exit 1
fi fi
# Ensure correct second argument type # Ensure correct second argument type
if [ "$#" != "1" ] && [ "$2" != "install" ] && [ "$2" != "enter" ]; then if [ "$#" != "2" ] && [ "$3" != "install" ] && [ "$3" != "enter" ]; then
echo "Action must either be empty, 'install' or 'enter'" echo "Action must either be empty, 'install' or 'enter'"
exit 1 exit 1
fi fi
if mountpoint -q /hermes; then if mountpoint -q /hermes; then
echo "Keys already mounted" echo "Keys already mounted"
else else
echo "Mounting keys" echo "Mounting keys"
@ -30,18 +30,18 @@ fi
echo "Running disko" echo "Running disko"
if [ "$1" = "mount" ]; then if [ "$2" = "mount" ] && [ "$1" = "lapetus" ]; then
zpool import -lfR /mnt zroot zpool import -lfR /mnt zroot
fi fi
nix run disko -- --mode $1 ./hosts/nixos/lapetus/filesystems/partitions.nix nix run disko -- --mode $1 ./hosts/nixos/lapetus/filesystems/partitions.nix
if [ "$2" = "install" ]; then if [ "$3" = "install" ]; then
echo "Installing nixos" echo "Installing nixos"
nixos-install --flake ".#lapetus" nixos-install --flake ".#$1"
fi fi
if [ "$2" = "enter" ]; then if [ "$3" = "enter" ]; then
echo "Entering nixos" echo "Entering nixos"
nixos-enter --root /mnt nixos-enter --root /mnt
fi fi