From 64bc3a725b477a395f584ed4a4462374c9396f1d Mon Sep 17 00:00:00 2001 From: Phil Date: Sun, 28 Nov 2021 21:52:00 +0000 Subject: [PATCH 1/2] detect apt-cacher on parent also a couple of possible tweaks to passify shellcheck some more --- retro-home-image | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/retro-home-image b/retro-home-image index 9912c07..8066467 100755 --- a/retro-home-image +++ b/retro-home-image @@ -59,8 +59,17 @@ function nspawn() { # Create basic resolv.conf for bind mounting inside the container echo "nameserver 1.1.1.1" > "${R_STAGE_0}/resolv.conf" - if pidof apt-cacher-ng && [ -d "${R}/etc/apt/apt.conf.d" ]; then + # apt-cacher-ng is running here or this is a VM guest and the host + # is running it + if pidof apt-cacher-ng && [ -d "${R}/etc/apt/apt.conf.d" ]; then echo "Acquire::http { Proxy \"http://${APT_CACHE_IP}:3142\"; }" > "${R}/etc/apt/apt.conf.d/90cache" + else + #or this is a VM guest and the host is running it + if nc -z 10.0.2.2 3143 && [ -d "${R}/etc/apt/apt.conf.d" ]; then + echo "Acquire::http { Proxy \"http://10.0.2.2:3142\"; }" > "${R}/etc/apt/apt.conf.d/90cache" + fi + # TODO ? handle a parameter for external/other apt proxy address if there is one + # in the environment other than the VM or the host it is running on fi # Make sure the container has a machine-id @@ -84,8 +93,8 @@ function stage_01_bootstrap() { export B="${B_STAGE_1}" export R="${R_STAGE_1}" - rm -rf "${B_STAGE_1}"/* - rm -rf "${R_STAGE_1}"/* + rm -rf "${B_STAGE_1:?}"/* + rm -rf "${R_STAGE_1:?}"/* # Required tools on the host apt-get -y install binfmt-support debootstrap git \ @@ -893,9 +902,10 @@ function stage_06_clean() { echo '' > "${R}"/etc/machine-id # Only required if Connman has been made the default network renderer - cd "${R}/etc" - ln -sf ../run/connman/resolv.conf resolv.conf - cd - + #cd "${R}/etc" + #ln -sf ../run/connman/resolv.conf resolv.conf + #cd - + ( cd "${R}/etc" && ln -sf ../run/connman/resolv.conf resolv.conf) } function stage_07_image() { From 795d057572110dcaeb1be0ab0b979f242cdd9f4a Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Thu, 23 Dec 2021 23:20:40 +0000 Subject: [PATCH 2/2] Typo in port fixed glad you didn't merge this one too soon! --- retro-home-image | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retro-home-image b/retro-home-image index c6a7dc0..2e50d68 100755 --- a/retro-home-image +++ b/retro-home-image @@ -72,7 +72,7 @@ function nspawn() { echo "Acquire::http { Proxy \"http://${APT_CACHE_IP}:3142\"; }" > "${R}/etc/apt/apt.conf.d/90cache" else #or this is a VM guest and the host is running it - if nc -z 10.0.2.2 3143 && [ -d "${R}/etc/apt/apt.conf.d" ]; then + if nc -z 10.0.2.2 3142 && [ -d "${R}/etc/apt/apt.conf.d" ]; then echo "Acquire::http { Proxy \"http://10.0.2.2:3142\"; }" > "${R}/etc/apt/apt.conf.d/90cache" fi # TODO ? handle a parameter for external/other apt proxy address if there is one