-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
98 lines (88 loc) · 3.61 KB
/
install.sh
File metadata and controls
98 lines (88 loc) · 3.61 KB
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
#!/bin/bash
# i2nix Linux installer script
# --- Dependencies Check ---
for cmd in virt-install virsh wget mkpasswd; do
if ! command -v "$cmd" &> /dev/null; then
echo "$cmd could not be found. Please install it."
exit 1
fi
done
# IP for GATEWAY SSH
GATEWAY_SSH=10.152.152.10
# --- Download Debian 13 ISO ---
ISO_FILENAME="debian-13.1.0-amd64-netinst.iso"
if [ ! -f "$ISO_FILENAME" ]; then
FULL_URL="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/$ISO_FILENAME"
echo "Downloading Debian 13 netinst ISO..."
wget -O "$ISO_FILENAME" "$FULL_URL"
echo "Download complete: $ISO_FILENAME"
else
echo "ISO file already exists. Skipping download."
fi
# --- Create Preseed Config ---
echo "Creating preseed.cfg files..."
./preseed.sh gateway
./preseed.sh workstation
# --- Install Gateway ---
echo "Installing i2nix-gateway VM... This will take some time."
virt-install \
--name i2nix-gateway \
--ram 2048 \
--vcpus 1 \
--disk path=/var/lib/libvirt/images/i2nix-gateway.qcow2,size=8 \
--os-variant debian13 \
--network bridge=virbr0,model=virtio \
--network network=default,model=virtio \
--graphics none \
--console pty,target_type=serial \
--location "$PWD/$ISO_FILENAME" \
--initrd-inject gateway-preseed.cfg \
--extra-args="hostname=i2nix-gateway auto=true priority=critical preseed/file=/gateway-preseed.cfg console=ttyS0,115200n8" \
--wait -1
# --- Install Workstation ---
echo "Installing i2nix-workstation VM... This will take some time."
virt-install \
--name i2nix-workstation \
--ram 4096 \
--vcpus 2 \
--disk path=/var/lib/libvirt/images/i2nix-workstation.qcow2,size=16 \
--os-variant debian13 \
--network bridge=virbr0,model=virtio \
--graphics spice \
--location "$PWD/$ISO_FILENAME" \
--initrd-inject workstation-preseed.cfg \
--extra-args="hostname=i2nix-workstation auto=true priority=critical preseed/file=/workstation-preseed.cfg" \
--wait -1
echo "Both VMs have been installed."
# --- Configure Gateway ---
echo "Starting and configuring Gateway..."
virsh start i2nix-gateway
# Wait for the VM to boot and get an IP address
echo "Waiting for Gateway to boot..."
sleep 45
GATEWAY_IP=$(arp -e | grep $(virsh -c qemu:///system net-dhcp-leases default | grep i2nix-gateway | awk '{print $3}') | awk '{print $1}')
if [ -z "$GATEWAY_IP" ]; then
echo "Could not get Gateway IP. Setup failed."
exit 1
fi
echo "Gateway IP is $GATEWAY_IP"
ssh-keyscan "$GATEWAY_IP" >> ~/.ssh/known_hosts
ssh -o "ConnectTimeout 60" i2nix@"$GATEWAY_IP" "sudo apt update -y && sudo apt install -y git && git clone https://github.com/kn0sys/i2nix && cd i2nix && chmod +x gateway-setup.sh && sudo ./gateway-setup.sh"
# --- Configure Workstation ---
echo "Starting and configuring Workstation..."
virsh start i2nix-workstation
echo "Waiting for Workstation to boot..."
sleep 45
WORKSTATION_IP=$(arp -e | grep $(virsh -c qemu:///system net-dhcp-leases default | grep i2nix-workstation | awk '{print $3}') | awk '{print $1}')
if [ -z "$WORKSTATION_IP" ]; then
echo "Could not get Workstation IP. Setup failed."
exit 1
fi
echo "Workstation IP is $WORKSTATION_IP"
ssh-keyscan "$WORKSTATION_IP" >> ~/.ssh/known_hosts
ssh -o "ConnectTimeout 60" i2nix@"$WORKSTATION_IP" "sudo apt update -y && sudo apt install -y git && git clone https://github.com/kn0sys/i2nix && cd i2nix && chmod +x workstation-setup.sh && sudo ./workstation-setup.sh $GATEWAY_SSH && sudo reboot"
echo "i2nix installation complete. Launching workstation console."
# Clean up preseed file
rm *preseed.cfg
# Launch virt-manager focused on the workstation
virt-manager --connect qemu:///system --show-domain-console i2nix-workstation