Files
iconograph/server/modules/iconograph.py

71 lines
1.7 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/python3
import argparse
import os
import shutil
import subprocess
2016-05-19 00:46:30 +00:00
import icon_lib
2016-03-31 17:11:23 -07:00
parser = argparse.ArgumentParser(description='iconograph install module')
parser.add_argument(
'--ca-cert',
dest='ca_cert',
action='store',
required=True)
parser.add_argument(
'--chroot-path',
dest='chroot_path',
action='store',
required=True)
2016-04-06 22:52:48 -07:00
parser.add_argument(
'--https-ca-cert',
dest='https_ca_cert',
action='store')
parser.add_argument(
'--server',
dest='server',
action='store',
required=True)
FLAGS = parser.parse_args()
def main():
2016-05-19 00:46:30 +00:00
module = icon_lib.IconModule(FLAGS.chroot_path)
module.InstallPackages(
2016-07-18 05:54:04 +00:00
'upstart', 'daemontools-run', 'genisoimage', 'git', 'python3-openssl',
2016-05-09 22:46:38 +00:00
'python3-requests', 'python3-ws4py')
2016-04-06 22:38:57 -07:00
os.makedirs(os.path.join(FLAGS.chroot_path, 'icon', 'config'), exist_ok=True)
if not os.path.exists(os.path.join(FLAGS.chroot_path, 'icon', 'iconograph')):
2016-05-19 00:46:30 +00:00
module.ExecChroot(
2016-04-06 22:38:57 -07:00
'git',
'clone',
'https://github.com/robot-tools/iconograph.git',
'icon/iconograph')
shutil.copyfile(
FLAGS.ca_cert,
2016-04-06 22:38:57 -07:00
os.path.join(FLAGS.chroot_path, 'icon', 'config', 'ca.image.cert.pem'))
2016-04-06 22:52:48 -07:00
if FLAGS.https_ca_cert:
shutil.copyfile(
FLAGS.https_ca_cert,
os.path.join(FLAGS.chroot_path, 'icon', 'config', 'ca.www.cert.pem'))
client_flags = os.path.join(FLAGS.chroot_path, 'icon', 'config', 'client.flags')
with open(client_flags, 'w') as fh:
fh.write('--server=%(server)s\n' % {
'server': FLAGS.server,
})
os.symlink(
2016-04-06 22:38:57 -07:00
'/icon/iconograph/client',
os.path.join(FLAGS.chroot_path, 'etc', 'service', 'iconograph-client'))
if __name__ == '__main__':
main()