I wish to automate the installation of the latest rolling release on my test router. I.e. run a task-scheduler job to pull the latest version and reboot at some early hour in the morning.
The "add system image " requires interactive input. Is this some way around this or another route I should be taking here?
Hi @phillipmcmahon
If you have installed a box with vyos and need to upgrade, you can use “expect” scripts.
In this example vyos already installed and it’s upgrade procedure.
You need any linux with additional package “expect” and login to vyos by the key.
It’s for LTS, but can be adapted to rolling.
#!/usr/bin/env bash
remote_vyos_host=$1
expect <<EOF
set timeout 180
spawn ssh vyos@$remote_vyos_host
expect "vyos*:~" {send "add system image /home/vyos/vyos-1.2.5-amd64.iso\r"}
expect "What would you like to name this image?" {send "\r"}
expect "directory and config file?" {send "Yes\r"}
expect "current configuration? (Yes/No)" {send "Yes\r"}
expect "vyos*:~" {send "reboot\r"}
expect "Are you sure you want to reboot this system" {send "y\r"}
expect "vyos*:~" {send "\r"}
exit 0
EOF
Script for upgrade rolling release from local iso file located in /home/vyos.
#!/usr/bin/env bash
remote_vyos_host=$1
# Check that the ip address as the first argument is set
if [ $# -ne 1 ]; then
echo "Usage: $0 <vyos_ip_adderss>"
exit 1
fi
expect <<EOF
set timeout 600
spawn ssh vyos@$remote_vyos_host
expect "vyos*:~" {send "add system image /home/vyos/vyos-rolling-latest.iso\r"}
expect "What would you like to name this image?" {send "\r"}
expect "directory and config file?" {send "Yes\r"}
expect "current configuration? (Yes/No)" {send "Yes\r"}
expect "vyos*:~" {send "reboot\r"}
expect "Are you sure you want to reboot this system" {send "y\r"}
expect "vyos*:~" {send "\r"}
exit 0
EOF
./upgrade.sh x.x.x.x
Where x.x.x.x ip address that is accessible by ssh key for user “vyos”.
I don’t know another way to get around interactive questions without “expect” or “ansible” (interactive application).
Perhaps there could be an extension of the add system image that performs a quiet install with no prompts, of the answer to the prompts can be provided in the command line?