#!/usr/bin/bash # ____ __ ____ ______ __ # / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / # / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / # / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | # /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| TESTS # # Title: Docker-OSX (Mac on Docker) # Author: Sick.Codes https://twitter.com/sickcodes # Version: 4.2 # License: GPLv3+ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes # # Status: Used internally to auto build, run and test images on DO. # help_text="Usage: ./test.sh --branch --repo General options: --branch, -b Git branch, default is master --repo, -r Alternative link to build --mirror-country, -m Two letter country code for Arch mirrors --docker-username, -u Docker hub username --docker-password, -p Docker hub password --vnc-password, -v Choose a VNC passwd. Flags --no-cache, -n Enable --no-cache (default already) --no-no-cache, -nn Disable --no-cache docker builds --help, -h, help Display this help and exit " # set -xeuf -o pipefail # gather arguments while (( "$#" )); do case "${1}" in --help | -h | h | help ) echo "${help_text}" && exit 0 ;; --branch=* | -b=* ) export BRANCH="${1#*=}" shift ;; --branch* | -b* ) export BRANCH="${2}" shift shift ;; --repo=* | -r=* ) export REPO="${1#*=}" shift ;; --repo* | -r* ) export REPO="${2}" shift shift ;; --mirror-country=* | -m=* ) export MIRROR_COUNTRY="${1#*=}" shift ;; --mirror-country* | -m* ) export MIRROR_COUNTRY="${2}" shift shift ;; --vnc-password=* | -v=* | --vnc-passwd=* ) export VNC_PASSWORD="${1#*=}" shift ;; --vnc-password* | -v* | --vnc-passwd* ) export VNC_PASSWORD="${2}" shift shift ;; --docker-username=* | -u=* ) export DOCKER_USERNAME="${1#*=}" shift ;; --docker-username* | -u* ) export DOCKER_USERNAME="${2}" shift shift ;; --docker-password=* | -p=* ) export DOCKER_PASSWORD="${1#*=}" shift ;; --docker-password* | -p* ) export DOCKER_PASSWORD="${2}" shift shift ;; --no-cache | -n ) export NO_CACHE='--no-cache' shift ;; --no-no-cache | -nn ) export NO_CACHE= shift ;; *) echo "Invalid option: ${1}" exit 1 ;; esac done BRANCH="${BRANCH:=master}" REPO="${REPO:=https://github.com/sickcodes/Docker-OSX.git}" VNC_PASSWORD="${VNC_PASSWORD:=testing}" MIRROR_COUNTRY="${MIRROR_COUNTRY:=US}" NO_CACHE="${NO_CACHE:=--no-cache}" TEST_BUILDS=( 'docker-osx:naked' 'docker-osx:naked-auto' 'docker-osx:auto' ) TEST_BUILDS=( 'docker-osx:naked' 'docker-osx:naked-auto' 'docker-osx:auto' ) VERSION_BUILDS=( 'high-sierra' 'mojave' 'catalina' 'big-sur' 'monterey' 'ventura' 'sonoma' ) warning () { clear for j in {15..1}; do echo "############# WARNING: THIS SCRIPT IS NOT INTENDED FOR USE BY ################" echo "############# IT IS USED BY THE PROJECT TO BUILD AND PUSH TO DOCKERHUB #######" echo "" echo " Press Ctrl C to stop. " MAX_COLS=$((${COLUMNS}/2)) printf "$j %.0s" {1..20} echo sleep 1 done } install_docker () { apt remove docker docker-engine docker.io containerd runc -y \ ; apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y \ && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \ && apt-key fingerprint 0EBFCD88 \ && > /etc/apt/sources.list.d/docker.list \ && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ && apt update -y \ && apt install docker-ce docker-ce-cli containerd.io -y \ && usermod -aG docker "${USER}" \ && su hook docker run --rm hello-world } install_vnc () { apt update -y \ && apt install xorg openbox tigervnc-standalone-server tigervnc-common tigervnc-xorg-extension tigervnc-viewer -y \ && mkdir -p ${HOME}/.vnc \ && touch ~/.vnc/config \ && tee -a ~/.vnc/config <<< 'geometry=1920x1080' \ && tee -a ~/.vnc/config <<< 'localhost' \ && tee -a ~/.vnc/config <<< 'alwaysshared' \ && touch ./vnc.sh \ && printf '\n%s\n' \ 'sudo rm -f /tmp/.X99-lock' \ 'export DISPLAY=:99' \ '/usr/bin/Xvnc -geometry 1920x1080 -rfbauth ~/.vnc/passwd :99 &' > ./vnc.sh \ && tee vncpasswd_file <<< "${VNC_PASSWORD:=testing}" && echo "${VNC_PASSWORD:="$(tr -dc '[:graph:]' ${HOME}/.vnc/passwd \ && chmod 600 ~/.vnc/passwd \ && apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager -y \ && sudo systemctl enable libvirtd.service \ && sudo systemctl enable virtlogd.service \ && echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ && sudo modprobe kvm \ && echo 'export DISPLAY=:99' >> ~/.bashrc \ && printf '\n\n\n\n%s\n%s\n\n\n\n' '===========VNC_PASSWORD========== ' "$(