diff --git a/.github/workflows/auto-update-app-headers.yml b/.github/workflows/auto-update-app-headers.yml index b02c3e61..dfa34200 100644 --- a/.github/workflows/auto-update-app-headers.yml +++ b/.github/workflows/auto-update-app-headers.yml @@ -1,4 +1,4 @@ -name: Auto Update .app-headers +name: Auto Update .app-files on: push: @@ -6,10 +6,10 @@ on: - main paths: - 'ct/**.sh' - workflow_dispatch: # ErmΓΆglicht das manuelle AusfΓΌhren der Action + workflow_dispatch: jobs: - update-app-headers: + update-app-files: runs-on: ubuntu-latest permissions: @@ -21,62 +21,62 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - # Step 2: Set up Git user for committing changes + # Step 2: Disable file mode changes detection + - name: Disable file mode changes + run: git config core.fileMode false + + # Step 3: Set up Git user for committing changes - name: Set up Git run: | git config --global user.name "GitHub Actions" - git config --global user.email "actions@github.com" + git config --global user.email "github-actions[bot]@users.noreply.github.com" - # Step 3: Install figlet + # Step 4: Install figlet - name: Install figlet run: sudo apt-get install -y figlet - # Step 4: Run the generate-app-headers.sh script to update .app-headers - - name: Run generate-app-headers.sh to update .app-headers + # Step 5: Run the updated generate-app-files.sh script + - name: Run generate-app-files.sh run: | chmod +x .github/workflows/scripts/generate-app-headers.sh .github/workflows/scripts/generate-app-headers.sh env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Step 5: Check if there are any changes + # Step 6: Check if there are any changes - name: Check if there are any changes id: verify-diff run: | - git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT + echo "Checking for changes..." + git status + if git diff --quiet; then + echo "No changes detected." + echo "changed=false" >> $GITHUB_OUTPUT + else + echo "Changes detected:" + git diff --stat + echo "changed=true" >> $GITHUB_OUTPUT + fi - # Step 6: Commit changes (if any) and create a PR + # Step 7: Commit changes (if any) and create a PR - name: Commit and create PR if changes exist if: steps.verify-diff.outputs.changed == 'true' run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add ./misc/.app-headers - git commit -m "Update .app-headers file" - # Create a temporary branch for the PR - git checkout -b pr-update-app-headers - git push origin pr-update-app-headers --force - - # Create PR against main - gh pr create --title "[core] update .app-headers file" \ - --body "This PR is auto-generated by a Github Action to update the .app-headers file." \ - --head pr-update-app-headers \ + git add -A + git commit -m "Update .app files" + git checkout -b pr-update-app-files + git push origin pr-update-app-files --force + + gh pr create --title "[core] update .app files" \ + --body "This PR is auto-generated by a GitHub Action to update the .app files." \ + --head pr-update-app-files \ --base main \ --label "automated pr" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Re-approve pull request after update - if: steps.verify-diff.outputs.changed == 'true' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - PR_NUMBER=$(gh pr list --head "pr-update-app-headers" --json number --jq '.[].number') - # Check if the PR was created by the bot (skip review if so) - PR_AUTHOR=$(gh pr view "$PR_NUMBER" --json author --jq '.author.login') - if [ "$PR_AUTHOR" != "github-actions[bot]" ]; then - gh pr review "$PR_NUMBER" --approve - else - echo "PR was created by the bot, skipping review." - fi + # Step 8: Output success message when no changes + - name: No changes detected + if: steps.verify-diff.outputs.changed == 'false' + run: echo "No changes to commit. Workflow completed successfully." diff --git a/.github/workflows/scripts/generate-app-headers.sh b/.github/workflows/scripts/generate-app-headers.sh old mode 100644 new mode 100755 index c548b0fc..f82c674d --- a/.github/workflows/scripts/generate-app-headers.sh +++ b/.github/workflows/scripts/generate-app-headers.sh @@ -1,33 +1,34 @@ #!/usr/bin/env bash -output_file="./misc/.app-headers" -> "$output_file" # Clear or create the file +# Base directory for headers +headers_dir="./ct/headers" -current_date=$(date +"%m-%d-%Y") -# Header with date -{ - echo "### Generated on $current_date" - echo "##################################################" - echo -} >> "$output_file" +# Ensure the headers directory exists and clear it +mkdir -p "$headers_dir" +rm -f "$headers_dir"/* -# Find only regular .sh files in ./ct, sort them alphabetically +# Find all .sh files in ./ct directory, sorted alphabetically find ./ct -type f -name "*.sh" | sort | while read -r script; do # Extract the APP name from the APP line app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null) if [[ -n "$app_name" ]]; then + # Define the output file name in the headers directory + output_file="${headers_dir}/$(basename "${script%.*}")" + # Generate figlet output figlet_output=$(figlet -f slant "$app_name") - { - echo "### $(basename "$script")" - echo "APP=$app_name" - echo "$figlet_output" - echo - } >> "$output_file" + + # Check if figlet output is not empty + if [[ -n "$figlet_output" ]]; then + echo "$figlet_output" > "$output_file" + echo "Generated: $output_file" + else + echo "Figlet failed for $app_name in $script" + fi else echo "No APP name found in $script, skipping." fi done -echo "Generated combined file at $output_file" +echo "Completed processing .sh files." diff --git a/CHANGELOG.md b/CHANGELOG.md index aaba48e6..443239b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,24 @@ All LXC instances created using this repository come pre-installed with Midnight Do not break established syntax in this file, as it is automatically updated by a Github Workflow +## 2025-01-24 + +### Changed + +### ✨ New Scripts + +- New Script: Ubuntu 24.10 VM [@MickLesk](https://github.com/MickLesk) ([#1711](https://github.com/community-scripts/ProxmoxVE/pull/1711)) + +### πŸš€ Updated Scripts + +- Feature: Filebrowser Script > Redesign | Update Logic | Remove Logic [@MickLesk](https://github.com/MickLesk) ([#1716](https://github.com/community-scripts/ProxmoxVE/pull/1716)) +- Feature: Ubuntu 22.04 VM > Redesign | Optional HDD-Size Prompt [@MickLesk](https://github.com/MickLesk) ([#1712](https://github.com/community-scripts/ProxmoxVE/pull/1712)) +- Feature: Ubuntu 24.04 VM > Redesign | Optional HDD-Size Prompt | cifs support [@MickLesk](https://github.com/MickLesk) ([#1714](https://github.com/community-scripts/ProxmoxVE/pull/1714)) + +### 🧰 Maintenance + +- [Core] Better Creation of App Headers for next feature [@MickLesk](https://github.com/MickLesk) ([#1719](https://github.com/community-scripts/ProxmoxVE/pull/1719)) + ## 2025-01-23 ### Changed diff --git a/ct/actualbudget.sh b/ct/actualbudget.sh index 555b1113..2680b56a 100644 --- a/ct/actualbudget.sh +++ b/ct/actualbudget.sh @@ -33,30 +33,25 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - - if ! command -v jq >/dev/null 2>&1; then - echo "Installing jq..." - apt-get install -y jq >/dev/null 2>&1 - echo "Installed jq..." - fi - - RELEASE=$(curl -s https://api.github.com/repos/actualbudget/actual-server/tags | jq --raw-output '.[0].name') - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + + RELEASE=$(curl -s https://api.github.com/repos/actualbudget/actual/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ ! -f /opt/actualbudget_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/actualbudget_version.txt)" ]]; then msg_info "Stopping ${APP}" systemctl stop actualbudget msg_ok "${APP} Stopped" msg_info "Updating ${APP} to ${RELEASE}" - wget -q https://codeload.github.com/actualbudget/actual-server/legacy.tar.gz/refs/tags/${RELEASE} -O actual-server.tar.gz - tar -xzvf actual-server.tar.gz >/dev/null 2>&1 + cd /tmp + wget -q https://github.com/actualbudget/actual-server/archive/refs/tags/v${RELEASE}.tar.gz mv /opt/actualbudget /opt/actualbudget_bak mkdir -p /opt/actualbudget/ - mv actual-server-* /opt/actualbudget + tar -xzf v${RELEASE}.tar.gz >/dev/null 2>&1 + mv *ctual-server-*/* /opt/actualbudget mv /opt/actualbudget_bak/.env /opt/actualbudget mv /opt/actualbudget_bak/server-files /opt/actualbudget/server-files cd /opt/actualbudget yarn install &>/dev/null - echo "${RELEASE}" >/opt/${APP}_version.txt + echo "${RELEASE}" >/opt/actualbudget_version.txt msg_ok "Updated ${APP}" msg_info "Starting ${APP}" @@ -65,6 +60,7 @@ function update_script() { msg_info "Cleaning Up" rm -rf /opt/actualbudget_bak + rm -rf /tmp/actual-server.tar.gz msg_ok "Cleaned" msg_ok "Updated Successfully" else diff --git a/ct/headers/test.txt b/ct/headers/test.txt new file mode 100644 index 00000000..e69de29b diff --git a/install/actualbudget-install.sh b/install/actualbudget-install.sh index 82adda21..b6068c2c 100644 --- a/install/actualbudget-install.sh +++ b/install/actualbudget-install.sh @@ -18,9 +18,8 @@ $STD apt-get install -y \ curl \ sudo \ mc \ + tini \ gpg \ - git \ - jq \ build-essential msg_ok "Installed Dependencies" @@ -54,7 +53,7 @@ PORT=5006 EOF cd /opt/actualbudget $STD yarn install -echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" +echo "${RELEASE}" >"/opt/actualbudget_version.txt" msg_ok "Installed Actual Budget" msg_info "Creating Service" @@ -83,6 +82,7 @@ motd_ssh customize msg_info "Cleaning up" +rm -rf /opt/v${RELEASE}.tar.gz $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned" diff --git a/json/ubuntu2204-vm.json b/json/ubuntu2204-vm.json index de4d1550..d3a34776 100644 --- a/json/ubuntu2204-vm.json +++ b/json/ubuntu2204-vm.json @@ -20,7 +20,7 @@ "resources": { "cpu": 2, "ram": 2048, - "hdd": 2, + "hdd": 5, "os": null, "version": null } diff --git a/json/ubuntu2404-vm.json b/json/ubuntu2404-vm.json index dbb7fa73..9c2b9a45 100644 --- a/json/ubuntu2404-vm.json +++ b/json/ubuntu2404-vm.json @@ -20,7 +20,7 @@ "resources": { "cpu": 2, "ram": 2048, - "hdd": 2, + "hdd": 7, "os": null, "version": null } diff --git a/json/ubuntu2410-vm.json b/json/ubuntu2410-vm.json new file mode 100644 index 00000000..a1715368 --- /dev/null +++ b/json/ubuntu2410-vm.json @@ -0,0 +1,34 @@ +{ + "name": "Ubuntu 24.10", + "slug": "ubuntu2410-vm", + "categories": [ + 2 + ], + "date_created": "2025-01-24", + "type": "vm", + "updateable": false, + "privileged": false, + "interface_port": null, + "documentation": null, + "website": "https://ubuntu.com/", + "logo": "https://assets.ubuntu.com/v1/29985a98-ubuntu-logo32.png", + "description": "Ubuntu is a distribution based on Debian, designed to have regular releases and a consistent user experience.", + "install_methods": [ + { + "type": "default", + "script": "vm/ubuntu2410-vm.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 8, + "os": null, + "version": null + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} diff --git a/misc/.app-headers b/misc/.app-headers index c8602222..ebdb0ed6 100644 --- a/misc/.app-headers +++ b/misc/.app-headers @@ -1,4 +1,4 @@ -### Generated on 01-22-2025 +### Generated on 01-24-2025 ################################################## ### 2fauth.sh diff --git a/misc/filebrowser.sh b/misc/filebrowser.sh index 02a4bb4c..a9ea1186 100644 --- a/misc/filebrowser.sh +++ b/misc/filebrowser.sh @@ -1,9 +1,8 @@ #!/usr/bin/env bash -# Copyright (c) 2021-2025 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Copyright (c) 2021-2025 community-scripts ORG +# Author: tteck (tteckster) | Co-Author: MickLesk +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE function header_info { clear @@ -11,79 +10,88 @@ function header_info { _______ __ ____ / ____(_) /__ / __ )_________ _ __________ _____ / /_ / / / _ \/ __ / ___/ __ \ | /| / / ___/ _ \/ ___/ - / __/ / / / __/ /_/ / / / /_/ / |/ |/ (__ ) __/ / -/_/ /_/_/\___/_____/_/ \____/|__/|__/____/\___/_/ - + / __/ / / / __/ /_/ / / / /_/ / |/ |/ (__ ) __/ / +/_/ /_/_/\___/_____/_/ \____/|__/|__/____/\___/_/ EOF } -IP=$(hostname -I | awk '{print $1}') YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") +RD=$(echo "\033[01;31m") +BL=$(echo "\033[36m") CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}βœ“${CL}" +CM="${GN}βœ”οΈ${CL}" +CROSS="${RD}βœ–οΈ${CL}" +INFO="${BL}ℹ️${CL}" + APP="FileBrowser" -hostname="$(hostname)" -header_info -if [ -f /root/filebrowser.db ]; then - read -r -p "Would you like to uninstall ${APP} on $hostname.? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - systemctl disable -q --now filebrowser.service - rm -rf /usr/local/bin/filebrowser /root/filebrowser.db /etc/systemd/system/filebrowser.service - echo "$APP Removed" - sleep 2 - clear - exit - else - clear - exit - fi -fi -while true; do - read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn - case $yn in - [Yy]*) break ;; - [Nn]*) exit ;; - *) echo "Please answer yes or no." ;; - esac -done +INSTALL_PATH="/usr/local/bin/filebrowser" +SERVICE_PATH="/etc/systemd/system/filebrowser.service" +DB_PATH="/root/filebrowser.db" +IP=$(hostname -I | awk '{print $1}') header_info + function msg_info() { local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + echo -e "${INFO} ${YW}${msg}...${CL}" } function msg_ok() { local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + echo -e "${CM} ${GN}${msg}${CL}" } -read -r -p "Would you like to use No Authentication? " prompt -msg_info "Installing ${APP}" -apt-get install -y curl &>/dev/null -RELEASE=$(curl -fsSL https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g') -curl -fsSL https://github.com/filebrowser/filebrowser/releases/download/$RELEASE/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null +function msg_error() { + local msg="$1" + echo -e "${CROSS} ${RD}${msg}${CL}" +} -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - filebrowser config init -a '0.0.0.0' &>/dev/null - filebrowser config set -a '0.0.0.0' &>/dev/null - filebrowser config init --auth.method=noauth &>/dev/null - filebrowser config set --auth.method=noauth &>/dev/null - filebrowser users add ID 1 --perm.admin &>/dev/null -else - filebrowser config init -a '0.0.0.0' &>/dev/null - filebrowser config set -a '0.0.0.0' &>/dev/null - filebrowser users add admin helper-scripts.com --perm.admin &>/dev/null +if [ -f "$INSTALL_PATH" ]; then + echo -e "${YW}⚠️ ${APP} is already installed.${CL}" + read -r -p "Would you like to uninstall ${APP}? (y/N): " uninstall_prompt + if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Uninstalling ${APP}" + systemctl disable -q --now filebrowser.service + rm -f "$INSTALL_PATH" "$DB_PATH" "$SERVICE_PATH" + msg_ok "${APP} has been uninstalled." + exit 0 + fi + + read -r -p "Would you like to update ${APP}? (y/N): " update_prompt + if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Updating ${APP}" + curl -fsSL https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null + msg_ok "Updated ${APP}" + exit 0 + else + echo -e "${YW}⚠️ Update skipped. Exiting.${CL}" + exit 0 + fi fi -msg_ok "Installed ${APP} on $hostname" -msg_info "Creating Service" -cat </etc/systemd/system/filebrowser.service +echo -e "${YW}⚠️ ${APP} is not installed.${CL}" +read -r -p "Would you like to install ${APP}? (y/n): " install_prompt +if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing ${APP}" + apt-get install -y curl &>/dev/null + curl -fsSL https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null + msg_ok "Installed ${APP}" + + read -r -p "Would you like to use No Authentication? (y/N): " auth_prompt + if [[ "${auth_prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Configuring No Authentication" + filebrowser config init -a '0.0.0.0' &>/dev/null + filebrowser config set -a '0.0.0.0' --auth.method=noauth &>/dev/null + msg_ok "No Authentication configured" + else + msg_info "Setting up default authentication" + filebrowser config init -a '0.0.0.0' &>/dev/null + filebrowser config set -a '0.0.0.0' &>/dev/null + filebrowser users add admin helper-scripts.com --perm.admin &>/dev/null + msg_ok "Default authentication configured (admin:helper-scripts.com)" + fi + + msg_info "Creating service" + cat </etc/systemd/system/filebrowser.service [Unit] Description=Filebrowser After=network-online.target @@ -96,9 +104,11 @@ ExecStart=/usr/local/bin/filebrowser -r / [Install] WantedBy=default.target EOF -systemctl enable -q --now filebrowser.service -msg_ok "Created Service" + systemctl enable -q --now filebrowser.service + msg_ok "Service created successfully" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://$IP:8080${CL} \n" + echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:8080${CL}" +else + echo -e "${YW}⚠️ Installation skipped. Exiting.${CL}" + exit 0 +fi diff --git a/vm/ubuntu2204-vm.sh b/vm/ubuntu2204-vm.sh index f20ca100..50132197 100644 --- a/vm/ubuntu2204-vm.sh +++ b/vm/ubuntu2204-vm.sh @@ -1,9 +1,8 @@ #!/usr/bin/env bash -# Copyright (c) 2021-2025 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE function header_info { clear @@ -23,16 +22,36 @@ NEXTID=$(pvesh get /cluster/nextid) YW=$(echo "\033[33m") BL=$(echo "\033[36m") -HA=$(echo "\033[1;34m") RD=$(echo "\033[01;31m") BGN=$(echo "\033[4;92m") GN=$(echo "\033[1;92m") DGN=$(echo "\033[32m") CL=$(echo "\033[m") + +CL=$(echo "\033[m") +BOLD=$(echo "\033[1m") BFR="\\r\\033[K" -HOLD="-" -CM="${GN}βœ“${CL}" -CROSS="${RD}βœ—${CL}" +HOLD=" " +TAB=" " + +CM="${TAB}βœ”οΈ${TAB}${CL}" +CROSS="${TAB}βœ–οΈ${TAB}${CL}" +INFO="${TAB}πŸ’‘${TAB}${CL}" +OS="${TAB}πŸ–₯️${TAB}${CL}" +CONTAINERTYPE="${TAB}πŸ“¦${TAB}${CL}" +DISKSIZE="${TAB}πŸ’Ύ${TAB}${CL}" +CPUCORE="${TAB}🧠${TAB}${CL}" +RAMSIZE="${TAB}πŸ› οΈ${TAB}${CL}" +CONTAINERID="${TAB}πŸ†”${TAB}${CL}" +HOSTNAME="${TAB}🏠${TAB}${CL}" +BRIDGE="${TAB}πŸŒ‰${TAB}${CL}" +GATEWAY="${TAB}🌐${TAB}${CL}" +DEFAULT="${TAB}βš™οΈ${TAB}${CL}" +MACADDRESS="${TAB}πŸ”—${TAB}${CL}" +VLANTAG="${TAB}🏷️${TAB}${CL}" +CREATING="${TAB}πŸš€${TAB}${CL}" +ADVANCED="${TAB}🧩${TAB}${CL}" + THIN="discard=on,ssd=1," set -e trap 'error_handler $LINENO "$BASH_COMMAND"' ERR @@ -63,22 +82,22 @@ pushd $TEMP_DIR >/dev/null if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 22.04 VM" --yesno "This will create a New Ubuntu 22.04 VM. Proceed?" 10 58; then : else - header_info && echo -e "⚠ User exited script \n" && exit + header_info && echo -e "${CROSS}${RD}User exited script${CL}\n" && exit fi function msg_info() { local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}" } function msg_ok() { local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + echo -e "${BFR}${CM}${GN}${msg}${CL}" } function msg_error() { local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" + echo -e "${BFR}${CROSS}${RD}${msg}${CL}" } function check_root() { @@ -93,17 +112,18 @@ function check_root() { function pve_check() { if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then - msg_error "This version of Proxmox Virtual Environment is not supported" + msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported" echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." echo -e "Exiting..." sleep 2 exit -fi + fi } function arch_check() { if [ "$(dpkg --print-architecture)" != "amd64" ]; then - msg_error "This script will not work with PiMox! \n" + echo -e "\n ${INFO}${YWB}This script will not work with PiMox! \n" + echo -e "\n ${YWB}Visit https://github.com/asylumexp/Proxmox for ARM64 support. \n" echo -e "Exiting..." sleep 2 exit @@ -125,7 +145,7 @@ function ssh_check() { function exit-script() { clear - echo -e "⚠ User exited script \n" + echo -e "\n${CROSS}${RD}User exited script${CL}\n" exit } @@ -133,6 +153,7 @@ function default_settings() { VMID="$NEXTID" FORMAT=",efitype=4m" MACHINE="" + DISK_SIZE="5G" DISK_CACHE="" HN="ubuntu" CPU_TYPE="" @@ -142,20 +163,21 @@ function default_settings() { MAC="$GEN_MAC" VLAN="" MTU="" - START_VM="no" - echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" - echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}" - echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" - echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" - echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" - echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" - echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" - echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address: ${BGN}${MAC}${CL}" - echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" - echo -e "${BL}Creating an Ubuntu 22.04 VM using the above default settings${CL}" + START_VM="yes" + echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}None${CL}" + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}${HN}${CL}" + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}KVM64${CL}" + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}${RAM_SIZE}${CL}" + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}${BRG}${CL}" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}${MAC}${CL}" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}Default${CL}" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}Default${CL}" + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}yes${CL}" + echo -e "${CREATING}${BOLD}${DGN}Creating a Ubuntu 22.04 VM using the above default settings${CL}" } function advanced_settings() { @@ -169,7 +191,7 @@ function advanced_settings() { sleep 2 continue fi - echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" + echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" break else exit-script @@ -181,27 +203,42 @@ function advanced_settings() { "q35" "Machine q35" OFF \ 3>&1 1>&2 2>&3); then if [ $MACH = q35 ]; then - echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}" FORMAT="" MACHINE=" -machine q35" else - echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}" FORMAT=",efitype=4m" MACHINE="" fi else exit-script 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 ' ') + if [[ "$DISK_SIZE" =~ ^[0-9]+$ ]]; then + DISK_SIZE="${DISK_SIZE}G" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}$DISK_SIZE${CL}" + elif [[ "$DISK_SIZE" =~ ^[0-9]+G$ ]]; then + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}$DISK_SIZE${CL}" + else + echo -e "${DISKSIZE}${BOLD}${RD}Invalid Disk Size. Please use a number (e.g., 10 or 10G).${CL}" + exit-script + fi + else + exit-script + fi + if DISK_CACHE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ "0" "None (Default)" ON \ "1" "Write Through" OFF \ 3>&1 1>&2 2>&3); then if [ $DISK_CACHE = "1" ]; then - echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}" DISK_CACHE="cache=writethrough," else - echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}None${CL}" DISK_CACHE="" fi else @@ -211,10 +248,10 @@ function advanced_settings() { if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $VM_NAME ]; then HN="ubuntu" - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else HN=$(echo ${VM_NAME,,} | tr -d ' ') - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else exit-script @@ -225,10 +262,10 @@ function advanced_settings() { "1" "Host" OFF \ 3>&1 1>&2 2>&3); then if [ $CPU_TYPE1 = "1" ]; then - echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}" CPU_TYPE=" -cpu host" else - echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}KVM64${CL}" CPU_TYPE="" fi else @@ -238,9 +275,9 @@ function advanced_settings() { if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $CORE_COUNT ]; then CORE_COUNT="2" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}" else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}" fi else exit-script @@ -249,9 +286,9 @@ function advanced_settings() { if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $RAM_SIZE ]; then RAM_SIZE="2048" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}" else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}" fi else exit-script @@ -260,9 +297,9 @@ function advanced_settings() { if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $BRG ]; then BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" fi else exit-script @@ -271,10 +308,10 @@ function advanced_settings() { if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $MAC1 ]; then MAC="$GEN_MAC" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}" else MAC="$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC1${CL}" fi else exit-script @@ -284,10 +321,10 @@ function advanced_settings() { if [ -z $VLAN1 ]; then VLAN1="Default" VLAN="" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}" else VLAN=",tag=$VLAN1" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}" fi else exit-script @@ -297,28 +334,28 @@ function advanced_settings() { if [ -z $MTU1 ]; then MTU1="Default" MTU="" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}" else MTU=",mtu=$MTU1" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}" fi else exit-script fi if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then - echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}yes${CL}" START_VM="yes" else - echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}no${CL}" START_VM="no" fi - if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create an Ubuntu 22.04 VM?" --no-button Do-Over 10 58); then - echo -e "${RD}Creating an Ubuntu 22.04 VM using the above advanced settings${CL}" + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create a Ubuntu 22.04 VM?" --no-button Do-Over 10 58); then + echo -e "${CREATING}${BOLD}${DGN}Creating a Ubuntu 22.04 VM using the above advanced settings${CL}" else header_info - echo -e "${RD}Using Advanced Settings${CL}" + echo -e "${ADVANCED}${BOLD}${RD}Using Advanced Settings${CL}" advanced_settings fi } @@ -326,11 +363,11 @@ function advanced_settings() { function start_script() { if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then header_info - echo -e "${BL}Using Default Settings${CL}" + echo -e "${DEFAULT}${BOLD}${BL}Using Default Settings${CL}" default_settings else header_info - echo -e "${RD}Using Advanced Settings${CL}" + echo -e "${ADVANCED}${BOLD}${RD}Using Advanced Settings${CL}" advanced_settings fi } @@ -380,7 +417,7 @@ msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') case $STORAGE_TYPE in -nfs | dir) +nfs | dir | cifs) DISK_EXT=".qcow2" DISK_REF="$VMID/" DISK_IMPORT="-format qcow2" @@ -402,27 +439,61 @@ done msg_info "Creating a Ubuntu 22.04 VM" qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ - -name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null qm set $VMID \ -efidisk0 ${DISK0_REF}${FORMAT} \ - -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=2G \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=${DISK_SIZE} \ -ide2 ${STORAGE}:cloudinit \ -boot order=scsi0 \ - -serial0 socket \ - -description "
+ -serial0 socket >/dev/null +DESCRIPTION=$( + cat < + + Logo + - # Ubuntu 22.04 VM +

ubuntu VM

+ +

+ + spend Coffee + +

+ + + + GitHub + + + + Discussions + + + + Issues + +
+EOF +) +qm set "$VMID" -description "$DESCRIPTION" >/dev/null +if [ -n "$DISK_SIZE" ]; then + msg_info "Resizing disk to $DISK_SIZE GB" + qm resize $VMID scsi0 ${DISK_SIZE} >/dev/null +else + msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB" + qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null +fi - - " >/dev/null msg_ok "Created a Ubuntu 22.04 VM ${CL}${BL}(${HN})" if [ "$START_VM" == "yes" ]; then msg_info "Starting Ubuntu 22.04 VM" qm start $VMID msg_ok "Started Ubuntu 22.04 VM" fi + msg_ok "Completed Successfully!\n" echo -e "Setup Cloud-Init before starting \n -More info at https://github.com/tteck/Proxmox/discussions/2072 \n" +More info at https://github.com/community-scripts/ProxmoxVE/discussions/272 \n" diff --git a/vm/ubuntu2404-vm.sh b/vm/ubuntu2404-vm.sh index c789ecc9..b6b18809 100644 --- a/vm/ubuntu2404-vm.sh +++ b/vm/ubuntu2404-vm.sh @@ -22,17 +22,37 @@ GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1: NEXTID=$(pvesh get /cluster/nextid) YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -HA=$(echo "\033[1;34m") +BL=$(echo "\033[36m") RD=$(echo "\033[01;31m") BGN=$(echo "\033[4;92m") GN=$(echo "\033[1;92m") DGN=$(echo "\033[32m") CL=$(echo "\033[m") + +CL=$(echo "\033[m") +BOLD=$(echo "\033[1m") BFR="\\r\\033[K" -HOLD="-" -CM="${GN}βœ“${CL}" -CROSS="${RD}βœ—${CL}" +HOLD=" " +TAB=" " + +CM="${TAB}βœ”οΈ${TAB}${CL}" +CROSS="${TAB}βœ–οΈ${TAB}${CL}" +INFO="${TAB}πŸ’‘${TAB}${CL}" +OS="${TAB}πŸ–₯️${TAB}${CL}" +CONTAINERTYPE="${TAB}πŸ“¦${TAB}${CL}" +DISKSIZE="${TAB}πŸ’Ύ${TAB}${CL}" +CPUCORE="${TAB}🧠${TAB}${CL}" +RAMSIZE="${TAB}πŸ› οΈ${TAB}${CL}" +CONTAINERID="${TAB}πŸ†”${TAB}${CL}" +HOSTNAME="${TAB}🏠${TAB}${CL}" +BRIDGE="${TAB}πŸŒ‰${TAB}${CL}" +GATEWAY="${TAB}🌐${TAB}${CL}" +DEFAULT="${TAB}βš™οΈ${TAB}${CL}" +MACADDRESS="${TAB}πŸ”—${TAB}${CL}" +VLANTAG="${TAB}🏷️${TAB}${CL}" +CREATING="${TAB}πŸš€${TAB}${CL}" +ADVANCED="${TAB}🧩${TAB}${CL}" + THIN="discard=on,ssd=1," set -e trap 'error_handler $LINENO "$BASH_COMMAND"' ERR @@ -63,22 +83,22 @@ pushd $TEMP_DIR >/dev/null if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 24.04 VM" --yesno "This will create a New Ubuntu 24.04 VM. Proceed?" 10 58; then : else - header_info && echo -e "⚠ User exited script \n" && exit + header_info && echo -e "${CROSS}${RD}User exited script${CL}\n" && exit fi function msg_info() { local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}" } function msg_ok() { local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + echo -e "${BFR}${CM}${GN}${msg}${CL}" } function msg_error() { local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" + echo -e "${BFR}${CROSS}${RD}${msg}${CL}" } function check_root() { @@ -93,17 +113,18 @@ function check_root() { function pve_check() { if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then - msg_error "This version of Proxmox Virtual Environment is not supported" + msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported" echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." echo -e "Exiting..." sleep 2 exit -fi + fi } function arch_check() { if [ "$(dpkg --print-architecture)" != "amd64" ]; then - msg_error "This script will not work with PiMox! \n" + echo -e "\n ${INFO}${YWB}This script will not work with PiMox! \n" + echo -e "\n ${YWB}Visit https://github.com/asylumexp/Proxmox for ARM64 support. \n" echo -e "Exiting..." sleep 2 exit @@ -125,7 +146,7 @@ function ssh_check() { function exit-script() { clear - echo -e "⚠ User exited script \n" + echo -e "\n${CROSS}${RD}User exited script${CL}\n" exit } @@ -133,6 +154,7 @@ function default_settings() { VMID="$NEXTID" FORMAT=",efitype=4m" MACHINE="" + DISK_SIZE="7G" DISK_CACHE="" HN="ubuntu" CPU_TYPE="" @@ -142,18 +164,21 @@ function default_settings() { MAC="$GEN_MAC" VLAN="" MTU="" - echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" - echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}" - echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" - echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" - echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" - echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" - echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" - echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address: ${BGN}${MAC}${CL}" - echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - echo -e "${BL}Creating an Ubuntu 24.04 VM using the above default settings${CL}" + START_VM="yes" + echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}None${CL}" + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}${HN}${CL}" + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}KVM64${CL}" + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}${RAM_SIZE}${CL}" + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}${BRG}${CL}" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}${MAC}${CL}" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}Default${CL}" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}Default${CL}" + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}yes${CL}" + echo -e "${CREATING}${BOLD}${DGN}Creating a Ubuntu 24.04 VM using the above default settings${CL}" } function advanced_settings() { @@ -167,7 +192,7 @@ function advanced_settings() { sleep 2 continue fi - echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" + echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" break else exit-script @@ -179,27 +204,42 @@ function advanced_settings() { "q35" "Machine q35" OFF \ 3>&1 1>&2 2>&3); then if [ $MACH = q35 ]; then - echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}" FORMAT="" MACHINE=" -machine q35" else - echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}" FORMAT=",efitype=4m" MACHINE="" fi else exit-script 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 ' ') + if [[ "$DISK_SIZE" =~ ^[0-9]+$ ]]; then + DISK_SIZE="${DISK_SIZE}G" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}$DISK_SIZE${CL}" + elif [[ "$DISK_SIZE" =~ ^[0-9]+G$ ]]; then + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}$DISK_SIZE${CL}" + else + echo -e "${DISKSIZE}${BOLD}${RD}Invalid Disk Size. Please use a number (e.g., 10 or 10G).${CL}" + exit-script + fi + else + exit-script + fi + if DISK_CACHE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ "0" "None (Default)" ON \ "1" "Write Through" OFF \ 3>&1 1>&2 2>&3); then if [ $DISK_CACHE = "1" ]; then - echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}" DISK_CACHE="cache=writethrough," else - echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}None${CL}" DISK_CACHE="" fi else @@ -209,10 +249,10 @@ function advanced_settings() { if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $VM_NAME ]; then HN="ubuntu" - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else HN=$(echo ${VM_NAME,,} | tr -d ' ') - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else exit-script @@ -223,10 +263,10 @@ function advanced_settings() { "1" "Host" OFF \ 3>&1 1>&2 2>&3); then if [ $CPU_TYPE1 = "1" ]; then - echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}" CPU_TYPE=" -cpu host" else - echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}KVM64${CL}" CPU_TYPE="" fi else @@ -236,9 +276,9 @@ function advanced_settings() { if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $CORE_COUNT ]; then CORE_COUNT="2" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}" else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}" fi else exit-script @@ -247,9 +287,9 @@ function advanced_settings() { if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $RAM_SIZE ]; then RAM_SIZE="2048" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}" else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}" fi else exit-script @@ -258,9 +298,9 @@ function advanced_settings() { if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $BRG ]; then BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" fi else exit-script @@ -269,10 +309,10 @@ function advanced_settings() { if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if [ -z $MAC1 ]; then MAC="$GEN_MAC" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}" else MAC="$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC1${CL}" fi else exit-script @@ -282,10 +322,10 @@ function advanced_settings() { if [ -z $VLAN1 ]; then VLAN1="Default" VLAN="" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}" else VLAN=",tag=$VLAN1" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}" fi else exit-script @@ -295,20 +335,28 @@ function advanced_settings() { if [ -z $MTU1 ]; then MTU1="Default" MTU="" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}" else MTU=",mtu=$MTU1" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}" fi else exit-script fi - if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create an Ubuntu 24.04 VM?" --no-button Do-Over 10 58); then - echo -e "${RD}Creating an Ubuntu 24.04 VM using the above advanced settings${CL}" + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}yes${CL}" + START_VM="yes" + else + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create a Ubuntu 24.04 VM?" --no-button Do-Over 10 58); then + echo -e "${CREATING}${BOLD}${DGN}Creating a Ubuntu 24.04 VM using the above advanced settings${CL}" else header_info - echo -e "${RD}Using Advanced Settings${CL}" + echo -e "${ADVANCED}${BOLD}${RD}Using Advanced Settings${CL}" advanced_settings fi } @@ -316,15 +364,14 @@ function advanced_settings() { function start_script() { if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then header_info - echo -e "${BL}Using Default Settings${CL}" + echo -e "${DEFAULT}${BOLD}${BL}Using Default Settings${CL}" default_settings else header_info - echo -e "${RD}Using Advanced Settings${CL}" + echo -e "${ADVANCED}${BOLD}${RD}Using Advanced Settings${CL}" advanced_settings fi } - check_root arch_check pve_check @@ -392,22 +439,61 @@ done msg_info "Creating a Ubuntu 24.04 VM" qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ - -name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null qm set $VMID \ -efidisk0 ${DISK0_REF}${FORMAT} \ - -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=2G \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=${DISK_SIZE} \ -ide2 ${STORAGE}:cloudinit \ -boot order=scsi0 \ - -serial0 socket \ - -description "
+ -serial0 socket >/dev/null +DESCRIPTION=$( + cat < + + Logo + - # Ubuntu 24.04 VM +

ubuntu VM

+ +

+ + spend Coffee + +

+ + + + GitHub + + + + Discussions + + + + Issues + +
+EOF +) +qm set "$VMID" -description "$DESCRIPTION" >/dev/null +if [ -n "$DISK_SIZE" ]; then + msg_info "Resizing disk to $DISK_SIZE GB" + qm resize $VMID scsi0 ${DISK_SIZE} >/dev/null +else + msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB" + qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null +fi - - " >/dev/null msg_ok "Created a Ubuntu 24.04 VM ${CL}${BL}(${HN})" +if [ "$START_VM" == "yes" ]; then + msg_info "Starting Ubuntu 24.04 VM" + qm start $VMID + msg_ok "Started Ubuntu 24.04 VM" +fi + msg_ok "Completed Successfully!\n" echo -e "Setup Cloud-Init before starting \n -More info at https://github.com/tteck/Proxmox/discussions/2072 \n" +More info at https://github.com/community-scripts/ProxmoxVE/discussions/272 \n" diff --git a/vm/ubuntu2410-vm.sh b/vm/ubuntu2410-vm.sh new file mode 100644 index 00000000..a512d81d --- /dev/null +++ b/vm/ubuntu2410-vm.sh @@ -0,0 +1,499 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + __ ____ __ ___ __ __ _______ _ ____ ___ + / / / / /_ __ ______ / /___ __ |__ \/ // / < / __ \ | | / / |/ / + / / / / __ \/ / / / __ \/ __/ / / / __/ / // /_ / / / / / | | / / /|_/ / +/ /_/ / /_/ / /_/ / / / / /_/ /_/ / / __/__ __/ / / /_/ / | |/ / / / / +\____/_.___/\__,_/_/ /_/\__/\__,_/ /____/ /_/ (_)_/\____/ |___/_/ /_/ + +EOF +} +header_info +echo -e "\n Loading..." +GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') +NEXTID=$(pvesh get /cluster/nextid) + +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +BGN=$(echo "\033[4;92m") +GN=$(echo "\033[1;92m") +DGN=$(echo "\033[32m") +CL=$(echo "\033[m") + +CL=$(echo "\033[m") +BOLD=$(echo "\033[1m") +BFR="\\r\\033[K" +HOLD=" " +TAB=" " + +CM="${TAB}βœ”οΈ${TAB}${CL}" +CROSS="${TAB}βœ–οΈ${TAB}${CL}" +INFO="${TAB}πŸ’‘${TAB}${CL}" +OS="${TAB}πŸ–₯️${TAB}${CL}" +CONTAINERTYPE="${TAB}πŸ“¦${TAB}${CL}" +DISKSIZE="${TAB}πŸ’Ύ${TAB}${CL}" +CPUCORE="${TAB}🧠${TAB}${CL}" +RAMSIZE="${TAB}πŸ› οΈ${TAB}${CL}" +CONTAINERID="${TAB}πŸ†”${TAB}${CL}" +HOSTNAME="${TAB}🏠${TAB}${CL}" +BRIDGE="${TAB}πŸŒ‰${TAB}${CL}" +GATEWAY="${TAB}🌐${TAB}${CL}" +DEFAULT="${TAB}βš™οΈ${TAB}${CL}" +MACADDRESS="${TAB}πŸ”—${TAB}${CL}" +VLANTAG="${TAB}🏷️${TAB}${CL}" +CREATING="${TAB}πŸš€${TAB}${CL}" +ADVANCED="${TAB}🧩${TAB}${CL}" + +THIN="discard=on,ssd=1," +set -e +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +trap cleanup EXIT +function error_handler() { + local exit_code="$?" + local line_number="$1" + local command="$2" + local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" + echo -e "\n$error_message\n" + cleanup_vmid +} + +function cleanup_vmid() { + if qm status $VMID &>/dev/null; then + qm stop $VMID &>/dev/null + qm destroy $VMID &>/dev/null + fi +} + +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 24.10 VM" --yesno "This will create a New Ubuntu 24.10 VM. Proceed?" 10 58; then + : +else + header_info && echo -e "${CROSS}${RD}User exited script${CL}\n" && exit +fi + +function msg_info() { + local msg="$1" + echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}" +} + +function msg_ok() { + local msg="$1" + echo -e "${BFR}${CM}${GN}${msg}${CL}" +} + +function msg_error() { + local msg="$1" + echo -e "${BFR}${CROSS}${RD}${msg}${CL}" +} + +function check_root() { + if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then + clear + msg_error "Please run this script as root." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +function pve_check() { + if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit + fi +} + +function arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + echo -e "\n ${INFO}${YWB}This script will not work with PiMox! \n" + echo -e "\n ${YWB}Visit https://github.com/asylumexp/Proxmox for ARM64 support. \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +function ssh_check() { + if command -v pveversion >/dev/null 2>&1; then + if [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then + echo "you've been warned" + else + clear + exit + fi + fi + fi +} + +function exit-script() { + clear + echo -e "\n${CROSS}${RD}User exited script${CL}\n" + exit +} + +function default_settings() { + VMID="$NEXTID" + FORMAT=",efitype=4m" + MACHINE="" + DISK_SIZE="8G" + DISK_CACHE="" + HN="ubuntu" + CPU_TYPE="" + CORE_COUNT="2" + RAM_SIZE="2048" + BRG="vmbr0" + MAC="$GEN_MAC" + VLAN="" + MTU="" + START_VM="yes" + echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}None${CL}" + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}${HN}${CL}" + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}KVM64${CL}" + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}${RAM_SIZE}${CL}" + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}${BRG}${CL}" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}${MAC}${CL}" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}Default${CL}" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}Default${CL}" + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}yes${CL}" + echo -e "${CREATING}${BOLD}${DGN}Creating a Ubuntu 24.10 VM using the above default settings${CL}" +} + +function advanced_settings() { + while true; do + if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z "$VMID" ]; then + VMID="$NEXTID" + fi + if pct status "$VMID" &>/dev/null || qm status "$VMID" &>/dev/null; then + echo -e "${CROSS}${RD} ID $VMID is already in use${CL}" + sleep 2 + continue + fi + echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" + break + else + exit-script + fi + done + + if MACH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "MACHINE TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 10 58 2 \ + "i440fx" "Machine i440fx" ON \ + "q35" "Machine q35" OFF \ + 3>&1 1>&2 2>&3); then + if [ $MACH = q35 ]; then + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}" + FORMAT="" + MACHINE=" -machine q35" + else + echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}" + FORMAT=",efitype=4m" + MACHINE="" + fi + else + exit-script + 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 ' ') + if [[ "$DISK_SIZE" =~ ^[0-9]+$ ]]; then + DISK_SIZE="${DISK_SIZE}G" + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}$DISK_SIZE${CL}" + elif [[ "$DISK_SIZE" =~ ^[0-9]+G$ ]]; then + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}$DISK_SIZE${CL}" + else + echo -e "${DISKSIZE}${BOLD}${RD}Invalid Disk Size. Please use a number (e.g., 10 or 10G).${CL}" + exit-script + fi + else + exit-script + fi + + if DISK_CACHE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "None (Default)" ON \ + "1" "Write Through" OFF \ + 3>&1 1>&2 2>&3); then + if [ $DISK_CACHE = "1" ]; then + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}" + DISK_CACHE="cache=writethrough," + else + echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}None${CL}" + DISK_CACHE="" + fi + else + exit-script + fi + + if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VM_NAME ]; then + HN="ubuntu" + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" + else + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" + fi + else + exit-script + fi + + if CPU_TYPE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU MODEL" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "KVM64 (Default)" ON \ + "1" "Host" OFF \ + 3>&1 1>&2 2>&3); then + if [ $CPU_TYPE1 = "1" ]; then + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}" + CPU_TYPE=" -cpu host" + else + echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}KVM64${CL}" + CPU_TYPE="" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}" + else + echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}" + fi + else + exit-script + fi + + if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $RAM_SIZE ]; then + RAM_SIZE="2048" + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}" + else + echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}" + fi + else + exit-script + fi + + if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $BRG ]; then + BRG="vmbr0" + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" + else + echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" + fi + else + exit-script + fi + + if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}" + else + MAC="$MAC1" + echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VLAN1 ]; then + VLAN1="Default" + VLAN="" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}" + else + VLAN=",tag=$VLAN1" + echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}" + fi + else + exit-script + fi + + if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MTU1 ]; then + MTU1="Default" + MTU="" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}" + else + MTU=",mtu=$MTU1" + echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}" + fi + else + exit-script + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}yes${CL}" + START_VM="yes" + else + echo -e "${GATEWAY}${BOLD}${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create a Ubuntu 24.10 VM?" --no-button Do-Over 10 58); then + echo -e "${CREATING}${BOLD}${DGN}Creating a Ubuntu 24.10 VM using the above advanced settings${CL}" + else + header_info + echo -e "${ADVANCED}${BOLD}${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then + header_info + echo -e "${DEFAULT}${BOLD}${BL}Using Default Settings${CL}" + default_settings + else + header_info + echo -e "${ADVANCED}${BOLD}${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +check_root +arch_check +pve_check +ssh_check +start_script + +msg_info "Validating Storage" +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)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + STORAGE_MENU+=("$TAG" "$ITEM" "OFF") +done < <(pvesm status -content images | awk 'NR>1') +VALID=$(pvesm status -content images | awk 'NR>1') +if [ -z "$VALID" ]; then + msg_error "Unable to detect a valid storage location." + exit +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit + done +fi +msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location." +msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}." +msg_info "Retrieving the URL for the Ubuntu 24.0 Disk Image" +URL=https://cloud-images.ubuntu.com/oracular/current/oracular-server-cloudimg-amd64.img +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" + +STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') +case $STORAGE_TYPE in +nfs | dir | cifs) + DISK_EXT=".qcow2" + DISK_REF="$VMID/" + DISK_IMPORT="-format qcow2" + THIN="" + ;; +btrfs) + DISK_EXT=".raw" + DISK_REF="$VMID/" + DISK_IMPORT="-format raw" + FORMAT=",efitype=4m" + THIN="" + ;; +esac +for i in {0,1}; do + disk="DISK$i" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done + +msg_info "Creating a Ubuntu 24.10 VM" +qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF}${FORMAT} \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=${DISK_SIZE} \ + -ide2 ${STORAGE}:cloudinit \ + -boot order=scsi0 \ + -serial0 socket >/dev/null +DESCRIPTION=$( + cat < + + Logo + + +

Ubuntu 24.10 VM

+ +

+ + spend Coffee + +

+ + + + GitHub + + + + Discussions + + + + Issues + + +EOF +) +qm set "$VMID" -description "$DESCRIPTION" >/dev/null +if [ -n "$DISK_SIZE" ]; then + msg_info "Resizing disk to $DISK_SIZE GB" + qm resize $VMID scsi0 ${DISK_SIZE} >/dev/null +else + msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB" + qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null +fi + +msg_ok "Created a Ubuntu 24.10 VM ${CL}${BL}(${HN})" +if [ "$START_VM" == "yes" ]; then + msg_info "Starting Ubuntu 24.10 VM" + qm start $VMID + msg_ok "Started Ubuntu 24.10 VM" +fi + +msg_ok "Completed Successfully!\n" +echo -e "Setup Cloud-Init before starting \n +More info at https://github.com/community-scripts/ProxmoxVE/discussions/272 \n"