Update unifi-os-server-vm.sh

This commit is contained in:
CanbiZ 2025-12-03 13:40:10 +01:00
parent f3829b732c
commit 31dbc4dc9e

View File

@ -776,8 +776,6 @@ if virt-customize -a "${FILE}" --install qemu-guest-agent,curl,ca-certificates,p
msg_info "Pre-installed base packages (faster first boot)" msg_info "Pre-installed base packages (faster first boot)"
fi fi
msg_ok "UniFi OS Server will be installed on first boot"
# Add auto-login if Cloud-Init is disabled # Add auto-login if Cloud-Init is disabled
if [ "$USE_CLOUD_INIT" != "yes" ]; then if [ "$USE_CLOUD_INIT" != "yes" ]; then
virt-customize -q -a "${FILE}" \ virt-customize -q -a "${FILE}" \
@ -785,7 +783,7 @@ if [ "$USE_CLOUD_INIT" != "yes" ]; then
--run-command "bash -c 'echo -e \"[Service]\nExecStart=\nExecStart=-/sbin/agetty --autologin root --noclear %I \\\$TERM\" > /etc/systemd/system/getty@tty1.service.d/override.conf'" 2>/dev/null --run-command "bash -c 'echo -e \"[Service]\nExecStart=\nExecStart=-/sbin/agetty --autologin root --noclear %I \\\$TERM\" > /etc/systemd/system/getty@tty1.service.d/override.conf'" 2>/dev/null
fi fi
msg_ok "UniFi OS Server will be installed on first boot" msg_ok "Prepared ${OS_DISPLAY} image with UniFi OS installer"
# Expand root partition to use full disk space # Expand root partition to use full disk space
msg_info "Expanding disk image to ${DISK_SIZE}" msg_info "Expanding disk image to ${DISK_SIZE}"
@ -828,6 +826,16 @@ if [ "$USE_CLOUD_INIT" = "yes" ]; then
msg_info "Configuring Cloud-Init" msg_info "Configuring Cloud-Init"
setup_cloud_init "$VMID" "$STORAGE" "$HN" "yes" >/dev/null 2>&1 setup_cloud_init "$VMID" "$STORAGE" "$HN" "yes" >/dev/null 2>&1
msg_ok "Cloud-Init configured" msg_ok "Cloud-Init configured"
# Display credentials immediately so user can login
if [ -n "$CLOUDINIT_CRED_FILE" ] && [ -f "$CLOUDINIT_CRED_FILE" ]; then
echo ""
echo -e "${INFO}${BOLD}${GN}Cloud-Init Credentials (save these now!):${CL}"
echo -e "${TAB}${DGN}User: ${BGN}${CLOUDINIT_USER:-root}${CL}"
echo -e "${TAB}${DGN}Password: ${BGN}${CLOUDINIT_PASSWORD}${CL}"
echo -e "${TAB}${RD}⚠️ SSH to VM IP or use Proxmox Console${CL}"
echo ""
fi
fi fi
DESCRIPTION=$( DESCRIPTION=$(
@ -918,21 +926,29 @@ if [ "$START_VM" == "yes" ]; then
else else
msg_ok "VM is running, but installation is still in progress" msg_ok "VM is running, but installation is still in progress"
echo -e "${TAB}${INFO}${YW}Installation takes 3-5 minutes after first boot${CL}" echo -e "${TAB}${INFO}${YW}Installation takes 3-5 minutes after first boot${CL}"
echo -e "${TAB}${INFO}${YW}Check progress: ${BL}qm guest exec ${VMID} -- tail -f /var/log/install-unifi.log${CL}" if [ "$USE_CLOUD_INIT" = "yes" ]; then
echo -e "${TAB}${INFO}${YW}Or SSH to: ${BL}${VM_IP}${CL} and run: ${BL}tail -f /var/log/install-unifi.log${CL}" echo -e "${TAB}${INFO}${YW}SSH to: ${BL}ssh ${CLOUDINIT_USER:-root}@${VM_IP}${CL}"
echo -e "${TAB}${INFO}${YW}Password: ${BGN}${CLOUDINIT_PASSWORD}${CL}"
echo -e "${TAB}${INFO}${YW}Then run: ${BL}tail -f /var/log/install-unifi.log${CL}"
else
echo -e "${TAB}${INFO}${YW}Console login: ${BL}root${CL} (auto-login enabled)"
echo -e "${TAB}${INFO}${YW}Then run: ${BL}tail -f /var/log/install-unifi.log${CL}"
fi
echo -e "${TAB}${INFO}${YW}Access will be at: ${BGN}https://${VM_IP}:11443${CL}" echo -e "${TAB}${INFO}${YW}Access will be at: ${BGN}https://${VM_IP}:11443${CL}"
fi fi
else else
msg_ok "VM is running (ID: ${VMID})" msg_ok "VM is running (ID: ${VMID})"
echo -e "${TAB}${INFO}${YW}Could not auto-detect IP address${CL}" echo -e "${TAB}${INFO}${YW}Could not auto-detect IP address${CL}"
if [ "$USE_CLOUD_INIT" = "yes" ]; then
echo -e "${TAB}${INFO}${YW}Use Proxmox Console to login with Cloud-Init credentials${CL}"
echo -e "${TAB}${INFO}${YW}User: ${BGN}${CLOUDINIT_USER:-root}${CL} / Password: ${BGN}${CLOUDINIT_PASSWORD}${CL}"
else
echo -e "${TAB}${INFO}${YW}Use Proxmox Console (root auto-login enabled)${CL}"
fi
echo -e "${TAB}${INFO}${YW}Access VM console in Proxmox to check status${CL}" echo -e "${TAB}${INFO}${YW}Access VM console in Proxmox to check status${CL}"
echo -e "${TAB}${INFO}${YW}Or check installation log: ${BL}tail -f /var/log/install-unifi.log${CL}" echo -e "${TAB}${INFO}${YW}Check installation log: ${BL}tail -f /var/log/install-unifi.log${CL}"
fi fi
fi fi
if [ "$USE_CLOUD_INIT" = "yes" ]; then
display_cloud_init_info "$VMID" "$HN"
fi
post_update_to_api "done" "none" post_update_to_api "done" "none"
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"