From 7ad6745d407e2e79c2ae0128a2103ad8538961f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C2=B3osz=20Stocki?= Date: Wed, 15 Nov 2023 14:02:09 +0100 Subject: [PATCH] initial --- Dockerfile | 35 +++++++++++++++++++ custom_startup.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++++ install_upscayl.sh | 15 +++++++++ 3 files changed, 134 insertions(+) create mode 100644 Dockerfile create mode 100644 custom_startup.sh create mode 100644 install_upscayl.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..55af8ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM kasmweb/core-ubuntu-jammy:develop +USER root + +ENV HOME /home/kasm-default-profile +ENV STARTUPDIR /dockerstartup +ENV INST_SCRIPTS $STARTUPDIR/install +ENV NVIDIA_DRIVER_CAPABILITIES=graphics,compat32,utility,compute + +WORKDIR $HOME + +######### Customize Container Here ########### + +COPY install_upscayl.sh $INST_SCRIPTS/upscayl/ +RUN bash $INST_SCRIPTS/upscayl/install_upscayl.sh && rm -rf $INST_SCRIPTS/upscayl/ + +COPY custom_startup.sh $STARTUPDIR/custom_startup.sh +RUN chmod +x $STARTUPDIR/custom_startup.sh +RUN chmod 755 $STARTUPDIR/custom_startup.sh + +# Update the desktop environment to be optimized for a single application +RUN cp $HOME/.config/xfce4/xfconf/single-application-xfce-perchannel-xml/* $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/ +RUN cp /usr/share/extra/backgrounds/bg_kasm.png /usr/share/extra/backgrounds/bg_default.png +RUN apt-get remove -y xfce4-panel + + +######### 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 \ No newline at end of file diff --git a/custom_startup.sh b/custom_startup.sh new file mode 100644 index 0000000..a6afb81 --- /dev/null +++ b/custom_startup.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -ex +START_COMMAND="upscayl" +PGREP="upscayl" +export MAXIMIZE="true" +export MAXIMIZE_NAME="Upscayl" +MAXIMIZE_SCRIPT=$STARTUPDIR/maximize_window.sh +DEFAULT_ARGS="" +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 \ No newline at end of file diff --git a/install_upscayl.sh b/install_upscayl.sh new file mode 100644 index 0000000..5a53868 --- /dev/null +++ b/install_upscayl.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -ex + +# If you require a specific version of Upscayl - rather than the latest - it can be +# hardcoded by setting this variable and rebuilding the container. +#UPSCAYL_VERSION="3.2.1"https://github.com/upscayl/upscayl/releases/download/v2.9.1/upscayl-2.9.1-linux.deb + +if [ -z ${UPSCAYL_VERSION+x} ] +then + UPSCAYL_VERSION=$(curl -sL https://github.com/upscayl/upscayl/releases/latest/download/latest-linux.yml | grep version | grep -oP 'version: \K[0-9.]+') +fi +curl -o /tmp/upscayl.deb -L "https://github.com/upscayl/upscayl/releases/download/v${UPSCAYL_VERSION}/upscayl-${UPSCAYL_VERSION}-linux.deb" +dpkg -i /tmp/upscayl.tar.xz + +rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*