From b42e2ceb525ef215bd2b892cd159fa3531fe8958 Mon Sep 17 00:00:00 2001 From: thelamer Date: Mon, 9 Sep 2024 12:38:44 -0400 Subject: [PATCH] update kasm init to support egress - arch --- Dockerfile | 3 +++ Dockerfile.aarch64 | 3 +++ root/kasminit | 32 ++++++++++++++++++++++++++++++++ root/usr/bin/notify-send | 3 +++ 4 files changed, 41 insertions(+) create mode 100755 root/usr/bin/notify-send diff --git a/Dockerfile b/Dockerfile index 9638143..c45a696 100644 --- a/Dockerfile +++ b/Dockerfile @@ -349,6 +349,9 @@ RUN \ chown -R 1000:1000 /kasmbins && \ chown 1000:1000 /usr/share/kasmvnc/www/Downloads && \ mkdir -p /dockerstartup && \ + mv \ + /usr/sbin/notify-send \ + /usr/sbin/notify-send-real && \ echo "**** dind support ****" && \ groupadd -r dockremap && \ useradd -r -g dockremap dockremap && \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index b802345..cb701df 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -351,6 +351,9 @@ RUN \ chown -R 1000:1000 /kasmbins && \ chown 1000:1000 /usr/share/kasmvnc/www/Downloads && \ mkdir -p /dockerstartup && \ + mv \ + /usr/sbin/notify-send \ + /usr/sbin/notify-send-real && \ echo "**** dind support ****" && \ groupadd -r dockremap && \ useradd -r -g dockremap dockremap && \ diff --git a/root/kasminit b/root/kasminit index 69afd29..82933fd 100755 --- a/root/kasminit +++ b/root/kasminit @@ -78,6 +78,38 @@ elif ! diff -q /proot-apps/pversion ${HOME}/.local/bin/pversion > /dev/null; the cp /proot-apps/* ${HOME}/.local/bin/ fi +## Network egress wait ## +while :; do + interfaces=$(ip link show type veth | awk -F: '/^[0-9]+: / {print $2}' | awk '{print $1}' | sed 's/@.*//') + if [ -z "$interfaces" ]; then + sleep 1 + continue + fi + for interface in $interfaces; do + if [[ $interface == eth* ]]; then + break 2 + fi + if [[ $interface == k-p-* ]]; then + egress_file="/dockerstartup/.egress_status" + while [ ! -f "$egress_file" ]; do + sleep 1 + done + egress_status=$(cat $egress_file) + if [ "$egress_status" == "ready" ]; then + if [ -z "$KASM_PROFILE_LDR" ]; then + http_proxy="" https_proxy="" curl -k "https://${KASM_API_HOST}:${KASM_API_PORT}/api/set_kasm_session_status?token=${KASM_API_JWT}" -H 'Content-Type: application/json' -d '{"status": "running"}' + fi + break 2 + fi + if [ "$egress_status" == "error" ]; then + echo "Failed to establish egress gateway. Exiting..." + exit 1 + fi + fi + done + sleep 1 +done + ## KasmVNC init ## # Password if [[ -f $HOME/.kasmpasswd ]]; then diff --git a/root/usr/bin/notify-send b/root/usr/bin/notify-send new file mode 100755 index 0000000..b25a776 --- /dev/null +++ b/root/usr/bin/notify-send @@ -0,0 +1,3 @@ +#! /bin/bash + +dbus-launch /usr/sbin/notify-send-real "$@"