From 1086d5856985a9f36a9a13e49ab6f7334870438e Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Tue, 5 Apr 2016 13:45:24 -0700 Subject: [PATCH] Syntax fix --- server/modules/systemid.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 server/modules/systemid.py diff --git a/server/modules/systemid.py b/server/modules/systemid.py new file mode 100755 index 0000000..d496d3e --- /dev/null +++ b/server/modules/systemid.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 + +import argparse +import os + + +parser = argparse.ArgumentParser(description='iconograph systemid') +parser.add_argument( + '--chroot-path', + dest='chroot_path', + action='store', + required=True) +FLAGS = parser.parse_args() + + +def main(): + os.mkdir(os.path.join(FLAGS.chroot_path, 'systemid')) + + init = os.path.join(FLAGS.chroot_path, 'etc', 'init', 'systemid.conf') + with open(init, 'w') as fh: + fh.write(""" +description "Mount /systemid" + +start on filesystem + +script + mount LABEL=SYSTEMID /systemid + . /systemid/systemid + echo ${SYSTEMID} > /etc/hostname + hostname --file /etc/hostname + grep ${SYSTEMID} /etc/hosts >/dev/null || echo "127.0.2.1 ${SYSTEMID}" >> /etc/hosts +end script +""") + + +if __name__ == '__main__': + main()