aboutsummaryrefslogtreecommitdiff
path: root/download-archzfs-iso.sh
blob: 65b5f3ddd1e73bd8985123c9a4d6e6af6aeabe04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# download-archzfs-iso.sh - Download the official archzfs ISO and add our scripts
#
# The archzfs project maintains ISOs with matched kernel+ZFS versions.
# This script downloads their ISO and creates a script bundle to use with it.

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUT_DIR="$SCRIPT_DIR/out"
CUSTOM_DIR="$SCRIPT_DIR/custom"

# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'

info() { echo -e "${GREEN}[INFO]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }

mkdir -p "$OUT_DIR"

echo ""
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo "  ArchZFS ISO Setup"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""

# Check for existing archzfs ISO
EXISTING_ISO=$(ls "$OUT_DIR"/archlinux-*-zfs-*.iso 2>/dev/null | head -1)

if [[ -n "$EXISTING_ISO" ]]; then
    info "Found existing archzfs ISO: $(basename "$EXISTING_ISO")"
    read -p "Use this ISO? [Y/n]: " use_existing
    if [[ "$use_existing" != "n" && "$use_existing" != "N" ]]; then
        ISO_FILE="$EXISTING_ISO"
    fi
fi

if [[ -z "$ISO_FILE" ]]; then
    info "Fetching latest archzfs ISO URL..."

    # Get the latest ISO from archzfs releases
    RELEASE_URL="https://github.com/archzfs/archzfs/releases"

    echo ""
    echo "Please download the latest archzfs ISO from:"
    echo -e "  ${CYAN}$RELEASE_URL${NC}"
    echo ""
    echo "Look for: archlinux-YYYY.MM.DD-zfs-linux-lts-x86_64.iso"
    echo "Save it to: $OUT_DIR/"
    echo ""
    read -p "Press Enter once downloaded, or Ctrl+C to abort..."

    ISO_FILE=$(ls "$OUT_DIR"/archlinux-*-zfs-*.iso 2>/dev/null | head -1)

    if [[ -z "$ISO_FILE" ]]; then
        echo "No archzfs ISO found in $OUT_DIR/"
        exit 1
    fi
fi

info "Using ISO: $ISO_FILE"

# Create a tarball of our custom scripts
info "Creating script bundle..."

BUNDLE_DIR=$(mktemp -d)
mkdir -p "$BUNDLE_DIR/archzfs-scripts"

# Copy our scripts
cp "$CUSTOM_DIR/install-archzfs" "$BUNDLE_DIR/archzfs-scripts/"
cp "$CUSTOM_DIR/install-claude" "$BUNDLE_DIR/archzfs-scripts/"
cp "$CUSTOM_DIR/archsetup-zfs" "$BUNDLE_DIR/archzfs-scripts/"

# Copy archsetup if available
if [[ -d /home/cjennings/code/archsetup ]]; then
    info "Including archsetup..."
    cp -r /home/cjennings/code/archsetup "$BUNDLE_DIR/archzfs-scripts/"
    rm -rf "$BUNDLE_DIR/archzfs-scripts/archsetup/.git"
    rm -rf "$BUNDLE_DIR/archzfs-scripts/archsetup/.claude"
fi

# Create setup script
cat > "$BUNDLE_DIR/archzfs-scripts/setup.sh" << 'SETUP'
#!/bin/bash
# Run this after booting the archzfs ISO
# It copies the installation scripts to the right places

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

echo "Setting up archzfs installation scripts..."

# Copy scripts to /usr/local/bin
cp "$SCRIPT_DIR/install-archzfs" /usr/local/bin/
cp "$SCRIPT_DIR/install-claude" /usr/local/bin/
cp "$SCRIPT_DIR/archsetup-zfs" /usr/local/bin/
chmod +x /usr/local/bin/install-archzfs
chmod +x /usr/local/bin/install-claude
chmod +x /usr/local/bin/archsetup-zfs

# Copy archsetup to /code
if [[ -d "$SCRIPT_DIR/archsetup" ]]; then
    mkdir -p /code
    cp -r "$SCRIPT_DIR/archsetup" /code/
    echo "archsetup copied to /code/archsetup"
fi

echo ""
echo "Setup complete! You can now run:"
echo "  install-archzfs"
echo ""
SETUP
chmod +x "$BUNDLE_DIR/archzfs-scripts/setup.sh"

# Create the tarball
BUNDLE_FILE="$OUT_DIR/archzfs-scripts.tar.gz"
tar -czf "$BUNDLE_FILE" -C "$BUNDLE_DIR" archzfs-scripts
rm -rf "$BUNDLE_DIR"

info "Script bundle created: $BUNDLE_FILE"

echo ""
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN}Setup Complete!${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo "To install Arch on ZFS:"
echo ""
echo "1. Boot from the archzfs ISO:"
echo "   $(basename "$ISO_FILE")"
echo ""
echo "2. Connect to network, then download and extract scripts:"
echo "   # If you have a web server or USB drive with the bundle:"
echo "   tar -xzf archzfs-scripts.tar.gz"
echo "   cd archzfs-scripts && ./setup.sh"
echo ""
echo "3. Run the installer:"
echo "   install-archzfs"
echo ""
echo "Alternative: Copy scripts via SSH from another machine"
echo ""