From b9aa3ec7ab10e639642c9576685a3b88e5157b55 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 14 Jan 2026 17:17:04 +0100 Subject: [PATCH] Enhance Piler and UniFi OS VM installation scripts Added installation steps for Piler WebUI and improved config file handling in piler-install.sh. Updated unifi-os-server-vm.sh to always prompt for VMID, refactored machine type selection, improved storage validation, added swap file setup for stability, and increased VM IP detection attempts for reliability. --- install/piler-install.sh | 9 +++++--- vm/unifi-os-server-vm.sh | 48 +++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/install/piler-install.sh b/install/piler-install.sh index 36aae0de2..f867e54be 100644 --- a/install/piler-install.sh +++ b/install/piler-install.sh @@ -46,7 +46,10 @@ $STD systemctl stop manticore $STD systemctl disable manticore msg_ok "Installed Manticore Search" +msg_info "Installing Piler" fetch_and_deploy_gh_release "piler" "jsuto/piler" "binary" "latest" "/tmp" "piler_*-noble-*_amd64.deb" +fetch_and_deploy_gh_release "piler-webui" "jsuto/piler" "binary" "latest" "/tmp" "piler-webui_*-noble-*_amd64.deb" +msg_ok "Installed Piler" msg_info "Configuring Piler Database" $STD mariadb -u root "${MARIADB_DB_NAME}" /dev/null || true @@ -175,9 +178,9 @@ $STD systemctl restart php8.3-fpm msg_ok "Configured PHP-FPM Pool" msg_info "Configuring Piler Web GUI" -cd /var/www/piler - -cat </var/www/piler/config-site.php +# Check if config-site.php already exists (created by .deb package) +if [ ! -f /var/www/piler/config-site.php ]; then + cat </var/www/piler/config-site.php &1 1>&2 2>&3); then if [ -z "$VMID" ]; then @@ -391,22 +391,24 @@ function advanced_settings() { fi done - if MACH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "MACHINE TYPE" --radiolist --cancel-button Exit-Script "Choose Machine Type" 10 58 2 \ + MACH="q35" + if MACH_RESULT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "MACHINE TYPE" --radiolist --cancel-button Exit-Script "Choose Machine Type" 10 58 2 \ "q35" "Q35 (Modern, PCIe, UEFI)" ON \ "i440fx" "i440fx (Legacy)" OFF \ 3>&1 1>&2 2>&3); then - if [ "$MACH" = "q35" ]; then - echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}Q35 (Modern)${CL}" - FORMAT="" - MACHINE=" -machine q35" - else - echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx (Legacy)${CL}" - FORMAT=",efitype=4m" - MACHINE="" - fi + MACH="$MACH_RESULT" else exit-script fi + if [ "$MACH" = "q35" ]; then + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}Q35 (Modern)${CL}" + FORMAT="" + MACHINE=" -machine q35" + else + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx (Legacy)${CL}" + FORMAT=",efitype=4m" + MACHINE="" + fi if DISK_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Disk Size in GiB (e.g., 10, 20)" 8 58 "$DISK_SIZE" --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then DISK_SIZE=$(echo "$DISK_SIZE" | tr -d ' ') @@ -575,13 +577,15 @@ start_script post_to_api_vm msg_info "Validating Storage" +STORAGE_MENU=() +MSG_MAX_LENGTH=0 while read -r line; do TAG=$(echo $line | awk '{print $1}') TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f 2>/dev/null || echo "N/A" | awk '{printf( "%9sB", $6)}') ITEM=" Type: $TYPE Free: $FREE " OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-0} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi STORAGE_MENU+=("$TAG" "$ITEM" "OFF") @@ -771,6 +775,20 @@ if [ "$START_VM" == "yes" ]; then sleep 120 msg_ok "Podman installed" + # Setup swap file (1GB for better stability) + msg_info "Setting up swap file" + send_line_to_vm "fallocate -l 1G /swapfile" + sleep 2 + send_line_to_vm "chmod 600 /swapfile" + sleep 1 + send_line_to_vm "mkswap /swapfile" + sleep 2 + send_line_to_vm "swapon /swapfile" + sleep 1 + send_line_to_vm "echo '/swapfile none swap sw 0 0' >> /etc/fstab" + sleep 1 + msg_ok "Swap file created" + # Step 2: Download UniFi OS Server installer msg_info "Downloading UniFi OS Server ${UOS_VERSION}" send_line_to_vm "cd /opt" @@ -800,12 +818,12 @@ if [ "$START_VM" == "yes" ]; then # Get IP from outside via Guest Agent msg_info "Detecting VM IP address" VM_IP="" - for i in {1..15}; do + for i in {1..30}; do VM_IP=$(qm guest cmd $VMID network-get-interfaces 2>/dev/null | jq -r '.[] | select(.name != "lo") | .["ip-addresses"][]? | select(.["ip-address-type"] == "ipv4") | .["ip-address"]' 2>/dev/null | head -1 || echo "") if [ -n "$VM_IP" ]; then break fi - sleep 2 + sleep 1 done if [ -n "$VM_IP" ]; then