From 5e5f33f6723da0ae4af4f24f0584bffade8a5165 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Wed, 22 Feb 2023 21:49:13 +0200 Subject: [PATCH] bin: delete update-static-dns script --- Dockerfile | 35 +++++-------------- README.md | 6 ---- static-dns-hosts.txt | 60 -------------------------------- system/arm/bin/update-static-dns | 35 ------------------- system/x86/bin/update-static-dns | 35 ------------------- 5 files changed, 9 insertions(+), 162 deletions(-) delete mode 100644 static-dns-hosts.txt delete mode 100755 system/arm/bin/update-static-dns delete mode 100755 system/x86/bin/update-static-dns diff --git a/Dockerfile b/Dockerfile index 57166bb..29dfe52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,10 +13,6 @@ ENV PATH /system/bin # Copy libc, linker and few utilities. COPY /system/$SYSTEM_TYPE /system -# Static DNS hosts: as our system does not have a DNS resolver, we will -# have to resolve domains manually and fill /system/etc/hosts. -COPY /static-dns-hosts.txt /system/etc/static-dns-hosts.txt - # Extract bootstrap archive and create symlinks. 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 && \ @@ -48,7 +44,6 @@ RUN for tool in df mount ping ping6 top umount; do \ # * Rest is owned by root and has 755/644 modes. RUN busybox chown -Rh 0:0 /system && \ busybox chown -Rh 1000:1000 /data/data/com.termux && \ - busybox chown 1000:1000 /system/etc/hosts /system/etc/static-dns-hosts.txt && \ busybox find /system -type d -exec busybox chmod 755 "{}" \; && \ busybox find /system -type f -executable -exec busybox chmod 755 "{}" \; && \ busybox find /system -type f ! -executable -exec busybox chmod 644 "{}" \; && \ @@ -58,29 +53,17 @@ RUN busybox chown -Rh 0:0 /system && \ busybox find ./bin ./lib/apt ./libexec -type f -exec busybox chmod 700 "{}" \; # Switch user to non-root. -USER 1000:1000 - -# Update static DNS cache on login. Also symlink script and host list to prefix. -RUN echo "echo -e 'Updating static DNS:\n' && /system/bin/update-static-dns && echo" \ - > /data/data/com.termux/files/home/.bashrc && \ - busybox ln -s /system/bin/update-static-dns /data/data/com.termux/files/usr/bin/update-static-dns && \ - busybox ln -s /system/etc/static-dns-hosts.txt /data/data/com.termux/files/usr/etc/static-dns-hosts.txt - -# Create empty user static DNS cache (external bind) -RUN busybox mkdir -p /data/data/com.termux/files/home/.termux/termux-docker/ && \ - busybox touch /data/data/com.termux/files/home/.termux/termux-docker/static-dns-hosts.txt && \ - busybox chown 1000:1000 /data/data/com.termux/files/home/.termux/termux-docker/static-dns-hosts.txt +#USER 1000:1000 # Update static DNS cache, install updates and cleanup when not building for arm. -ENV PATH /data/data/com.termux/files/usr/bin -RUN if [ ${BOOTSTRAP_ARCH} == 'arm' ]; then exit; else \ - update-static-dns && \ - apt update && \ - apt upgrade -o Dpkg::Options::=--force-confnew -yq && \ - rm -rf /data/data/com.termux/files/usr/var/lib/apt/* && \ - rm -rf /data/data/com.termux/files/usr/var/log/apt/* && \ - rm -rf /data/data/com.termux/cache/apt/* ;\ - fi +#ENV PATH /data/data/com.termux/files/usr/bin +#RUN if [ ${BOOTSTRAP_ARCH} == 'arm' ]; then exit; else \ +# apt update && \ +# apt upgrade -o Dpkg::Options::=--force-confnew -yq && \ +# rm -rf /data/data/com.termux/files/usr/var/lib/apt/* && \ +# rm -rf /data/data/com.termux/files/usr/var/log/apt/* && \ +# rm -rf /data/data/com.termux/cache/apt/* ;\ +# fi ############################################################################## # Create final image. diff --git a/README.md b/README.md index 9079952..50576db 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,6 @@ There a number of known issues which may not be resolved: * ARM containers may require a custom seccomp profile to remove restrictions from `personality()` system call. -* DNS: Docker image has to use a static DNS resolver through `/system/etc/hosts`. - You can regenerate this file by editing `/system/etc/static-dns-hosts.txt` or - `/data/data/com.termux/files/home/.termux/termux-docker/static-dns-hosts.txt` (aka - `~/.termux/termux-docker/static-dns-hosts.txt`) (this is preferable for docker binds) - and executing script `/system/bin/update-static-dns`. - * When running certain multi threaded program in 32bit containers, the PIDs can balloon and easily exceed libc's limit. The only way to fix this is to set `/proc/sys/kernel/pid_max` to 65536. See [termux-docker#40](https://github.com/termux/termux-docker/issues/40). diff --git a/static-dns-hosts.txt b/static-dns-hosts.txt deleted file mode 100644 index b5c4df5..0000000 --- a/static-dns-hosts.txt +++ /dev/null @@ -1,60 +0,0 @@ -## -## Termux Docker environment doesn't have working DNS resolver. -## This list contains domains that will be manually resolved. Result -## will be used to fill /system/etc/hosts. -## - -# Termux repositories: -termux.net -termux.org -packages.termux.org -packages-cf.termux.org -packages.termux.dev -packages-cf.termux.dev - -# Termux mirrors: -deb.kcubeterm.me -dl.kcubeterm.com -grimler.se -termux.mentality.rip -mirrors.bfsu.edu.cn -mirrors.tuna.tsinghua.edu.cn -mirrors.ustc.edu.cn -packages.kcubeterm.me -packages.kcubeterm.com -termux.astra.in.ua -mirror.bardia.tech - -# Community repositories: -its-pointless.github.io -termux-pod.github.io - -# Github: -github.com -objects.githubusercontent.com -codeload.github.com -gist.github.com -gist.githubusercontent.com -github-releases.githubusercontent.com -raw.githubusercontent.com - -# Perl: -www.cpan.org - -# Python package manager (pip): -pypi.org -test.pypi.org -upload.pypi.org -pythonhosted.org -files.pythonhosted.org -test-files.pythonhosted.org - -# Ruby package manager (gem): -rubygems.org -index.rubygems.org - -# Node package manager (npm): -registry.npmjs.org - -# Yarn package manager (yarn): -registry.yarnpkg.com diff --git a/system/arm/bin/update-static-dns b/system/arm/bin/update-static-dns deleted file mode 100755 index aa20a25..0000000 --- a/system/arm/bin/update-static-dns +++ /dev/null @@ -1,35 +0,0 @@ -#!/system/bin/sh - -export PATH=/system/bin - -echo "127.0.0.1 localhost $(busybox hostname)" > /system/etc/hosts -echo "::1 ip6-localhost" >> /system/etc/hosts - -# IPv4 -for host in $(busybox cat /system/etc/static-dns-hosts.txt /data/data/com.termux/files/home/.termux/termux-docker/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do - ip_addr=$(busybox nslookup -type=a "$host" 8.8.8.8 | busybox awk '/^Address: / { print $2 ; exit }') - - if [ -z "$ip_addr" ]; then - echo "Can't resolve '$host'." >&2 - continue - fi - - echo "$ip_addr $host" | busybox tee -a /system/etc/hosts -done - -# Check whether IPv6 is available. -busybox wget http://[2606:4700:4700::1111] -O /dev/null -o /dev/null -if [[ $? != 0 ]]; then - exit -fi -# IPv6 -for host in $(busybox cat /system/etc/static-dns-hosts.txt /data/data/com.termux/files/home/.termux/termux-docker/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do - ip_addr=$(busybox nslookup -type=aaaa "$host" 2001:4860:4860::8888 | busybox awk '/^Address: / { print $2 ; exit }') - - if [ -z "$ip_addr" ]; then - echo "Can't resolve '$host'." >&2 - continue - fi - - echo "$ip_addr $host" | busybox tee -a /system/etc/hosts -done diff --git a/system/x86/bin/update-static-dns b/system/x86/bin/update-static-dns deleted file mode 100755 index aa20a25..0000000 --- a/system/x86/bin/update-static-dns +++ /dev/null @@ -1,35 +0,0 @@ -#!/system/bin/sh - -export PATH=/system/bin - -echo "127.0.0.1 localhost $(busybox hostname)" > /system/etc/hosts -echo "::1 ip6-localhost" >> /system/etc/hosts - -# IPv4 -for host in $(busybox cat /system/etc/static-dns-hosts.txt /data/data/com.termux/files/home/.termux/termux-docker/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do - ip_addr=$(busybox nslookup -type=a "$host" 8.8.8.8 | busybox awk '/^Address: / { print $2 ; exit }') - - if [ -z "$ip_addr" ]; then - echo "Can't resolve '$host'." >&2 - continue - fi - - echo "$ip_addr $host" | busybox tee -a /system/etc/hosts -done - -# Check whether IPv6 is available. -busybox wget http://[2606:4700:4700::1111] -O /dev/null -o /dev/null -if [[ $? != 0 ]]; then - exit -fi -# IPv6 -for host in $(busybox cat /system/etc/static-dns-hosts.txt /data/data/com.termux/files/home/.termux/termux-docker/static-dns-hosts.txt | busybox grep -vE '^\s*#'); do - ip_addr=$(busybox nslookup -type=aaaa "$host" 2001:4860:4860::8888 | busybox awk '/^Address: / { print $2 ; exit }') - - if [ -z "$ip_addr" ]; then - echo "Can't resolve '$host'." >&2 - continue - fi - - echo "$ip_addr $host" | busybox tee -a /system/etc/hosts -done