-
-
Save Jelle-S/b0c5c9880532d10c936cc2771f4092e2 to your computer and use it in GitHub Desktop.
# Installs Home Assistant on VirtualBox following https://www.home-assistant.io/installation/linux | |
# Install VirtualBox | |
sudo apt-get -y install virtualbox | |
# Create a new VM | |
VBoxManage createvm --name homeassistant --register | |
# Select OS type "Other Linux (64-bit)" | |
VBoxManage modifyvm homeassistant --ostype Linux_64 | |
# Set RAM to 6GB (modify to your needs, TODO: make this an option, default value 2GB), video memory to 16MB (TODO: make this an option, default value 16MB) | |
VBoxManage modifyvm homeassistant --memory 6144 --vram 16 | |
# 2 vCPUs (TODO: make this an option, default value 2) | |
VBoxManage modifyvm homeassistant --cpus 2 | |
# Download the latest vdi image (TODO: Always use the latest version) | |
wget https://github.com/home-assistant/operating-system/releases/download/7.2/haos_ova-7.2.vdi.zip | |
sudo apt-get -y install unzip | |
unzip haos_ova-7.2.vdi.zip | |
rm haos_ova-7.2.vdi.zip | |
# Resize the harddisk to 100GB (TODO: make this an option, default value 32GB) | |
VBoxManage modifyhd "haos_ova-7.2.vdi" --resize 102400 | |
# Move the vdi image to a location of choice (TODO: make this an option, default value TBD) | |
mv haos_ova-7.2.vdi VirtualBox\ VMs/homeassistant/ | |
# Add the SATA controller | |
VBoxManage storagectl homeassistant --name "SATA Controller" --add sata --controller IntelAHCI | |
# Attach the vdi image (TODO: use the vdi path option) | |
VBoxManage storageattach homeassistant --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium ~/VirtualBox\ VMs/homeassistant/haos_ova-7.2.vdi | |
# Create the bridged adapter (TODO: Figure out a way to detect the netwerk adapter, or add it as an option) | |
VBoxManage modifyvm homeassistant --nic1 bridged --nictype1 82540EM --bridgeadapter1 enp2s0 | |
# Enable EFI | |
VBoxManage modifyvm homeassistant --firmware efi | |
# Set Intel HD Audio as Audio controller | |
VBoxManage modifyvm homeassistant --audiocontroller hda | |
# Start Home Assistant headless | |
VBoxManage startvm homeassistant --type headless | |
# TODO: Figure out the guest box's IP address and output it | |
"Figure out the guest box's IP address and output it"
If you enable RDP (Remoed Desktop) with:
vboxmanage modifyvm homeassistant --vrde on
(You'll probably have to reboot the virtual machine unless you ran this command before starting the vm)
Then you can RDP to the guest using the host's IP address. The RDP would have to originate from a machine with a GUI
Once in the guest at the ha>
prompt, execute
net info
This should provide the guest's IP address
The options of which you write could be setting bash variables at the beginning of the script.
One of them could be the name for the virtual machine, eg.
VM=HomeAssistant
and then replace homeassistant with $VM
If you want the wifi interface it can be extracted into the variable $HAIF
with the command:
export HAIF=$(nmcli d | grep wifi | awk '{print $1;}')
I don't believe you need to have the --nictype
when using bridgedadapter
thus
# Create the bridged adapter (DONE: Figure out a way to detect the netwerk adapter, or add it as an option)
# Network medium, NM: **wifi** or **ethernet**
NM=wifi
VM=HomeAssistant
export HAIF=$(nmcli d | grep $NM | awk '{print $1;}')
VBoxManage modifyvm $VM --nic1 bridged --bridgeadapter1 $HAIF
auto start
nano ~/.bashrc
(sleep 20 && VBoxManage startvm homeassistant --type headless) &