#!/bin/bash # Create VyOS IOS image # v0.1.3 iso_image='live-image-amd64.hybrid.iso' # 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 # check if /usr/sbin is exported export | grep PATH | grep -q '/usr/sbin'; ret_path="$?" [ "$ret_path" != 0 ] && echo "path /usr/sbin/ is not exported, use 'su -' instead 'su', 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 # dodify 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#COPY entrypoint.sh /usr/local/bin/entrypoint.sh#cp ~/vyos-build-current/docker/entrypoint.sh /usr/local/bin/#g' docker/Dockerfile sed -i 's#ENTRYPOINT \["/usr/local/bin/entrypoint.sh"\]#/usr/local/bin/entrypoint.sh#g' docker/Dockerfile sed -i 's/COPY/cp/g' docker/Dockerfile # run commands from Docker file bash docker/Dockerfile # compile VyOS from source ./configure make iso # check if ISO has been created if [ -f "build/$iso_image" ]; then echo -e "\nYour VyOS ISO image '$iso_image' is located in directory $(pwd)/build/" && exit 0 else echo -e "\nCan't locate VyOS ISO image '$iso_image', exiting" && exit 1 fi