From 4fab030986deb9371a1d882cc740d402dbd8ea10 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Thu, 23 Feb 2023 12:15:03 +0200 Subject: [PATCH] docker: add alternate entrypoint script This one spawns a root shell. --- Dockerfile | 1 + entrypoint_root.sh | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 entrypoint_root.sh diff --git a/Dockerfile b/Dockerfile index 88512ba..a7053e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ COPY /system/$SYSTEM_TYPE /system # Copy entrypoint script. COPY /entrypoint.sh /entrypoint.sh +COPY /entrypoint_root.sh /entrypoint_root.sh # Extract bootstrap archive and create symlinks. ADD https://github.com/termux/termux-packages/releases/download/bootstrap-$BOOTSTRAP_VERSION/bootstrap-$BOOTSTRAP_ARCH.zip /bootstrap.zip diff --git a/entrypoint_root.sh b/entrypoint_root.sh new file mode 100755 index 0000000..1b20f5b --- /dev/null +++ b/entrypoint_root.sh @@ -0,0 +1,20 @@ +#!/system/bin/sh + +if [ "$(id -u)" != "0" ]; then + echo "Failure: /entrypoint_root.sh must be started as root." >&2 + exit 1 +fi + +if [ -z "$(/system/bin/busybox pidof dnsmasq)" ]; then + /system/bin/mksh -T /dev/ptmx -c "/system/bin/dnsmasq -u root -g root --pid-file /dnsmasq.pid" >/dev/null 2>&1 + sleep 1 + if [ -z "$(/system/bin/busybox pidof dnsmasq)" ]; then + echo "[!] Failed to start dnsmasq, host name resolution may fail." >&2 + fi +fi + +if [ $# -ge 1 ]; then + exec "$@" +else + exec /data/data/com.termux/files/usr/bin/login +fi