#!/bin/bash # Create VyOS IOS image # v0.1 iso_image='live-image-amd64.hybrid.iso' user_host='brezular' ip='192.168.1.38' # exit 0 - ISO created and copied to host # exit 1 - ISO not created # exit 2 - ISO created but not copied [ "$(id -u)" != 0 ] && echo "Run script as root, exiting" && exit 1 apt -y install unzip python3 apt update #Download and extract VyOS source cd ~ wget https://github.com/vyos/vyos-build/archive/current.zip [ ! -f current.zip ] && echo "Can't locate file 'current.zip', exiting" && exit 1 unzip current.zip cd vyos-build-current #Modify file Dockerfile so it can download and install required packages needed for compilation cp docker/Dockerfile docker/Dockerfile.bak sed -i 's/RUN//g' docker/Dockerfile sed -i 's/ENTRYPOINT//g' docker/Dockerfile sed -i 's/COPY/cp/g' docker/Dockerfile # Run file Docker bash docker/Dockerfile # Compile VyOS source ./configure make iso # Check if ISO has been created if [ -f "build/$iso_image" ]; then echo -e "\nYour new VyOS ISO image '$iso_image' is located in directory $(pwd)/build/" else echo -e "\nCan't locate VyOS ISO image '$iso_image', exiting" && exit 1 fi # Copy VyOS ISO from guest to host read -p "Do you want me to copy VyOS ISO '$iso_image' to '$user_host@$ip:/home/$user_host/'? [y/n]: " answer if [ "$answer" == y ]; then echo -e "I'm going to copy ISO to host '$ip' as '$user_host'\n" scp -rv "build/$iso_image" "$user_host"@"$ip":/home/$user_host/ if [ "$?" == 0 ]; then echo -e "\nVyOS ISO '$iso_image' has been successfully copied to '$user_host@$ip:/home/$user_host/'" exit 0 else echo -e "\nCan't copy VyOS ISO image '$iso_image' to '$user_host@$ip:/home/$user_host/', exiting" && exit 1 fi elif [ "$answer" == n ]; then echo -e "\nNothing to do, exiting" && exit 2 else echo -e "\n'$answer' isn't a valid option, exiting" && exit 2 fi exit 0