Skip to content

Commit 65a184b

Browse files
refactor
1 parent e78a019 commit 65a184b

22 files changed

Lines changed: 2957 additions & 494 deletions

File tree

‎platforms/android/app/src/main/assets/init-sandbox.sh‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
export LD_LIBRARY_PATH=$PREFIX
22

3+
# This script is sourced by the device shell (/system/bin/sh, i.e. mksh), which
4+
# has no arrays, so the argument list is built as a string and deliberately
5+
# word-split at exec. That makes an unset or whitespace-bearing path a silent
6+
# corruption ("-b " with no value, or /libproot.so), so validate them up front.
7+
: "${PREFIX:?PREFIX is not set}"
8+
: "${NATIVE_DIR:?NATIVE_DIR is not set}"
9+
10+
case "$PREFIX$NATIVE_DIR" in
11+
*[[:space:]]*)
12+
printf '\033[31m[!]\033[0m PREFIX and NATIVE_DIR must not contain whitespace\n' >&2
13+
exit 1
14+
;;
15+
esac
16+
317
mkdir -p "$PREFIX/tmp"
418
mkdir -p "$PREFIX/ubuntu/tmp"
519
mkdir -p "$PREFIX/public"
@@ -35,6 +49,7 @@ done
3549

3650

3751

52+
3853
unset system_mnt
3954

4055
ARGS="$ARGS -b /sdcard"
@@ -131,7 +146,16 @@ if [ "$FAILSAFE" = true ] && [ "$INSTALLING" != true ]; then
131146
LINKER="/system/bin/linker"
132147
fi
133148

134-
exec "$LINKER" "$PREFIX/axs" -c "sh"
149+
AXS_PORT="${AXS_PORT:-8767}"
150+
echo "$AXS_PORT" > "$PREFIX/axs.port"
151+
set -- --port "$AXS_PORT"
152+
# The app is served from https://localhost, which is AXS's default CORS
153+
# allowlist; only an explicit opt-in widens it to any origin.
154+
if [ "${AXS_ALLOW_ANY_ORIGIN:-0}" = "1" ]; then
155+
set -- "$@" --allow-any-origin
156+
fi
157+
158+
exec "$LINKER" "$PREFIX/axs" "$@" -c "sh"
135159
else
136160
exec "$PROOT" $ARGS /bin/sh "$PREFIX/init-ubuntu.sh" "$@"
137-
fi
161+
fi

0 commit comments

Comments
 (0)