diff --git a/src/ubuntu/install/brave/custom_startup.sh b/src/ubuntu/install/brave/custom_startup.sh index 58946c1..7e7e423 100644 --- a/src/ubuntu/install/brave/custom_startup.sh +++ b/src/ubuntu/install/brave/custom_startup.sh @@ -1,32 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$2 -if [ -n "$1" ] ; then - URL=$1 -else - URL=$LAUNCH_URL -fi - +START_COMMAND="brave-browser" +PGREP="brave" +MAXIMUS="false" DEFAULT_ARGS="--start-maximized" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x brave > /dev/null - then - /usr/bin/filter_ready - /usr/bin/desktop_ready - set +e - brave-browser $ARGS $URL - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/chrome/custom_startup.sh b/src/ubuntu/install/chrome/custom_startup.sh index 4238c86..4a2ac33 100644 --- a/src/ubuntu/install/chrome/custom_startup.sh +++ b/src/ubuntu/install/chrome/custom_startup.sh @@ -1,30 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$2 -if [ -n "$1" ] ; then - URL=$1 -else - URL=$LAUNCH_URL -fi - +START_COMMAND="google-chrome" +PGREP="chrome" +MAXIMUS="false" DEFAULT_ARGS="--start-maximized" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x chrome > /dev/null - then - /usr/bin/filter_ready - /usr/bin/desktop_ready - google-chrome $ARGS $URL +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/chromium/custom_startup.sh b/src/ubuntu/install/chromium/custom_startup.sh index dbc5051..d574dea 100644 --- a/src/ubuntu/install/chromium/custom_startup.sh +++ b/src/ubuntu/install/chromium/custom_startup.sh @@ -1,30 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$2 -if [ -n "$1" ] ; then - URL=$1 -else - URL=$LAUNCH_URL -fi - +START_COMMAND="chromium-browser" +PGREP="chromium" +MAXIMUS="false" DEFAULT_ARGS="--start-maximized" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x chromium > /dev/null - then - /usr/bin/filter_ready - /usr/bin/desktop_ready - chromium-browser $ARGS $URL - fi - sleep 1 - done - rm /tmp/custom_startup.lck +} + +kasm_startup() { + if [ -n "$KASM_URL" ] ; then + URL=$KASM_URL + elif [ -z "$URL" ] ; then + URL=$LAUNCH_URL + fi + + if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & + fi + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup fi diff --git a/src/ubuntu/install/discord/custom_startup.sh b/src/ubuntu/install/discord/custom_startup.sh index 1bf1e5b..e797409 100644 --- a/src/ubuntu/install/discord/custom_startup.sh +++ b/src/ubuntu/install/discord/custom_startup.sh @@ -1,30 +1,82 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="/usr/share/discord/Discord" +PGREP="Discord" +MAXIMUS="false" 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 -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +# 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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x Discord > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - /usr/share/discord/Discord $ARGS & - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + maximus & + fi + sleep 1 + done + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/doom/custom_startup.sh b/src/ubuntu/install/doom/custom_startup.sh index 5442e43..22d627d 100644 --- a/src/ubuntu/install/doom/custom_startup.sh +++ b/src/ubuntu/install/doom/custom_startup.sh @@ -1,5 +1,82 @@ #!/usr/bin/env bash -sleep 3 -xfce4-terminal -e "/usr/games/chocolate-doom ${APP_ARGS}" +set -ex +START_COMMAND="/usr/games/chocolate-doom" +PGREP="chocolate-doom" +DEFAULT_ARGS="" +MAXIMUS="false" +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & + fi + + while true + do + if ! pgrep -x $PGREP > /dev/null + then + /usr/bin/filter_ready + /usr/bin/desktop_ready + set +e + source $STARTUPDIR/generate_container_user + $START_COMMAND $ARGS $URL & + set -e + fi + sleep 1 + done + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/edge/custom_startup.sh b/src/ubuntu/install/edge/custom_startup.sh index 470b3cf..c5eabdb 100644 --- a/src/ubuntu/install/edge/custom_startup.sh +++ b/src/ubuntu/install/edge/custom_startup.sh @@ -1,33 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$2 -if [ -n "$1" ] ; then - URL=$1 -else - URL=$LAUNCH_URL -fi - +START_COMMAND="microsoft-edge" +PGREP="msedge" +MAXIMUS="false" DEFAULT_ARGS="--start-maximized" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 + set +e + $START_COMMAND $ARGS $OPT_URL + set -e + else + echo "No URL specified for exec command. Doing nothing." fi - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x msedge > /dev/null - then - /usr/bin/filter_ready - /usr/bin/desktop_ready - set +e - microsoft-edge $ARGS $URL - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + while true + do + if ! pgrep -x $PGREP > /dev/null + then + /usr/bin/filter_ready + /usr/bin/desktop_ready + $START_COMMAND $ARGS $URL + fi + sleep 1 + done + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/firefox/custom_startup.sh b/src/ubuntu/install/firefox/custom_startup.sh index 50c8dad..6ebeb2d 100644 --- a/src/ubuntu/install/firefox/custom_startup.sh +++ b/src/ubuntu/install/firefox/custom_startup.sh @@ -1,30 +1,76 @@ #!/usr/bin/env bash set -ex -FORCE=$2 -if [ -n "$1" ] ; then - URL=$1 -else - URL=$LAUNCH_URL -fi - +START_COMMAND="firefox" +PGREP="firefox" DEFAULT_ARGS="-width ${VNC_RESOLUTION/x*/} -height ${VNC_RESOLUTION/*x/}" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x firefox > /dev/null - then - /usr/bin/filter_ready - /usr/bin/desktop_ready - firefox $ARGS $URL - fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file +} + +kasm_startup() { + if [ -n "$KASM_URL" ] ; then + URL=$KASM_URL + elif [ -z "$URL" ] ; then + URL=$LAUNCH_URL + fi + + if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then + 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 + + fi + +} + + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/firefox_mobile/custom_startup.sh b/src/ubuntu/install/firefox_mobile/custom_startup.sh index 6a7c4e9..e99e68f 100644 --- a/src/ubuntu/install/firefox_mobile/custom_startup.sh +++ b/src/ubuntu/install/firefox_mobile/custom_startup.sh @@ -16,7 +16,6 @@ if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; t echo "custom_startup already running!" exit 1 fi - touch /tmp/custom_startup.lck while true do if ! pgrep -x firefox > /dev/null @@ -26,5 +25,4 @@ if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; t fi sleep 1 done - rm /tmp/custom_startup.lck fi \ No newline at end of file diff --git a/src/ubuntu/install/gimp/custom_startup.sh b/src/ubuntu/install/gimp/custom_startup.sh index 3db1730..7bf8c8c 100644 --- a/src/ubuntu/install/gimp/custom_startup.sh +++ b/src/ubuntu/install/gimp/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="gimp" +PGREP="gimp" +MAXIMUS="true" DEFAULT_ARGS="" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x gimp > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - gimp $ARGS & - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/horizon/custom_startup.sh b/src/ubuntu/install/horizon/custom_startup.sh index d55b47d..5b013dd 100644 --- a/src/ubuntu/install/horizon/custom_startup.sh +++ b/src/ubuntu/install/horizon/custom_startup.sh @@ -1,28 +1,83 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="vmware-view" +PGREP="vmware-view" +MAXIMUS="false" DEFAULT_ARGS="--fullscreen" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 + cd $HOME + $START_COMMAND $ARGS $OPT_URL + else + echo "No URL specified for exec command. Doing nothing." fi - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x vmware-view > /dev/null - then - cd $HOME - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - vmware-view $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + while true + do + if ! pgrep -x $PGREP > /dev/null + then + /usr/bin/filter_ready + /usr/bin/desktop_ready + cd $HOME + set +e + $START_COMMAND $ARGS $URL + set -e + fi + sleep 1 + done + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/insomnia/custom_startup.sh b/src/ubuntu/install/insomnia/custom_startup.sh index 6a64887..3937275 100644 --- a/src/ubuntu/install/insomnia/custom_startup.sh +++ b/src/ubuntu/install/insomnia/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="insomnia" +PGREP="insomnia" +MAXIMUS="true" DEFAULT_ARGS="--no-sandbox" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x insomnia > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - insomnia $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/maltego/custom_startup.sh b/src/ubuntu/install/maltego/custom_startup.sh index e1ffaa9..37fc9a8 100644 --- a/src/ubuntu/install/maltego/custom_startup.sh +++ b/src/ubuntu/install/maltego/custom_startup.sh @@ -1,27 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="/usr/bin/maltego" +PGREP="maltego" +MAXIMUS="false" DEFAULT_ARGS="" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x maltego > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - /usr/bin/maltego $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/only_office/custom_startup.sh b/src/ubuntu/install/only_office/custom_startup.sh index 8ed85ab..b5d5971 100644 --- a/src/ubuntu/install/only_office/custom_startup.sh +++ b/src/ubuntu/install/only_office/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="onlyoffice-desktopeditors" +PGREP="DesktopEditors" +MAXIMUS="true" DEFAULT_ARGS="--system-title-bar" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x DesktopEditors >> /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - onlyoffice-desktopeditors $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/postman/custom_startup.sh b/src/ubuntu/install/postman/custom_startup.sh index 3a9045d..fd870b3 100644 --- a/src/ubuntu/install/postman/custom_startup.sh +++ b/src/ubuntu/install/postman/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="/opt/Postman/Postman" +PGREP="Postman" +MAXIMUS="true" DEFAULT_ARGS="" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x Postman > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - /opt/Postman/Postman $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/rdesktop/custom_startup.sh b/src/ubuntu/install/rdesktop/custom_startup.sh index addae6d..6649c24 100644 --- a/src/ubuntu/install/rdesktop/custom_startup.sh +++ b/src/ubuntu/install/rdesktop/custom_startup.sh @@ -1,28 +1,82 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="rdesktop" +PGREP="rdesktop" +MAXIMUS="false" DEFAULT_ARGS="-f localhost " ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x rdesktop > /dev/null - then - cd $HOME - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - rdesktop $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + while true + do + if ! pgrep -x $PGREP > /dev/null + then + cd $HOME + /usr/bin/filter_ready + /usr/bin/desktop_ready + set +e + $START_COMMAND $ARGS $URL + set -e + fi + sleep 1 + done + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/remmina/custom_startup.sh b/src/ubuntu/install/remmina/custom_startup.sh index 8800cfa..80394eb 100644 --- a/src/ubuntu/install/remmina/custom_startup.sh +++ b/src/ubuntu/install/remmina/custom_startup.sh @@ -1,28 +1,81 @@ #!/usr/bin/env bash -set -x -FORCE=$1 - -DEFAULT_ARGS=" " +set -ex +START_COMMAND="remmina" +PGREP="remmina" +DEFAULT_ARGS="" +MAXIMUS="false" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x remmina > /dev/null - then - cd $HOME - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - remmina $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/signal/custom_startup.sh b/src/ubuntu/install/signal/custom_startup.sh index a312abd..313fb2c 100644 --- a/src/ubuntu/install/signal/custom_startup.sh +++ b/src/ubuntu/install/signal/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="signal-desktop" +PGREP="signal-desktop" DEFAULT_ARGS="--no-sandbox" +MAXIMUS="true" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x signal-desktop > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - signal-desktop $ARGS - set -e - fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & + fi + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/slack/custom_startup.sh b/src/ubuntu/install/slack/custom_startup.sh index 40286d2..61ffb60 100644 --- a/src/ubuntu/install/slack/custom_startup.sh +++ b/src/ubuntu/install/slack/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="slack" +PGREP="slack" +MAXIMUS="true" DEFAULT_ARGS="--no-sandbox" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x slack > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - slack $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/steam/custom_startup.sh b/src/ubuntu/install/steam/custom_startup.sh index 3aa100c..fe69f95 100644 --- a/src/ubuntu/install/steam/custom_startup.sh +++ b/src/ubuntu/install/steam/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="/usr/games/steam" +PGREP="steam" +MAXIMUS="true" DEFAULT_ARGS="" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x steam > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - /usr/games/steam $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/sublime_text/custom_startup.sh b/src/ubuntu/install/sublime_text/custom_startup.sh index d7772a6..dede27b 100644 --- a/src/ubuntu/install/sublime_text/custom_startup.sh +++ b/src/ubuntu/install/sublime_text/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="/opt/sublime_text/sublime_text" +PGREP="sublime_text" +MAXIMUS="true" DEFAULT_ARGS="" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x sublime_text > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - /opt/sublime_text/sublime_text $ARGS & - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/teams/custom_startup.sh b/src/ubuntu/install/teams/custom_startup.sh index ef4e437..e416f8c 100644 --- a/src/ubuntu/install/teams/custom_startup.sh +++ b/src/ubuntu/install/teams/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="teams" +PGREP="teams" +MAXIMUS="true" DEFAULT_ARGS="--no-sandbox" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x teams > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - teams $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/telegram/custom_startup.sh b/src/ubuntu/install/telegram/custom_startup.sh index 8c1209a..7578de2 100644 --- a/src/ubuntu/install/telegram/custom_startup.sh +++ b/src/ubuntu/install/telegram/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - -DEFAULT_ARGS="" +START_COMMAND="/opt/Telegram/Telegram" +PGREP="Telegram" +MAXIMUS="false" +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 -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +# 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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x Telegram > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - /opt/Telegram/Telegram $ARGS & - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/terminal/custom_startup.sh b/src/ubuntu/install/terminal/custom_startup.sh index 78a9201..2358205 100644 --- a/src/ubuntu/install/terminal/custom_startup.sh +++ b/src/ubuntu/install/terminal/custom_startup.sh @@ -1,32 +1,82 @@ #!/usr/bin/env bash set -ex -FORCE=$2 -if [ -n "$1" ] ; then - URL=$1 -else - URL=$LAUNCH_URL -fi - +START_COMMAND="xfce4-terminal" +PGREP="xfce4-terminal " +MAXIMUS="false" DEFAULT_ARGS="--fullscreen --hide-borders --hide-menubar --zoom=-1 --hide-scrollbar" -ARGS=${TERMINAL_ARGS:-$DEFAULT_ARGS} +ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x xfce4-terminal > /dev/null - then - cd $HOME - /usr/bin/desktop_ready - set +e - xfce4-terminal $ARGS - set -e + + # 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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + while true + do + if ! pgrep -x $PGREP > /dev/null + then + /usr/bin/filter_ready + /usr/bin/desktop_ready + set +e + cd $HOME + $START_COMMAND $ARGS $URL + set -e + fi + sleep 1 + done + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/torbrowser/custom_startup.sh b/src/ubuntu/install/torbrowser/custom_startup.sh index 72461b9..28aced4 100644 --- a/src/ubuntu/install/torbrowser/custom_startup.sh +++ b/src/ubuntu/install/torbrowser/custom_startup.sh @@ -1,29 +1,84 @@ #!/usr/bin/env bash set -ex -FORCE=$2 -if [ -n "$1" ] ; then - URL=$1 -else - URL=$LAUNCH_URL -fi +START_COMMAND="$HOME/tor-browser/tor-browser_en-US/Browser/start-tor-browser" +PGREP="firefox.real" +MAXIMUS="false" +DEFAULT_ARGS="--detach --allow-remote --new-tab" +ARGS=${APP_ARGS:-$DEFAULT_ARGS} -if [ -n "$URL" ] && ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 + set +e + $START_COMMAND $ARGS $OPT_URL + set -e + else + echo "No URL specified for exec command. Doing nothing." fi - touch /tmp/custom_startup.lck - while true - do - if ! pgrep firefox > /dev/null - then - /usr/bin/filter_ready - /usr/bin/desktop_ready - set +e - $HOME/tor-browser/tor-browser_en-US/Browser/start-tor-browser --detach --allow-remote --new-tab $URL - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/vlc/custom_startup.sh b/src/ubuntu/install/vlc/custom_startup.sh index ebb5832..30413d7 100644 --- a/src/ubuntu/install/vlc/custom_startup.sh +++ b/src/ubuntu/install/vlc/custom_startup.sh @@ -1,28 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="vlc" +PGREP="vlc" +MAXIMUS="true" DEFAULT_ARGS="--no-metadata-network-access --no-qt-privacy-ask" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x vlc >> /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - vlc $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/vs_code/custom_startup.sh b/src/ubuntu/install/vs_code/custom_startup.sh index 9c6f284..54204f2 100644 --- a/src/ubuntu/install/vs_code/custom_startup.sh +++ b/src/ubuntu/install/vs_code/custom_startup.sh @@ -1,29 +1,81 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="code" +PGREP="code" +MAXIMUS="true" DEFAULT_ARGS="--no-sandbox" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x code > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - code $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup fi diff --git a/src/ubuntu/install/zoom/custom_startup.sh b/src/ubuntu/install/zoom/custom_startup.sh index c25bffb..2795a7e 100644 --- a/src/ubuntu/install/zoom/custom_startup.sh +++ b/src/ubuntu/install/zoom/custom_startup.sh @@ -1,28 +1,83 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="zoom" +PGREP="zoom" +MAXIMUS="true" DEFAULT_ARGS="" ARGS=${APP_ARGS:-$DEFAULT_ARGS} -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x zoom >> /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - zoom $ARGS - set -e +} + +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 + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file + + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi diff --git a/src/ubuntu/install/zsnes/custom_startup.sh b/src/ubuntu/install/zsnes/custom_startup.sh index 45d788d..c844ad5 100644 --- a/src/ubuntu/install/zsnes/custom_startup.sh +++ b/src/ubuntu/install/zsnes/custom_startup.sh @@ -1,29 +1,80 @@ #!/usr/bin/env bash set -ex -FORCE=$1 - +START_COMMAND="zsnes" +PGREP="zsnes" +MAXIMUS="true" DEFAULT_ARGS="" ARGS=${APP_ARGS:-$DEFAULT_ARGS} +options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit +eval set -- "$options" -maximus & -if ( [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ) ; then - if [ -f /tmp/custom_startup.lck ] ; then - echo "custom_startup already running!" - exit 1 +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 - touch /tmp/custom_startup.lck - while true - do - if ! pgrep -x zsnes > /dev/null - then - /usr/bin/desktop_ready - /usr/bin/filter_ready - set +e - zsnes $ARGS - set -e - fi - sleep 1 - done - rm /tmp/custom_startup.lck -fi \ No newline at end of file +} + +kasm_startup() { + if [ -n "$KASM_URL" ] ; then + URL=$KASM_URL + elif [ -z "$URL" ] ; then + URL=$LAUNCH_URL + fi + + if [[ $MAXIMUS == 'true' ]] ; then + maximus & + fi + + if [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ; then + 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 + + fi + +} + +if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then + kasm_exec +else + kasm_startup +fi