diff options
author | Neil Williams <codehelp@debian.org> | 2015-09-13 16:14:15 +0100 |
---|---|---|
committer | Neil Williams <codehelp@debian.org> | 2015-09-13 16:29:15 +0100 |
commit | ad64e0d3f602fff51455b8db86e3b566df2555e5 (patch) | |
tree | 6325ea8c14b6f787df649457d4a0b00a71a8a9a6 | |
parent | cf4dc75495793ccda7d69ef2e6ee51a62d72669a (diff) | |
download | vmdebootstrap-ad64e0d3f602fff51455b8db86e3b566df2555e5.tar.gz |
Simplify the networking checks
-rwxr-xr-x | vmdebootstrap | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/vmdebootstrap b/vmdebootstrap index 4894bae..18cce19 100755 --- a/vmdebootstrap +++ b/vmdebootstrap @@ -786,18 +786,20 @@ class VmDebootstrap(cliapp.Application): # pylint: disable=too-many-public-meth def setup_networking(self, rootdir): self.message('Setting up networking') + ifc_file = os.path.join(rootdir, 'etc', 'network', 'interfaces') + ifc_d = os.path.join(rootdir, 'etc', 'network', 'interfaces.d') - # unconditionally write for wheezy (which became oldstable on 04/25/2015) + # unconditionally write for wheezy (which became oldstable 2015.04.25) if self.was_oldstable(datetime.date(2015, 4, 26)): - with open(os.path.join(rootdir, 'etc', 'network', 'interfaces'), 'w') as netfile: + with open(ifc_file, 'w') as netfile: netfile.write('source /etc/network/interfaces.d/*\n') - os.mkdir(os.path.join(rootdir, 'etc', 'network', 'interfaces.d')) - - elif not os.path.exists(os.path.join(rootdir, 'etc', 'network', 'interfaces')): - iface_path = os.path.join(rootdir, 'etc', 'network', 'interfaces') - with open(iface_path, 'w') as netfile: + elif not os.path.exists(ifc_file): + with open(ifc_file, 'a') as netfile: netfile.write('source-directory /etc/network/interfaces.d\n') - ethpath = os.path.join(rootdir, 'etc', 'network', 'interfaces.d', 'setup') + + if not os.path.exists(ifc_d): + os.mkdir(ifc_d) + ethpath = os.path.join(ifc_d, 'setup') with open(ethpath, 'w') as eth: eth.write('auto lo\n') eth.write('iface lo inet loopback\n') |