From 255fa563da70de30d57aeef8e276aaaab01a1150 Mon Sep 17 00:00:00 2001
From: bamtests <17178592+bamtests@users.noreply.github.com>
Date: Sun, 3 Sep 2023 22:42:41 -0400
Subject: [PATCH] added working obsidian workspace
---
dockerfile-kasm-obsidian | 35 ++++++++
docs/obsidian/README.md | 11 +++
docs/obsidian/demo.txt | 9 ++
docs/obsidian/description.txt | 1 +
src/ubuntu/install/obsidian/custom_startup.sh | 84 +++++++++++++++++++
.../install/obsidian/install_obsidian.sh | 11 +++
6 files changed, 151 insertions(+)
create mode 100644 dockerfile-kasm-obsidian
create mode 100644 docs/obsidian/README.md
create mode 100644 docs/obsidian/demo.txt
create mode 100644 docs/obsidian/description.txt
create mode 100644 src/ubuntu/install/obsidian/custom_startup.sh
create mode 100644 src/ubuntu/install/obsidian/install_obsidian.sh
diff --git a/dockerfile-kasm-obsidian b/dockerfile-kasm-obsidian
new file mode 100644
index 000000000..1d13c8559
--- /dev/null
+++ b/dockerfile-kasm-obsidian
@@ -0,0 +1,35 @@
+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
+WORKDIR $HOME
+
+######### Customize Container Here ###########
+
+
+COPY ./src/ubuntu/install/obsidian $INST_SCRIPTS/obsidian/
+RUN bash $INST_SCRIPTS/obsidian/install_obsidian.sh && rm -rf $INST_SCRIPTS/obsidian/
+
+COPY ./src/ubuntu/install/obsidian/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
+
+ENV HOME /home/kasm-user
+WORKDIR $HOME
+RUN mkdir -p $HOME && chown -R 1000:0 $HOME
+
+USER 1000
diff --git a/docs/obsidian/README.md b/docs/obsidian/README.md
new file mode 100644
index 000000000..6a5e6c6bd
--- /dev/null
+++ b/docs/obsidian/README.md
@@ -0,0 +1,11 @@
+# About This Image
+
+This Image contains a browser-accessible version of [Obsidian.md](https://obsidian.md/).
+
+![Screenshot][Image_Screenshot]
+
+[Image_Screenshot]: https://link.storjshare.io/jvehliqkyvoxtgdzzvehrxu2dnxq/readme-photos%2Fkasmweb%2Fkasmweb-obsidian-example.png?view=1 "Image Screenshot"
+
+# Environment Variables
+
+* `APP_ARGS` - Additional arguments to pass to the application when launched.
diff --git a/docs/obsidian/demo.txt b/docs/obsidian/demo.txt
new file mode 100644
index 000000000..e02693ee2
--- /dev/null
+++ b/docs/obsidian/demo.txt
@@ -0,0 +1,9 @@
+# Live Demo
+
+
+
+**Launch a real-time demo in a new browser window:** Live Demo.
+
+
+
+∗*Note: Demo is limited to 3 minutes and has upload/downloads restricted for security purposes.*
diff --git a/docs/obsidian/description.txt b/docs/obsidian/description.txt
new file mode 100644
index 000000000..0933be5ea
--- /dev/null
+++ b/docs/obsidian/description.txt
@@ -0,0 +1 @@
+Obsidian for Kasm Workspaces
\ No newline at end of file
diff --git a/src/ubuntu/install/obsidian/custom_startup.sh b/src/ubuntu/install/obsidian/custom_startup.sh
new file mode 100644
index 000000000..441f3b883
--- /dev/null
+++ b/src/ubuntu/install/obsidian/custom_startup.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+set -ex
+START_COMMAND="obsidian"
+PGREP="obsidian"
+export MAXIMIZE="true"
+export MAXIMIZE_NAME="Obsidian"
+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/obsidian/install_obsidian.sh b/src/ubuntu/install/obsidian/install_obsidian.sh
new file mode 100644
index 000000000..564fb6d5a
--- /dev/null
+++ b/src/ubuntu/install/obsidian/install_obsidian.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+set -ex
+wget -q "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.4.5/obsidian_1.4.5_amd64.deb" -O obsidian.deb
+apt-get update
+apt-get install -y ./obsidian.deb
+rm -f obsidian.deb
+
+sed -i "s#Exec=/opt/Obsidian/obsidian#Exec=/opt/Obsidian/obsidian --no-sandbox#g" /usr/share/applications/obsidian.desktop
+cp /usr/share/applications/obsidian.desktop $HOME/Desktop
+chmod +x $HOME/Desktop/obsidian.desktop
+chown 1000:1000 $HOME/Desktop/obsidian.desktop
\ No newline at end of file