#!/usr/bin/expect # 1.2.0 # Script deploys VyOS network OS to QEMU instance running on localhost 3355 with attached VyOS ISO # # Prior to starting this script you must download VyOS ISO and create QEMU blank disk: # /usr/local/bin/qemu-img create -f vmdk vyos-amd64.vmdk 2G # # Then you can run Qemu disk using cdrom parameter with attached ISO e.g. # /usr/local/bin/qemu-system-x86_64 -boot c -cdrom vyos-1.2.0-epa2-amd64.iso -hda vyos-amd64.vmdk -m 4G -enable-kvm -serial telnet:127.0.0.1:3355,server,nowait spawn telnet localhost 3355 set timeout 3600 send "\r" expect "vyos login:" send "vyos\r" expect "Password:" send "vyos\r" expect "*$*" send "install image\n" expect "*Would you like to continue?*" send "\r" expect "*Partition (Auto/Parted/Skip)*" send "\r" expect "*Install the image on?*" send "\r" expect "*This will destroy all data*" send "Yes\r" expect "*How big of a root partition should I create?*" send "\r" expect "*What would you like to name this image?*" send "\r" expect "*Which one should I copy to sda?*" send "\r" expect "*Enter password for user*" send "vyos\r" expect "*Retype password*" send "vyos\r" expect "*Which drive should*" send "\r" expect "*$*" send "sudo su\r" expect "*#*" send "reboot\r" expect "*Are you sure you want to reboot*" send "y\r" expect "vyos login:*" send "vyos\r" expect "Password:" send "vyos\r" expect "*$*" send "sudo su\r" expect "*#*" send "mv /lib/udev/vyatta_net_name /lib/udev/vyatta_net_name.bak\r" expect "*#*" send "sed -i 's/2367abef/00/g' /lib/udev/rules.d/75-persistent-net-generator.rules\r" expect "*#*" send "sed -i 's/set default=0/set default=1/g' /boot/grub/grub.cfg\r" expect "*#*" send "\x1d" expect "telnet>" send "quit\r"