diff --git a/Dockerfile b/Dockerfile index abbcee7..a456fa5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,9 +27,11 @@ SHELL ["sh", "-c"] # so this odd-looking script forces the update process # to work using the -s argument of toybox-su instead, which is working. RUN sh -T /dev/ptmx -c "$TERMUX__PREFIX/bin/dnsmasq -u root -g root --pid-file=/dnsmasq.pid" && \ - sleep 1 && \ echo '#!/system/bin/sh' > /update.sh && \ echo "PATH=$TERMUX__PREFIX/bin" >> /update.sh && \ + echo 'while [ ! -f /dnsmasq.pid ]; do' >> /update.sh && \ + echo 'sleep 1' >> /update.sh && \ + echo 'done' >> /update.sh && \ echo "source $TERMUX__PREFIX/bin/termux-setup-package-manager" >> /update.sh && \ echo 'if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then' >> /update.sh && \ echo 'apt update' >> /update.sh && \ diff --git a/entrypoint.sh b/entrypoint.sh index 4e56612..e4bd790 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,13 +10,14 @@ if [ "$(id -u)" != "0" ]; then fi if [ -z "$(pidof dnsmasq)" ]; then + rm -f /dnsmasq.pid /system/bin/sh -T /dev/ptmx -c "dnsmasq -u root -g root --pid-file=/dnsmasq.pid" >/dev/null 2>&1 - sleep 1 - if [ -z "$(pidof dnsmasq)" ]; then - echo "[!] Failed to start dnsmasq, host name resolution may fail." >&2 - fi fi +while [ ! -f /dnsmasq.pid ]; do + sleep 1 +done + exec /system/bin/su -s "$PREFIX/bin/env" system -- \ -i \ ANDROID_DATA="$ANDROID_DATA" \ diff --git a/entrypoint_root.sh b/entrypoint_root.sh index 97d0ee8..e9986bc 100755 --- a/entrypoint_root.sh +++ b/entrypoint_root.sh @@ -10,11 +10,12 @@ if [ "$(id -u)" != "0" ]; then fi if [ -z "$(pidof dnsmasq)" ]; then + rm -f /dnsmasq.pid /system/bin/sh -T /dev/ptmx -c "dnsmasq -u root -g root --pid-file=/dnsmasq.pid" >/dev/null 2>&1 - sleep 1 - if [ -z "$(pidof dnsmasq)" ]; then - echo "[!] Failed to start dnsmasq, host name resolution may fail." >&2 - fi fi +while [ ! -f /dnsmasq.pid ]; do + sleep 1 +done + exec "$@"