Custom file and /etc/issue* generation.

This commit is contained in:
Jeffrey Townsend
2016-06-02 01:22:05 +00:00
parent f0f6fd88bb
commit 2afb37ce01

View File

@@ -411,6 +411,33 @@ rm -f /usr/sbin/policy-rc.d
json.dump(md, f, indent=2)
onlu.execute("sudo chmod a-w %s" % mname)
for (fname, v) in Configure.get('files', {}).iteritems():
if fname.startswith('/'):
fname = fname[1:]
dst = os.path.join(dir_, fname)
onlu.execute("sudo mkdir -p %s" % os.path.dirname(dst))
onlu.execute("sudo touch %s" % dst)
onlu.execute("sudo chmod a+w %s" % dst)
if os.path.exists(v):
shutil.copy(v, dst)
else:
with open(dst, "w") as f:
f.write("%s\n" % v)
if Configure.get('issue'):
issue = Configure.get('issue')
fn = os.path.join(dir_, "etc/issue")
onlu.execute("sudo chmod a+w %s" % fn)
with open(fn, "w") as f:
f.write("%s\n" % issue)
onlu.execute("sudo chmod a-w %s" % fn)
fn = os.path.join(dir_, "etc/issue.net")
onlu.execute("sudo chmod a+w %s" % fn)
with open(fn, "w") as f:
f.write("%s" % issue)
onlu.execute("sudo chmod a-w %s" % fn)
finally:
onlu.execute("sudo umount -l %s %s" % (os.path.join(dir_, "dev"), os.path.join(dir_, "proc")))