this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 119 lines 3.1 kB view raw
1#!/usr/bin/env bash 2set -euo pipefail 3 4# Install script for box NAS 5# Run this from the NixOS installer after rsync'ing the helm repo 6# 7# Prerequisites: 8# - Boot NixOS installer 9# - Enable SSH: passwd && sudo systemctl start sshd 10# - rsync helm repo: rsync -avz --exclude='.git' /path/to/helm nixos@<IP>:~/ 11# 12# Usage: 13# cd ~/helm 14# ./install-box.sh 15 16# Configuration 17FLAKE="$HOME/helm#box" 18NVME="/dev/disk/by-id/nvme-CT500P310SSD8_2544543B87C2" 19 20# ZFS drives - update these if drives change 21ZFS1="/dev/disk/by-id/ata-WDC_WD40EFPX-68C6CN0_WD-WX32D954A2J7" 22ZFS2="/dev/disk/by-id/ata-WDC_WD40EFPX-68C6CN0_WD-WX32D95FVZVL" 23ZFS3="/dev/disk/by-id/ata-WDC_WD40EFPX-68C6CN0_WD-WX42D95M807R" 24 25echo "=== Box NAS Installation ===" 26echo "" 27echo "This will install NixOS with:" 28echo " - NVMe boot drive: $NVME" 29echo " - ZFS RAIDZ1 pool with 3x 4TB drives (~8TB usable)" 30echo "" 31 32# Verify drives exist 33echo "Verifying drives..." 34for disk in "$NVME" "$ZFS1" "$ZFS2" "$ZFS3"; do 35 if [[ ! -e "$disk" ]]; then 36 echo "ERROR: Disk not found: $disk" 37 echo "Available disks:" 38 ls -la /dev/disk/by-id/ | grep -E '(nvme|ata)' | grep -v part 39 exit 1 40 fi 41done 42echo "All drives found." 43echo "" 44 45# Generate ZFS keyfile 46echo "Generating ZFS keyfile..." 47dd if=/dev/urandom of=/tmp/tank.key bs=32 count=1 2>/dev/null 48echo "ZFS keyfile created at /tmp/tank.key" 49echo "" 50 51# Get LUKS password 52echo "Enter LUKS password for boot drive encryption:" 53read -s LUKS_PASSWORD 54echo "" 55echo "Confirm LUKS password:" 56read -s LUKS_PASSWORD_CONFIRM 57echo "" 58 59if [[ "$LUKS_PASSWORD" != "$LUKS_PASSWORD_CONFIRM" ]]; then 60 echo "ERROR: Passwords do not match" 61 exit 1 62fi 63 64echo -n "$LUKS_PASSWORD" > /tmp/luks-password 65echo "LUKS password saved." 66echo "" 67 68# Confirm before proceeding 69echo "WARNING: This will DESTROY all data on the following drives:" 70echo " - $NVME" 71echo " - $ZFS1" 72echo " - $ZFS2" 73echo " - $ZFS3" 74echo "" 75read -p "Type 'yes' to continue: " CONFIRM 76if [[ "$CONFIRM" != "yes" ]]; then 77 echo "Aborted." 78 exit 1 79fi 80 81echo "" 82echo "Running disko-install..." 83sudo nix \ 84 --extra-experimental-features nix-command \ 85 --extra-experimental-features flakes \ 86 run 'github:nix-community/disko/latest#disko-install' -- \ 87 --flake "$FLAKE" \ 88 --disk nvme "$NVME" \ 89 --disk zfs1 "$ZFS1" \ 90 --disk zfs2 "$ZFS2" \ 91 --disk zfs3 "$ZFS3" 92 93echo "" 94echo "Copying ZFS keyfile to installed system..." 95# disko-install mounts the root filesystem at /mnt 96if [[ ! -d /mnt/etc ]]; then 97 echo "ERROR: /mnt/etc does not exist. Is the root filesystem mounted?" 98 exit 1 99fi 100sudo mkdir -p /mnt/etc/zfs 101sudo cp /tmp/tank.key /mnt/etc/zfs/tank.key 102sudo chmod 000 /mnt/etc/zfs/tank.key 103 104echo "Updating ZFS keylocation to permanent path..." 105# Update keylocation so ZFS looks for the key in the installed system 106sudo zfs set keylocation=file:///etc/zfs/tank.key tank 107 108echo "" 109echo "Cleaning up..." 110rm -f /tmp/luks-password /tmp/tank.key 111 112echo "" 113echo "=== Installation complete! ===" 114echo "" 115echo "Next steps:" 116echo " 1. Reboot: sudo reboot" 117echo " 2. Enter LUKS password at boot prompt" 118echo " 3. SSH to box at 192.168.1.240" 119echo ""