diff --git a/unbox.sh b/unbox.sh index fb4222a..d5c9029 100755 --- a/unbox.sh +++ b/unbox.sh @@ -56,11 +56,7 @@ function unbox_outer_stage(){ fi if type -t chroot > /dev/null; then - if type -t arch-chroot > /dev/null; then - CHROOT=arch-chroot - else - CHROOT=chroot - fi + CHROOT=chroot else echo ERROR: no chroot found 1>&2 exit 1 @@ -70,7 +66,35 @@ function unbox_outer_stage(){ mount -o bind . target/root/unbox mkdir -p target/root/unbox_data mount -o bind /data target/root/unbox_data - $CHROOT target /root/unbox/unbox.sh unbox_inner_stage + ( + mount -obind /sys target/sys + mount -obind /proc target/proc + mount -obind /dev target/dev + mount -obind /dev/pts target/dev/pts + + if [[ -L target/etc/resolv.conf ]]; then + + resolv_conf=$(readlink "target/etc/resolv.conf") + if [[ $resolv_conf = /* ]]; then + resolv_conf=target$resolv_conf + else + resolv_conf=target/etc/$resolv_conf + fi + + # ensure file exists to bind mount over + if [[ ! -f $resolv_conf ]]; then + install -Dm644 /dev/null "$resolv_conf" || return 1 + fi + fi + + if [[ -e target/etc/resolv.conf ]]; then + cp -L /etc/resolv.conf $resolv_conf + fi + + $CHROOT target /root/unbox/unbox.sh unbox_inner_stage + umount /dev/pts + umount /dev /sys /proc + ) umount target/root/unbox target/root/unbox_data if type -t post_install_stage > /dev/null; then