diff --git a/tests/test.sh b/tests/test.sh new file mode 100644 index 0000000..a8e328b --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,300 @@ +#!/usr/bin/docker +# ____ __ ____ ______ __ +# / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / +# / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / +# / /_/ / /_/ / /__/ ,< / __/ / / /_/ /___/ / | +# /_____/\____/\___/_/|_|\___/_/ \____//____/_/|_| 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: Work in progress. +# + +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-no-cache, -nn Disable --no-cache docker builds + --help, -h, help Display this help and exit +" + +# set -xeuf -o pipefail + +NO_CACHE='--no-cache' + +# 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-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}" + +TEST_BUILDS=( +'docker-osx:latest' +'docker-osx:naked' +'docker-osx:big-sur' +'docker-osx:auto' +#'docker-osx:auto-big-sur' +) + +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 \ + && 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========== ' "$(