Move internal modules to icon_lib
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import icon_lib
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='iconograph adduser')
|
||||
@@ -28,18 +29,10 @@ parser.add_argument(
|
||||
FLAGS = parser.parse_args()
|
||||
|
||||
|
||||
def Exec(*args, **kwargs):
|
||||
print('+', args)
|
||||
subprocess.check_call(args, **kwargs)
|
||||
|
||||
|
||||
def ExecChroot(*args, **kwargs):
|
||||
Exec('chroot', FLAGS.chroot_path, *args, **kwargs)
|
||||
|
||||
|
||||
def main():
|
||||
ExecChroot('adduser', '--system', '--group', '--disabled-password',
|
||||
'--shell=/bin/bash', FLAGS.username)
|
||||
module = icon_lib.IconModule(FLAGS.chroot_path)
|
||||
module.ExecChroot('adduser', '--system', '--group', '--disabled-password',
|
||||
'--shell=/bin/bash', FLAGS.username)
|
||||
|
||||
if FLAGS.sudo:
|
||||
with open(os.path.join(FLAGS.chroot_path, 'etc', 'sudoers.d', FLAGS.username), 'w') as fh:
|
||||
@@ -50,7 +43,7 @@ def main():
|
||||
dest_path = os.path.join(dest_dir, 'authorized_keys')
|
||||
os.mkdir(dest_dir)
|
||||
shutil.copy(FLAGS.authorized_keys_file, dest_path)
|
||||
ExecChroot('chown', '--recursive', '%s:%s' % (FLAGS.username, FLAGS.username), '/home/%s' % FLAGS.username)
|
||||
module.ExecChroot('chown', '--recursive', '%s:%s' % (FLAGS.username, FLAGS.username), '/home/%s' % FLAGS.username)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,6 +5,8 @@ import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import icon_lib
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='iconograph autoimage')
|
||||
parser.add_argument(
|
||||
@@ -56,26 +58,14 @@ parser.add_argument(
|
||||
FLAGS = parser.parse_args()
|
||||
|
||||
|
||||
def Exec(*args, **kwargs):
|
||||
print('+', args)
|
||||
subprocess.check_call(args, **kwargs)
|
||||
|
||||
|
||||
def ExecChroot(*args, **kwargs):
|
||||
Exec('chroot', FLAGS.chroot_path, *args, **kwargs)
|
||||
|
||||
|
||||
def main():
|
||||
ExecChroot(
|
||||
'apt-get',
|
||||
'install',
|
||||
'--assume-yes',
|
||||
'git', 'grub-pc', 'python3-openssl', 'python3-requests')
|
||||
module = icon_lib.IconModule(FLAGS.chroot_path)
|
||||
module.InstallPackages('git', 'grub-pc', 'python3-openssl', 'python3-requests')
|
||||
|
||||
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')):
|
||||
ExecChroot(
|
||||
module.ExecChroot(
|
||||
'git',
|
||||
'clone',
|
||||
'https://github.com/robot-tools/iconograph.git',
|
||||
|
||||
@@ -5,6 +5,8 @@ import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import icon_lib
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='iconograph autoimage')
|
||||
parser.add_argument(
|
||||
@@ -45,33 +47,21 @@ parser.add_argument(
|
||||
FLAGS = parser.parse_args()
|
||||
|
||||
|
||||
def Exec(*args, **kwargs):
|
||||
print('+', args)
|
||||
subprocess.check_call(args, **kwargs)
|
||||
|
||||
|
||||
def ExecChroot(*args, **kwargs):
|
||||
Exec('chroot', FLAGS.chroot_path, *args, **kwargs)
|
||||
|
||||
|
||||
def main():
|
||||
ExecChroot(
|
||||
'apt-get',
|
||||
'install',
|
||||
'--assume-yes',
|
||||
'git', 'python3-requests', 'openssl')
|
||||
module = icon_lib.IconModule(FLAGS.chroot_path)
|
||||
module.InstallPackages('git', 'python3-requests', 'openssl')
|
||||
|
||||
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')):
|
||||
ExecChroot(
|
||||
module.ExecChroot(
|
||||
'git',
|
||||
'clone',
|
||||
'https://github.com/robot-tools/iconograph.git',
|
||||
'icon/iconograph')
|
||||
|
||||
if not os.path.exists(os.path.join(FLAGS.chroot_path, 'icon', 'certserver')):
|
||||
ExecChroot(
|
||||
module.ExecChroot(
|
||||
'git',
|
||||
'clone',
|
||||
'https://github.com/robot-tools/certserver.git',
|
||||
|
||||
@@ -5,6 +5,8 @@ import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import icon_lib
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='iconograph install module')
|
||||
parser.add_argument(
|
||||
@@ -29,27 +31,16 @@ parser.add_argument(
|
||||
FLAGS = parser.parse_args()
|
||||
|
||||
|
||||
def Exec(*args, **kwargs):
|
||||
print('+', args)
|
||||
subprocess.check_call(args, **kwargs)
|
||||
|
||||
|
||||
def ExecChroot(*args, **kwargs):
|
||||
Exec('chroot', FLAGS.chroot_path, *args, **kwargs)
|
||||
|
||||
|
||||
def main():
|
||||
ExecChroot(
|
||||
'apt-get',
|
||||
'install',
|
||||
'--assume-yes',
|
||||
module = icon_lib.IconModule(FLAGS.chroot_path)
|
||||
module.InstallPackages(
|
||||
'daemontools-run', 'genisoimage', 'git', 'python3-openssl',
|
||||
'python3-requests', 'python3-ws4py')
|
||||
|
||||
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')):
|
||||
ExecChroot(
|
||||
module.ExecChroot(
|
||||
'git',
|
||||
'clone',
|
||||
'https://github.com/robot-tools/iconograph.git',
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import icon_lib
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='iconograph openssh')
|
||||
@@ -15,21 +16,9 @@ parser.add_argument(
|
||||
FLAGS = parser.parse_args()
|
||||
|
||||
|
||||
def Exec(*args, **kwargs):
|
||||
print('+', args)
|
||||
subprocess.check_call(args, **kwargs)
|
||||
|
||||
|
||||
def ExecChroot(*args, **kwargs):
|
||||
Exec('chroot', FLAGS.chroot_path, *args, **kwargs)
|
||||
|
||||
|
||||
def main():
|
||||
ExecChroot(
|
||||
'apt-get',
|
||||
'install',
|
||||
'--assume-yes',
|
||||
'openssh-server')
|
||||
module = icon_lib.IconModule(FLAGS.chroot_path)
|
||||
module.InstallPackages('openssh-server')
|
||||
|
||||
for path in glob.glob(os.path.join(FLAGS.chroot_path, 'etc', 'ssh', 'ssh_host_*')):
|
||||
os.unlink(path)
|
||||
|
||||
Reference in New Issue
Block a user