Skip to content

Commit 29b1d1a

Browse files
authored
fix: restore resolv.conf for armbian/ubuntu images (#38)
* fix: restore resolv.conf for armbian/ubuntu images Signed-off-by: Stefan Dej <[email protected]> * fix: fix url to /etc/resolv.conf in readlink --------- Signed-off-by: Stefan Dej <[email protected]>
1 parent b920560 commit 29b1d1a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/end_chroot_script

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ then
2222
rm -r /home/"${BASE_USER}"/.pydistutils.cfg
2323
fi
2424

25+
if [ -f /etc/resolv.conf.link ]; then
26+
echo "Restoring original symlink for resolv.conf"
27+
resolvconf_target=$(cat /etc/resolv.conf.link)
28+
ln -sf "${resolvconf_target}" /etc/resolv.conf
29+
rm /etc/resolv.conf.link
30+
elif [ -e /etc/resolv.conf.orig ]; then
31+
echo "Restoring original resolv.conf"
32+
[ -f /etc/resolv.conf ] && rm /etc/resolv.conf
33+
mv /etc/resolv.conf.orig /etc/resolv.conf || true
34+
fi
35+
2536
# Remove common.sh after build (https://github.com/OctoPrint/CustoPiZer/issues/13)
2637
if [ -f "/common.sh" ]; then
2738
rm -f /common.sh

src/start_chroot_script

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ source /common.sh
1414
install_cleanup_trap
1515

1616
if [[ "${EDITBASE_DISTRO}" == "armbian" || "${EDITBASE_DISTRO}" == "ubuntu" ]]; then
17-
mv /etc/resolv.conf /etc/resolv.conf.orig || true
17+
# workaround for Armbian > 24.5, because it uses a symlink for /etc/resolv.conf
18+
if [ -h /etc/resolv.conf ]; then
19+
link_target="$(readlink /etc/resolv.conf)"
20+
echo "${link_target}" > /etc/resolv.conf.link
21+
rm -f /etc/resolv.conf
22+
else
23+
mv /etc/resolv.conf /etc/resolv.conf.orig || true
24+
fi
25+
26+
# Set up resolv.conf with Google & Cloudflare public DNS servers
1827
echo "nameserver 8.8.8.8" > /etc/resolv.conf
1928
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
2029
echo "nameserver 1.1.1.1" >> /etc/resolv.conf

0 commit comments

Comments
 (0)