Updated Mikrotik CHR script

Remove EFI disk and install as per Mikrotik reference script
pull/2133/head
NiccyB 2 years ago
parent a0a250cab5
commit ea226ccde9
  1. 38
      vm/mikrotik-routeros-chr.sh

@ -2,7 +2,7 @@
# Copyright (c) 2021-2023 tteck # Copyright (c) 2021-2023 tteck
# Author: tteck (tteckster) # Author: tteck (tteckster)
# Adapted from x86 RouterOS script: NiccyB # Adapted from x86 RouterOS script using Mikrotik reference script: NiccyB
# License: MIT # License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE # https://github.com/tteck/Proxmox/raw/main/LICENSE
@ -70,7 +70,7 @@ pushd $TEMP_DIR >/dev/null
sleep 3 sleep 3
exit exit
fi fi
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "Mikrotik RouterOS VM" --yesno "This will create a New Mikrotik RouterOS VM. Proceed?" 10 58); then if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "Mikrotik RouterOS VM" --yesno "This will create a New Mikrotik RouterOS CHR VM. Proceed?" 10 58); then
echo "User selected Yes" echo "User selected Yes"
else else
clear clear
@ -90,7 +90,7 @@ function default_settings() {
echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}" echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}"
VMID=$NEXTID VMID=$NEXTID
echo -e "${DGN}Using Hostname: ${BGN}mikrotik-routeros${CL}" echo -e "${DGN}Using Hostname: ${BGN}mikrotik-routeros${CL}"
HN=mikrotik-routeros HN=mikrotik-routeros-chr
echo -e "${DGN}Allocated Cores: ${BGN}1${CL}" echo -e "${DGN}Allocated Cores: ${BGN}1${CL}"
CORE_COUNT="1" CORE_COUNT="1"
echo -e "${DGN}Allocated RAM: ${BGN}256${CL}" echo -e "${DGN}Allocated RAM: ${BGN}256${CL}"
@ -115,7 +115,7 @@ function advanced_settings() {
else else
exit exit
fi fi
VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 Mikrotik-RouterOS --title "HOSTNAME" 3>&1 1>&2 2>&3) VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 Mikrotik-RouterOS-CHR --title "HOSTNAME" 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
HN=$(echo ${VM_NAME,,} | tr -d ' ') HN=$(echo ${VM_NAME,,} | tr -d ' ')
@ -130,7 +130,7 @@ function advanced_settings() {
else else
exit exit
fi fi
RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 1024 --title "RAM" 3>&1 1>&2 2>&3) RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 256 --title "RAM" 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
@ -235,7 +235,7 @@ msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location."
msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}." msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}."
msg_info "Getting URL for Mikrotik RouterOS CHR Disk Image" msg_info "Getting URL for Mikrotik RouterOS CHR Disk Image"
URL=https://download.mikrotik.com/routeros/6.49.10/chr-6.49.10.img.zip URL=https://download.mikrotik.com/routeros/7.12.1/chr-7.12.1.img.zip
sleep 2 sleep 2
msg_ok "${CL}${BL}${URL}${CL}" msg_ok "${CL}${BL}${URL}${CL}"
@ -259,31 +259,29 @@ btrfs)
DISK_IMPORT="-format raw" DISK_IMPORT="-format raw"
;; ;;
esac esac
for i in {0,1}; do
disk="DISK$i" disk="DISK0"
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} eval DISK0=vm-${VMID}-disk-0${DISK_EXT:-}
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} eval DISK0_REF=${STORAGE}:${DISK_REF:-}${!disk}
done
msg_ok "Extracted Mikrotik RouterOS CHR Disk Image" msg_ok "Extracted Mikrotik RouterOS CHR Disk Image"
msg_info "Creating Mikrotik RouterOS CHR VM" msg_info "Creating Mikrotik RouterOS CHR VM"
qm create $VMID -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $HN -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU \ qm create $VMID -bios seabios -cores $CORE_COUNT -memory $RAM_SIZE -name $HN -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU \
-onboot 1 -ostype l26 -scsihw virtio-scsi-pci -onboot 1 -ostype l26
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
qm set $VMID \ qm set $VMID \
-efidisk0 ${DISK0_REF},efitype=4m,size=4M \ -virtio0 ${DISK0_REF} \
-scsi0 ${DISK1_REF},size=512M \ -boot order=virtio0 \
-boot order=scsi0 \
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a>
# Mikrotik RouterOS # Mikrotik RouterOS
<a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/&#x2615;-Buy me a coffee-blue' /></a> <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/&#x2615;-Buy me a coffee-blue' /></a>
</div>" >/dev/null </div>" >/dev/null
msg_ok "Mikrotik RouterOS VM ${CL}${BL}(${HN})" msg_ok "Mikrotik RouterOS CHR VM ${CL}${BL}(${HN})"
if [ "$START_VM" == "yes" ]; then if [ "$START_VM" == "yes" ]; then
msg_info "Starting Mikrotik RouterOS VM" msg_info "Starting Mikrotik RouterOS CHR VM"
qm start $VMID qm start $VMID
msg_ok "Started Mikrotik RouterOS VM" msg_ok "Started Mikrotik RouterOS CHR VM"
fi fi
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"

Loading…
Cancel
Save