mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
Custom file and /etc/issue* generation.
This commit is contained in:
@@ -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")))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user