From bf9a7311a0ea46c0374315d3d6fc8d0417ba7b1f Mon Sep 17 00:00:00 2001 From: Justin Travis Date: Sun, 24 Jul 2022 20:28:54 +0000 Subject: [PATCH] KASM-2969 Unityhub Image --- .gitlab-ci.yml | 8 +- dockerfile-kasm-unityhub | 40 +++++++++ docs/unityhub/README.md | 11 +++ docs/unityhub/description.txt | 1 + src/ubuntu/install/unityhub/custom_startup.sh | 84 +++++++++++++++++++ .../install/unityhub/install_unityhub.sh | 26 ++++++ 6 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 dockerfile-kasm-unityhub create mode 100644 docs/unityhub/README.md create mode 100644 docs/unityhub/description.txt create mode 100644 src/ubuntu/install/unityhub/custom_startup.sh create mode 100644 src/ubuntu/install/unityhub/install_unityhub.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f64839..b78790a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,7 +60,7 @@ variables: - tracelabs - ubuntu-focal-dind - ubuntu-focal-dind-rootless - - vmware-horizon + - unityhub - zoom - zsnes @@ -133,7 +133,7 @@ build_app_images: - aws-autoscale parallel: matrix: - - KASM_IMAGE: [doom, sublime-text, gimp, vs-code, teams, only-office, zoom, signal, steam, postman, insomnia, zsnes, vlc, maltego, telegram, hunchly, java-dev, terminal, vmware-horizon, remmina, rdesktop, discord, libre-office, thunderbird, atom, audacity, deluge, filezilla, inkscape, pinta, qbittorrent, blender] + - KASM_IMAGE: [doom, sublime-text, gimp, vs-code, teams, only-office, zoom, signal, steam, postman, insomnia, zsnes, vlc, maltego, telegram, hunchly, java-dev, terminal, remmina, rdesktop, discord, libre-office, thunderbird, atom, audacity, deluge, filezilla, inkscape, pinta, qbittorrent, blender, unityhub] build_ubuntu_desktop_images: stage: build @@ -430,7 +430,7 @@ build_schedules_app_images: - aws-autoscale parallel: matrix: - - KASM_IMAGE: [doom, sublime-text, gimp, vs-code, teams, only-office, zoom, signal, steam, postman, insomnia, zsnes, vlc, maltego, telegram, hunchly, java-dev, terminal, vmware-horizon, remmina, rdesktop, discord, libre-office, thunderbird, atom, audacity, deluge, filezilla, inkscape, pinta, qbittorrent, blender] + - KASM_IMAGE: [doom, sublime-text, gimp, vs-code, teams, only-office, zoom, signal, steam, postman, insomnia, zsnes, vlc, maltego, telegram, hunchly, java-dev, terminal, remmina, rdesktop, discord, libre-office, thunderbird, atom, audacity, deluge, filezilla, inkscape, pinta, qbittorrent, blender, unityhub] build_schedules_ubuntu_desktop_images: image: ${ORG_NAME}/docker-buildx-private:develop @@ -572,8 +572,8 @@ update_readmes: - ubuntu-jammy-desktop - ubuntu-focal-dind - ubuntu-focal-dind-rootless + - unityhub - vlc - - vmware-horizon - vs-code - zoom - zsnes diff --git a/dockerfile-kasm-unityhub b/dockerfile-kasm-unityhub new file mode 100644 index 0000000..87c92f7 --- /dev/null +++ b/dockerfile-kasm-unityhub @@ -0,0 +1,40 @@ +ARG BASE_TAG="develop" +ARG BASE_IMAGE="core-ubuntu-focal" +FROM kasmweb/$BASE_IMAGE:$BASE_TAG +USER root + +ENV HOME /home/kasm-default-profile +ENV STARTUPDIR /dockerstartup +ENV INST_SCRIPTS $STARTUPDIR/install +ENV LOCALE_ALL= +ENV LANGUAGE= +WORKDIR $HOME + +######### Customize Container Here ########### + +# Install Utilities +COPY ./src/ubuntu/install/misc $INST_SCRIPTS/misc/ +RUN bash $INST_SCRIPTS/misc/install_tools.sh && rm -rf $INST_SCRIPTS/misc/ + +# Install Google Chrome +COPY ./src/ubuntu/install/chrome $INST_SCRIPTS/chrome/ +RUN bash $INST_SCRIPTS/chrome/install_chrome.sh && rm -rf $INST_SCRIPTS/chrome/ + +# Install Unity +COPY ./src/ubuntu/install/unityhub $INST_SCRIPTS/unityhub/ +RUN bash $INST_SCRIPTS/unityhub/install_unityhub.sh && rm -rf $INST_SCRIPTS/unityhub/ + +COPY ./src/ubuntu/install/unityhub/custom_startup.sh $STARTUPDIR/custom_startup.sh +RUN chmod +x $STARTUPDIR/custom_startup.sh +RUN chmod 755 $STARTUPDIR/custom_startup.sh + +######### End Customizations ########### + +RUN chown 1000:0 $HOME +RUN $STARTUPDIR/set_user_permission.sh $HOME + +ENV HOME /home/kasm-user +WORKDIR $HOME +RUN mkdir -p $HOME && chown -R 1000:0 $HOME + +USER 1000 diff --git a/docs/unityhub/README.md b/docs/unityhub/README.md new file mode 100644 index 0000000..dfa4c24 --- /dev/null +++ b/docs/unityhub/README.md @@ -0,0 +1,11 @@ +# About This Image + +This Image contains a browser-accessible version of [Unity Hub](https://unity.com/). + +![Screenshot][Image_Screenshot] + +[Image_Screenshot]: https://5856039.fs1.hubspotusercontent-na1.net/hubfs/5856039/dockerhub/image-screenshots/unityhub.png "Image Screenshot" + +# Environment Variables + +* `APP_ARGS` - Additional arguments to pass to the application when launched. diff --git a/docs/unityhub/description.txt b/docs/unityhub/description.txt new file mode 100644 index 0000000..82a41ee --- /dev/null +++ b/docs/unityhub/description.txt @@ -0,0 +1 @@ +Unity Hub for Kasm Workspaces \ No newline at end of file diff --git a/src/ubuntu/install/unityhub/custom_startup.sh b/src/ubuntu/install/unityhub/custom_startup.sh new file mode 100644 index 0000000..15a8d0c --- /dev/null +++ b/src/ubuntu/install/unityhub/custom_startup.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -ex +START_COMMAND="/opt/unityhub/unityhub" +PGREP="unityhub-bin" +export MAXIMIZE="false" +export MAXIMIZE_NAME="Unity" +MAXIMIZE_SCRIPT=$STARTUPDIR/maximize_window.sh +DEFAULT_ARGS=" --no-sandbox" +ARGS=${APP_ARGS:-$DEFAULT_ARGS} + +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" + +while [[ $1 != -- ]]; do + case $1 in + -g|--go) GO='true'; shift 1;; + -a|--assign) ASSIGN='true'; shift 1;; + -u|--url) OPT_URL=$2; shift 2;; + *) echo "bad option: $1" >&2; exit 1;; + esac +done +shift + +# Process non-option arguments. +for arg; do + echo "arg! $arg" +done + +FORCE=$2 + +kasm_exec() { + if [ -n "$OPT_URL" ] ; then + URL=$OPT_URL + elif [ -n "$1" ] ; then + URL=$1 + fi + + # Since we are execing into a container that already has the browser running from startup, + # when we don't have a URL to open we want to do nothing. Otherwise a second browser instance would open. + if [ -n "$URL" ] ; then + /usr/bin/filter_ready + /usr/bin/desktop_ready + bash ${MAXIMIZE_SCRIPT} & + $START_COMMAND $ARGS $OPT_URL + else + echo "No URL specified for exec command. Doing nothing." + fi +} + +kasm_startup() { + if [ -n "$KASM_URL" ] ; then + URL=$KASM_URL + elif [ -z "$URL" ] ; then + URL=$LAUNCH_URL + fi + + if [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ; then + + echo "Entering process startup loop" + set +x + while true + do + if ! pgrep -x $PGREP > /dev/null + then + /usr/bin/filter_ready + /usr/bin/desktop_ready + set +e + bash ${MAXIMIZE_SCRIPT} & + $START_COMMAND $ARGS $URL + set -e + fi + sleep 1 + done + set -x + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/unityhub/install_unityhub.sh b/src/ubuntu/install/unityhub/install_unityhub.sh new file mode 100644 index 0000000..2bb67d6 --- /dev/null +++ b/src/ubuntu/install/unityhub/install_unityhub.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# Adapted from https://docs.unity3d.com/hub/manual/InstallHub.html#install-hub-linux +SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )" +set -ex +sh -c 'echo "deb https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list' +wget -qO - https://hub.unity3d.com/linux/keys/public | apt-key add - +apt-get update +apt-get install -y unityhub + +sed -i 's,/opt/unityhub/unityhub,/opt/unityhub/unityhub --no-sandbox,g' /usr/share/applications/unityhub.desktop + + +cp /usr/share/applications/unityhub.desktop $HOME/Desktop/ +chmod +x $HOME/Desktop/unityhub.desktop +chown 1000:1000 $HOME/Desktop/unityhub.desktop + + +# Example for pre-installing a unity Editor +#mkdir -p $HOME/Unity/Hub/Editor/2021.3.6f1 +#cd /tmp/ +#wget -q https://download.unity3d.com/download_unity/7da38d85baf6/UnitySetup-2021.3.6f1 -O UnitySetup +#chmod +x ./UnitySetup +#yes | ./UnitySetup -u -l $HOME/Unity/Hub/Editor/2021.3.6f1 +#rm /tmp/UnitySetup +#chown -R 1000:1000 $HOME/Unity \ No newline at end of file