summaryrefslogtreecommitdiffstats
path: root/jupyter
blob: de603e9fcf8eaff38b3a4f8420f5a186f0ff94f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

APPIMAGE_DIR="/opt/jupyterlab-appimage"

# - find the AppImage; fail clearly if missing or ambiguous
_match="$(find "$APPIMAGE_DIR" -maxdepth 1 -name 'jupyterlab-*.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 jupyterlab 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
# - default to 'lab' when no subcommand is given; otherwise pass args as-is
if [ "$#" -eq 0 ]; then
    exec "$APPIMAGE" lab
else
    exec "$APPIMAGE" "$@"
fi