Skip to content

Commit 3084dea

Browse files
committed
wait for /dnsmasq.pid
- See #72 (comment)
1 parent 148b93d commit 3084dea

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ SHELL ["sh", "-c"]
2727
# so this odd-looking script forces the update process
2828
# to work using the -s argument of toybox-su instead, which is working.
2929
RUN sh -T /dev/ptmx -c "$TERMUX__PREFIX/bin/dnsmasq -u root -g root --pid-file=/dnsmasq.pid" && \
30-
sleep 1 && \
3130
echo '#!/system/bin/sh' > /update.sh && \
3231
echo "PATH=$TERMUX__PREFIX/bin" >> /update.sh && \
32+
echo 'while [ ! -f /dnsmasq.pid ]; do' >> /update.sh && \
33+
echo 'sleep 1' >> /update.sh && \
34+
echo 'done' >> /update.sh && \
3335
echo "source $TERMUX__PREFIX/bin/termux-setup-package-manager" >> /update.sh && \
3436
echo 'if [ "$TERMUX_APP_PACKAGE_MANAGER" = "apt" ]; then' >> /update.sh && \
3537
echo 'apt update' >> /update.sh && \
@@ -65,7 +67,7 @@ ENV TMPDIR=${TERMUX__PREFIX}/tmp
6567
ENV TZ=UTC
6668
ENV TERM=xterm
6769

68-
COPY --from=bootstrap / /
70+
COPY --from=bootstrap --exclude=dnsmasq.pid / /
6971

7072
WORKDIR ${TERMUX__HOME}
7173
SHELL ["sh", "-c"]

entrypoint.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ if [ "$(id -u)" != "0" ]; then
1010
fi
1111

1212
if [ -z "$(pidof dnsmasq)" ]; then
13+
rm -f /dnsmasq.pid
1314
/system/bin/sh -T /dev/ptmx -c "dnsmasq -u root -g root --pid-file=/dnsmasq.pid" >/dev/null 2>&1
14-
sleep 1
15-
if [ -z "$(pidof dnsmasq)" ]; then
16-
echo "[!] Failed to start dnsmasq, host name resolution may fail." >&2
17-
fi
1815
fi
1916

17+
while [ ! -f /dnsmasq.pid ]; do
18+
sleep 1
19+
done
20+
2021
exec /system/bin/su -s "$PREFIX/bin/env" system -- \
2122
-i \
2223
ANDROID_DATA="$ANDROID_DATA" \

entrypoint_root.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ if [ "$(id -u)" != "0" ]; then
1010
fi
1111

1212
if [ -z "$(pidof dnsmasq)" ]; then
13+
rm -f /dnsmasq.pid
1314
/system/bin/sh -T /dev/ptmx -c "dnsmasq -u root -g root --pid-file=/dnsmasq.pid" >/dev/null 2>&1
14-
sleep 1
15-
if [ -z "$(pidof dnsmasq)" ]; then
16-
echo "[!] Failed to start dnsmasq, host name resolution may fail." >&2
17-
fi
1815
fi
1916

17+
while [ ! -f /dnsmasq.pid ]; do
18+
sleep 1
19+
done
20+
2021
exec "$@"

0 commit comments

Comments
 (0)