From 96ff66e11cce7301776583f524243f8b9bb5b34a Mon Sep 17 00:00:00 2001 From: Richard Koliser Date: Mon, 20 Jun 2022 16:27:25 -0400 Subject: [PATCH] KASM-2789 Pull Ubuntu Chromium from chromium-browser-snapshots Moved existing chromium install to common Removed ubuntu install from common chromium Added new Ubuntu specific script Continue to get arm the previous way (don't have an arm build in the new location) Get x64 builds by looking up the chromium_base_position and then retrieve from chromium-browser-snapshots --- dockerfile-kasm-chromium | 3 + dockerfile-kasm-oracle-8-desktop | 2 +- src/common/install/chromium/custom_startup.sh | 84 ++++ .../install/chromium/install_chromium.sh | 68 +++ src/ubuntu/install/chromium/custom_startup.sh | 10 +- .../install/chromium/install_chromium.sh | 449 +++++++++++++++--- 6 files changed, 551 insertions(+), 65 deletions(-) create mode 100644 src/common/install/chromium/custom_startup.sh create mode 100644 src/common/install/chromium/install_chromium.sh diff --git a/dockerfile-kasm-chromium b/dockerfile-kasm-chromium index 5e843de..bc0de75 100644 --- a/dockerfile-kasm-chromium +++ b/dockerfile-kasm-chromium @@ -3,6 +3,9 @@ ARG BASE_IMAGE="core-ubuntu-focal" FROM kasmweb/$BASE_IMAGE:$BASE_TAG USER root +# This argument is optional, if not present the install script will get latest Chromium +ARG CHROMIUM_VERSION + ENV HOME /home/kasm-default-profile ENV STARTUPDIR /dockerstartup ENV INST_SCRIPTS $STARTUPDIR/install diff --git a/dockerfile-kasm-oracle-8-desktop b/dockerfile-kasm-oracle-8-desktop index 5f75e93..d339075 100644 --- a/dockerfile-kasm-oracle-8-desktop +++ b/dockerfile-kasm-oracle-8-desktop @@ -24,7 +24,7 @@ COPY ./src/oracle/install/misc $INST_SCRIPTS/misc/ RUN bash $INST_SCRIPTS/misc/install_tools.sh && rm -rf $INST_SCRIPTS/misc/ # Install Chromium -COPY ./src/ubuntu/install/chromium $INST_SCRIPTS/chromium/ +COPY ./src/common/install/chromium $INST_SCRIPTS/chromium/ RUN bash $INST_SCRIPTS/chromium/install_chromium.sh && rm -rf $INST_SCRIPTS/chromium/ # Install Firefox diff --git a/src/common/install/chromium/custom_startup.sh b/src/common/install/chromium/custom_startup.sh new file mode 100644 index 0000000..46d284c --- /dev/null +++ b/src/common/install/chromium/custom_startup.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -ex +START_COMMAND="chromium-browser" +PGREP="chromium" +MAXIMIZE="true" +DEFAULT_ARGS="" + +if [[ $MAXIMIZE == 'true' ]] ; then + DEFAULT_ARGS+=" --start-maximized" +fi +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 + $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 + $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/common/install/chromium/install_chromium.sh b/src/common/install/chromium/install_chromium.sh new file mode 100644 index 0000000..ebf5f60 --- /dev/null +++ b/src/common/install/chromium/install_chromium.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +set -ex + +CHROME_ARGS="--password-store=basic --no-sandbox --ignore-gpu-blocklist --user-data-dir --no-first-run --simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT'" +ARCH=$(arch | sed 's/aarch64/arm64/g' | sed 's/x86_64/amd64/g') + +if [[ "${DISTRO}" == @(centos|oracle7|oracle8) ]]; then + if [ "${DISTRO}" == "oracle8" ]; then + dnf install -y chromium + dnf clean all + else + yum install -y chromium + yum clean all + fi +elif [ "${DISTRO}" == "opensuse" ]; then + zypper install -yn chromium + zypper clean --all +else + echo "Unrecognized DISTRO parameter: ${DISTRO}" +fi + +sed -i 's/-stable//g' /usr/share/applications/chromium-browser.desktop + +cp /usr/share/applications/chromium-browser.desktop $HOME/Desktop/ +chown 1000:1000 $HOME/Desktop/chromium-browser.desktop + +mv /usr/bin/chromium-browser /usr/bin/chromium-browser-orig +cat >/usr/bin/chromium-browser <> $HOME/.config/mimeapps.list <>/usr/bin/x-www-browser <>/etc/chromium/policies/managed/default_managed_policy.json </usr/bin/chrome <>/usr/bin/x-www-browser <>/etc/chromium/policies/managed/default_managed_policy.json <>$HOME/Desktop/chrome.desktop </usr/bin/chromium-browser </usr/bin/chromium-browser <> $HOME/.config/mimeapps.list <>/usr/bin/x-www-browser <>/etc/chromium/policies/managed/default_managed_policy.json <>/etc/chromium/policies/managed/default_managed_policy.json <