proxmox/VM/OpenWRT/setup.sh
2023-07-26 05:21:42 +02:00

50 lines
1.6 KiB
Bash

#!/bin/bash
# ____ _ _
#/ ___|| |_| |__ ___ _ __ ___
#\___ \| __| '_ \ / _ \| '_ \ / _ \
# ___) | |_| | | | (_) | |_) | __/
#|____/ \__|_| |_|\___/| .__/ \___|
# |_|
#
regex='<strong>Current Stable Release - OpenWrt ([^/]*)<\/strong>' && response=$(curl -s https://openwrt.org) && [[ $response =~ $regex ]] && stableVersion="${BASH_REMATCH[1]}"
wget -O openwrt.img.gz https://downloads.openwrt.org/releases/$stableVersion/targets/x86/64/openwrt-$stableVersion-x86-64-generic-ext4-combined.img.gz
gunzip ./openwrt.img.gz
mv ./openwrt*.img ./openwrt.raw
qemu-img resize -f raw ./openwrt.raw 512M
echo "What Storage do you want to use? eg: local"
read -p "Enter your choice: " what_storage
qm importdisk 123 openwrt.raw $what_storage
echo "What is the VM name?"
read -p "Enter your choice: " vm_name
qm create $vm_id --memory 2048 --core 2 --name $vm_name --net0 virtio,bridge=vmbr0 >/dev/null
qm importdisk $vm_id $file local-lvm >/dev/null
qm set $vm_id --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-$vm_id-disk-0 >/dev/null
qm set $vm_id --ide2 local-lvm:cloudinit >/dev/null
qm set $vm_id --boot c --bootdisk scsi0 >/dev/null
qm set $vm_id --serial0 socket --vga serial0 >/dev/null
qm set $vm_id --balloon 0 >/dev/null
qm set $vm_id --onboot 0 >/dev/null
qm set $vm_id --tablet 0 >/dev/null
qm set $vm_id --agent enabled=1 >/dev/null
qm set $vm_id --ipconfig0 ip=dhcp,ip6=dhcp >/dev/
echo "What is the Username?"
read -p "Enter your choice: " username
echo "What is the Password?"
read -p "Enter your choice: " password
qm set $vm_id --ciuser $username --cipassword $password >/dev/null
# Exit the script.
exit 0