forked from DL-Mirrors/termux-docker
docker: add entrypoint script
Entrypoint script starts dnsmasq before shell is launched.
This commit is contained in:
@@ -13,6 +13,9 @@ ENV PATH /system/bin
|
|||||||
# Copy libc, linker and few utilities.
|
# Copy libc, linker and few utilities.
|
||||||
COPY /system/$SYSTEM_TYPE /system
|
COPY /system/$SYSTEM_TYPE /system
|
||||||
|
|
||||||
|
# Copy entrypoint script.
|
||||||
|
COPY /entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
# Extract bootstrap archive and create symlinks.
|
# Extract bootstrap archive and create symlinks.
|
||||||
ADD https://github.com/termux/termux-packages/releases/download/bootstrap-$BOOTSTRAP_VERSION/bootstrap-$BOOTSTRAP_ARCH.zip /bootstrap.zip
|
ADD https://github.com/termux/termux-packages/releases/download/bootstrap-$BOOTSTRAP_VERSION/bootstrap-$BOOTSTRAP_ARCH.zip /bootstrap.zip
|
||||||
RUN busybox mkdir -p /data/data/com.termux/files && \
|
RUN busybox mkdir -p /data/data/com.termux/files && \
|
||||||
@@ -84,4 +87,5 @@ WORKDIR /data/data/com.termux/files/home
|
|||||||
SHELL ["/data/data/com.termux/files/usr/bin/sh", "-c"]
|
SHELL ["/data/data/com.termux/files/usr/bin/sh", "-c"]
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
CMD ["/data/data/com.termux/files/usr/bin/login"]
|
CMD ["/data/data/com.termux/files/usr/bin/login"]
|
||||||
|
|||||||
21
entrypoint.sh
Executable file
21
entrypoint.sh
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/system/bin/sh
|
||||||
|
|
||||||
|
if [ "$(id -u)" = "0" ] && [ -z "$(/system/bin/busybox pidof dnsmasq)" ]; then
|
||||||
|
/system/bin/sh -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
|
||||||
|
else
|
||||||
|
echo "[!] Container is running as non-root, unable to start dnsmasq. DNS will be unavailable." >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -ge 1 ]; then
|
||||||
|
exec "$@"
|
||||||
|
else
|
||||||
|
if [ "$(id -u)" = "0" ]; then
|
||||||
|
exec /system/bin/su - system -c "/data/data/com.termux/files/usr/bin/login"
|
||||||
|
else
|
||||||
|
exec /data/data/com.termux/files/usr/bin/login
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user