~fginther/vmbuilder/new-artful-builder

« back to all changes in this revision

Viewing changes to templates/img-vagrant.tmpl

  • Committer: Dimitri John Ledkov
  • Date: 2017-10-10 22:34:03 UTC
  • Revision ID: xnox@ubuntu.com-20171010223403-za59rzuifbvk199g
Correctly backup and restore /etc/resolv.conf

During chroot operations the host resolv.conf is needed, but the final
image should preserve the original resolv.conf symlink which maybe
either resolveconf, or stub resolved.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
        chmod 0755 "${mp}/usr/sbin/policy-rc.d" ||
53
53
                fail "Unable to make policy-rc.d executable"
54
54
 
55
 
        rm "${mp}/etc/resolv.conf" ||
56
 
        fail "Unable to remove /etc/resolv.conf"
 
55
        mv "${mp}/etc/resolv.conf" "${mp}/etc/resolv.conf.orig" ||
 
56
                fail "Unable to backup /etc/resolv.conf"
57
57
 
58
58
    cp /etc/resolv.conf "${mp}/etc/resolv.conf" &&
59
59
                debug "Placed resolv.conf in image" ||
82
82
        rm "${mp}/etc/resolv.conf" ||
83
83
                fail "Failed to remove /etc/resolv.conf"
84
84
 
85
 
        chroot "${mp}" ln -snf ../run/resolvconf/resolv.conf /etc/resolv.conf
 
85
        mv "${mp}/etc/resolv.conf.orig" "${mp}/etc/resolv.conf" ||
 
86
                fail "Unable to revert /etc/resolv.conf"
86
87
}
87
88
 
88
89
build_chroot() {