Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

Dynamically determine DNS via getprop net.dns #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ if [ "$first" != 1 ];then
cd "$folder"
echo "decompressing ubuntu image"
proot --link2symlink tar -xf ${cur}/${tarball} --exclude='dev'||:
echo "fixing nameserver, otherwise it can't connect to the internet"
echo "nameserver 1.1.1.1" > etc/resolv.conf
cd "$cur"
fi
mkdir -p binds
Expand All @@ -39,6 +37,18 @@ echo "writing launch script"
cat > $bin <<- EOM
#!/bin/bash
cd \$(dirname \$0)
## setup resolv.conf
currentdns="\$(getprop net.dns1)"
i=1

rm -f $folder/etc/resolv.conf

while [ ! -z "\$currentdns" ]; do
echo "nameserver \$currentdns" >> $folder/etc/resolv.conf
i=\$((i+1))
currentdns=\$(getprop net.dns\${i})
done

## unset LD_PRELOAD in case termux-exec is installed
unset LD_PRELOAD
command="proot"
Expand Down