diff --git a/setup/install-modules.sh b/setup/install-modules.sh index fc17053..53f2461 100755 --- a/setup/install-modules.sh +++ b/setup/install-modules.sh @@ -186,7 +186,7 @@ SELECTED=$(dialog --backtitle "$BACKTITLE" \ "cockpit" "Cockpit web UI · machines · podman" off \ "ssh-server" "SSH server openssh · key-auth · enabled" off \ "freeipa-server" "FreeIPA Server interactive server setup + client gen" off \ - "freeipa-image" "FreeIPA Image OCI/LXC/Proxmox/VM builder + Keycloak" off \ + "freeipa-image" "FreeIPA Image OCI/LXC/Proxmox LXC builder + Keycloak" off \ "python" "Python tools pyright · pipx · pynvim" off \ "zfs" "ZFS zfs-dkms kernel module" off \ "wprs" "WPRS wprs-git (AUR)" off \ diff --git a/setup/modules/optional-Modules/apps/freeipa-image-builder.sh b/setup/modules/optional-Modules/apps/freeipa-image-builder.sh index da83171..4a09cac 100755 --- a/setup/modules/optional-Modules/apps/freeipa-image-builder.sh +++ b/setup/modules/optional-Modules/apps/freeipa-image-builder.sh @@ -70,10 +70,10 @@ command -v dialog &>/dev/null || { sudo pacman -S --noconfirm dialog; } TARGET=$(dialog --backtitle "$BACKTITLE" \ --title " Select Target Format " \ --menu "Choose the output format:" 16 70 4 \ - "docker" "Docker / Podman image (local + optional registry push)" \ - "lxc" "LXC / Proxmox CT template (.tar.zst rootfs archive)" \ - "proxmox-vm" "Proxmox VM (cloud-init QCOW2, requires virt-customize)" \ - "oci-archive" "OCI archive (skopeo tarball for air-gapped import)" \ + "docker" "Docker / Podman image (local + optional registry push)" \ + "lxc" "LXC template (.tar.zst rootfs, generic LXC/LXD)" \ + "proxmox-lxc" "Proxmox LXC CT template + conf + optional upload" \ + "oci-archive" "OCI archive (skopeo tarball for air-gapped import)" \ 3>&1 1>&2 2>&3) || { clear; echo "Aborted."; exit 0; } # ─── Keycloak? ─────────────────────────────────────────────────────────────── @@ -119,12 +119,18 @@ if [[ "$WITH_KEYCLOAK" == true ]]; then ask "Keycloak realm name [$KC_REALM]:"; read -r I; KC_REALM="${I:-$KC_REALM}" fi -# Proxmox VM cloud image (only if proxmox-vm selected) -CLOUD_IMAGE_URL="" -if [[ "$TARGET" == "proxmox-vm" ]]; then +# Proxmox LXC extra config +PVE_HOST=""; PVE_VMID="100"; PVE_STORAGE="local"; PVE_BRIDGE="vmbr0" +PVE_MEMORY="4096"; PVE_CORES="4"; PVE_DISK_SIZE="20" +if [[ "$TARGET" == "proxmox-lxc" ]]; then echo - ROCKY_URL="https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud.latest.x86_64.qcow2" - ask "Cloud image URL [$ROCKY_URL]:"; read -r I; CLOUD_IMAGE_URL="${I:-$ROCKY_URL}" + ask "Proxmox host (blank to skip upload):"; read -r PVE_HOST + ask "Container ID [100]:"; read -r I; PVE_VMID="${I:-100}" + ask "Storage for rootfs [local-lvm]:"; read -r I; PVE_STORAGE="${I:-local-lvm}" + ask "Network bridge [vmbr0]:"; read -r I; PVE_BRIDGE="${I:-vmbr0}" + ask "Memory MB [4096]:"; read -r I; PVE_MEMORY="${I:-4096}" + ask "CPU cores [4]:"; read -r I; PVE_CORES="${I:-4}" + ask "Disk size GB [20]:"; read -r I; PVE_DISK_SIZE="${I:-20}" fi # ─── Confirm ────────────────────────────────────────────────────────────────── @@ -225,65 +231,115 @@ LXCTXT log "Instructions: $OUTPUT_DIR/lxc-import-instructions.txt" ;; - proxmox-vm) - section "Proxmox VM — cloud-init QCOW2" + proxmox-lxc) + section "Proxmox LXC CT template" + TEMPLATE_NAME="freeipa-server-proxmox-lxc.tar.zst" + TEMPLATE_PATH="$OUTPUT_DIR/$TEMPLATE_NAME" - if ! command -v virt-customize &>/dev/null; then - error "virt-customize not found. Install libguestfs-tools:" - error " sudo pacman -S libguestfs # Arch" - error " sudo dnf install libguestfs-tools # Fedora/RHEL" - exit 1 - fi - if ! command -v qemu-img &>/dev/null; then - error "qemu-img not found. Install qemu-img / qemu-tools." - exit 1 + info "Creating temporary container to export rootfs..." + TMP_CTR="freeipa-pve-export-$$" + $ENGINE create --name "$TMP_CTR" "$IMAGE_TAG" /bin/true + + info "Exporting rootfs..." + if command -v zstd &>/dev/null; then + $ENGINE export "$TMP_CTR" | zstd -T0 -o "$TEMPLATE_PATH" + else + warn "zstd not found — falling back to gzip (.tar.gz)" + TEMPLATE_NAME="freeipa-server-proxmox-lxc.tar.gz" + TEMPLATE_PATH="$OUTPUT_DIR/$TEMPLATE_NAME" + $ENGINE export "$TMP_CTR" | gzip -9 > "$TEMPLATE_PATH" fi + $ENGINE rm "$TMP_CTR" &>/dev/null + log "Template: $TEMPLATE_PATH" - CLOUD_IMG="$TMP_D/cloud-base.qcow2" - QCOW2_OUT="$OUTPUT_DIR/freeipa-server.qcow2" - - info "Downloading cloud image..." - curl -L --progress-bar -o "$CLOUD_IMG" "$CLOUD_IMAGE_URL" - - info "Customizing image (installing FreeIPA packages)..." - virt-customize -a "$CLOUD_IMG" \ - --install freeipa-server,freeipa-server-dns,ansible-core,python3-netaddr \ - --copy-in "$IMAGE_SRC/ipa-first-boot.sh":/usr/local/sbin/ \ - --copy-in "$IMAGE_SRC/ipa-first-boot.service":/etc/systemd/system/ \ - --run-command "chmod +x /usr/local/sbin/ipa-first-boot.sh" \ - --run-command "systemctl enable ipa-first-boot.service" \ - --selinux-relabel - - qemu-img convert -O qcow2 "$CLOUD_IMG" "$QCOW2_OUT" - log "QCOW2: $QCOW2_OUT" - - # Cloud-init snippet - cat > "$OUTPUT_DIR/cloud-init-user-data.yml" < "$CT_CONF" < "$OUTPUT_DIR/proxmox-lxc-setup.txt" <:/var/lib/vz/template/cache/ - info "Proxmox VM import:" - info " qm create --name freeipa --memory 4096 --cores 4 --net0 virtio,bridge=vmbr0" - info " qm importdisk $QCOW2_OUT local-lvm" - info " qm set --scsihw virtio-scsi-pci --scsi0 local-lvm:vm--disk-0" - info " qm set --ide2 local-lvm:cloudinit --boot c --bootdisk scsi0" +── Step 2: Create the container ──────────────────────────── + pct create $PVE_VMID local:vztmpl/$TEMPLATE_NAME \\ + --hostname ${IPA_HOSTNAME%%.*} \\ + --memory $PVE_MEMORY --cores $PVE_CORES \\ + --rootfs $PVE_STORAGE:${PVE_DISK_SIZE} \\ + --net0 name=eth0,bridge=$PVE_BRIDGE,ip=dhcp \\ + --ostype fedora --unprivileged 0 \\ + --features nesting=1 + +── Step 3: Apply required LXC options ────────────────────── + # FreeIPA needs unconfined AppArmor and full cgroup access. + # Copy the generated config or append these lines: + cat >> /etc/pve/lxc/$PVE_VMID.conf <> /etc/environment < \\ + # IPA_DOMAIN=$IPA_DOMAIN IPA_DM_PASSWORD= \\ + # ./keycloak-configure.sh +GUIDEOF + log "Setup guide: $OUTPUT_DIR/proxmox-lxc-setup.txt" + + # Optional: upload to Proxmox host + if [[ -n "$PVE_HOST" ]]; then + section "Uploading template to $PVE_HOST" + scp "$TEMPLATE_PATH" "root@${PVE_HOST}:/var/lib/vz/template/cache/" + scp "$CT_CONF" "root@${PVE_HOST}:/etc/pve/lxc/${PVE_VMID}.conf" + log "Template uploaded to $PVE_HOST" + info "Next: pct create $PVE_VMID local:vztmpl/$TEMPLATE_NAME ..." + info " (see $OUTPUT_DIR/proxmox-lxc-setup.txt for full command)" + fi ;; oci-archive) diff --git a/setup/tui-install.sh b/setup/tui-install.sh index f3b8b99..69dc5be 100755 --- a/setup/tui-install.sh +++ b/setup/tui-install.sh @@ -221,7 +221,7 @@ SELECTED_APPS=$(dialog --backtitle "$BACKTITLE" \ "cockpit" "Cockpit web UI · machines · podman" off \ "ssh-server" "SSH server openssh · key-auth · enabled" off \ "freeipa-server" "FreeIPA Server interactive server setup + client gen" off \ - "freeipa-image" "FreeIPA Image OCI/LXC/Proxmox/VM builder + Keycloak" off \ + "freeipa-image" "FreeIPA Image OCI/LXC/Proxmox LXC builder + Keycloak" off \ "python" "Python tools pyright · pipx · pynvim" off \ "zfs" "ZFS zfs-dkms kernel module" off \ "wprs" "WPRS wprs-git (AUR)" off \