#!/bin/bash # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. src_dir=$(pwd) [[ -r ${src_dir}/util-msg.sh ]] && source ${src_dir}/util-msg.sh import ${src_dir}/util.sh # setting of the general parameters work_dir="${src_dir}/build" outFolder="${src_dir}/out" if [ $# -eq 0 ]; then msg "No " msg2 "Usage: testiso " exit 1 fi vdi_size=10240 # 10GB size #Check if already exist virtual disk and in case create it if [[ -e ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox ]]; then msg "CachyOS Virtual Machine Found" else msg "We create a new VirtualBox Machine called CachyOS" msg2 "We create a new Virtual Disk Image ( vdi ) with ${vdi_size}GB" VBoxManage createmedium disk --filename ~/VirtualBox\ VMs/CachyOS/CachyOS.vdi --size ${vdi_size} --format VDI --variant Fixed UUID=$(VBoxManage showhdinfo ~/VirtualBox\ VMs/CachyOS/CachyOS.vdi | awk 'NR == 1 {print $2}') #uuid of vdi disk gui_lang=$(awk -F'[.=]' '/LANG/ {print $2}' /etc/locale.conf) echo ' ' > ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox sed -i "s/UUID/$UUID/g" ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox sed -i "s/gui_lang/$gui_lang/g" ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox VBoxManage registervm ~/VirtualBox\ VMs/CachyOS/CachyOS.vbox #register the cachyos vbox machine fi VBoxManage storageattach CachyOS --storagectl IDE --port 1 --device 0 --medium emptydrive #empty the dvd drive sleep 1 iso_dir=$(find ${outFolder} -type d -iname "$1") iso=${iso_dir} if [[ -e $(ls ${iso}/*.iso) ]]; then iso_name=$(ls ${iso}/*.iso) else msg "No ISO to load present" exit 1 fi VBoxManage storageattach CachyOS --storagectl IDE --port 1 --device 0 --type dvddrive --medium $iso_name #attach dvd cachyos iso sleep 1 msg2 "Run Vbox CachyOS with ${iso_name}" sleep 2 VBoxManage startvm CachyOS #run vbox machine