From 2afb37ce01d55751d9e86992707ace779bd2c849 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 2 Jun 2016 01:22:05 +0000 Subject: [PATCH] Custom file and /etc/issue* generation. --- tools/onlrfs.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index 9875f1a4..be985bec 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -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")))