summaryrefslogtreecommitdiffstats
path: root/code-server-wrapper.sh
diff options
context:
space:
mode:
authorkj_sh6042026-05-19 20:20:06 -0400
committerkj_sh6042026-05-19 20:20:06 -0400
commitdf6b874be8695e87c50f65b7da2667fc726f1a6c (patch)
tree28b743926e245438a2c9fca8891bff6f4e521c0b /code-server-wrapper.sh
initial: first POSIX iterations
Diffstat (limited to 'code-server-wrapper.sh')
-rwxr-xr-xcode-server-wrapper.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/code-server-wrapper.sh b/code-server-wrapper.sh
new file mode 100755
index 0000000..612d2ab
--- /dev/null
+++ b/code-server-wrapper.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+APPIMAGE_DIR="/opt/code-server-appimage"
+
+# - find the AppImage; fail clearly if missing or ambiguous
+_match="$(find "$APPIMAGE_DIR" -maxdepth 1 -name 'code-server-*.AppImage' 2>/dev/null)"
+_count="$(printf '%s\n' "$_match" | grep -c 'AppImage' 2>/dev/null || echo 0)"
+
+if [ "$_count" -eq 0 ]; then
+ printf 'error: no code-server AppImage found in %s\n' "$APPIMAGE_DIR" >&2
+ exit 1
+fi
+
+if [ "$_count" -gt 1 ]; then
+ printf 'error: multiple AppImages found in %s - keep only one:\n' "$APPIMAGE_DIR" >&2
+ printf '%s\n' "$_match" >&2
+ exit 1
+fi
+
+APPIMAGE="$_match"
+export APPIMAGE_EXTRACT_AND_RUN=1
+exec "$APPIMAGE" "$@"