Auto update image - script error

Used to use the following to auto-update my image on a periodic basis

#!/bin/vbash

# Include VyOS functions
source /opt/vyatta/etc/functions/script-template

# Script debugging
#set -x

# Set variables and change vrf
URL=$(curl -s "https://api.github.com/repos/vyos/vyos-rolling-nightly-builds/releases/latest" | grep browser_download_url | head -n 1 | cut -d\" -f4)

# Perform update
#run add system image ${URL}

printf "y" '%s\n' "y" "y" | /opt/vyatta/bin/vyatta-op-cmd-wrapper add system image ${URL}

Printf entries handled skipping the signature not valid warning, accepting the default image name, boot and config choices.

Now I get the following error which I think is caused by incorrectly sending a new line to a python script but for the life of me I don’t know, and cannot find, the correct formatting.

The file is 430.000 MiB.
[#################################################################] 100%
Validating signature
Signature is not valid. Do you want to continue with installation? [y/N] Validating image checksums
What would you like to name this image? (Default: 1.5-rolling-202311280023) Cleaning up
Unmounting target filesystems
Removing temporary files
Whooops: EOF when reading a line

Apologies in advance for the basic nature of this problem, but any help would be appreciated.

1 Like

What if you run it without the printf stuff?

Still same amount of questions from the “add system image” command?

Im thinking if that command have changed to it no longer asks for 4 inputs but only 3 or so?

You can use API calls to update images

Yes, it runs fine without printf and requires 4 inputs.

Signature skip
Image name
Boot default
Config copy

How would the above run via the API approach in an automated manner, is there examples/documentation for this?

of course, you can look here

https://docs.vyos.io/en/latest/automation/vyos-api.html#vyosapi

curl -k --location --request POST 'https://vyos/image' \ --form data='{"op": "add", "url": "https://downloads.vyos.io/rolling/current/amd64/vyos-rolling-latest.iso"}' \ --form key='MY-HTTPS-API-PLAINTEXT-KEY'

Edit:

Vyos update over ssh with Jenkins

#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
echo | /opt/vyatta/bin/vyatta-op-cmd-wrapper add system image /home/jenkins/iso/vyos-rolling-latest.iso

@phillipmcmahon
printf "y\n\ny\ny\n" | /opt/vyatta/bin/vyatta-op-cmd-wrapper add system image ${URL}
works for me.

1 Like

Many thanks, and quite obvious now I see it. Thanks a lot.

One note: later today we’ll merge the missing step in the new image-tools that copied the ssh host keys (T5789), so at some future point, when updating from an instance containing that fix, the line will be:
printf "y\n\ny\ny\ny\n"

Thanks for the heads up!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.