Xenial changes

This commit is contained in:
Ian Gulliver
2016-07-18 18:40:07 +00:00
parent e65035d230
commit 95315dfa77
3 changed files with 41 additions and 43 deletions

View File

@@ -3,6 +3,8 @@
import argparse
import os
import icon_lib
parser = argparse.ArgumentParser(description='iconograph persistent')
parser.add_argument(
@@ -14,24 +16,40 @@ FLAGS = parser.parse_args()
def main():
module = icon_lib.IconModule(FLAGS.chroot_path)
os.mkdir(os.path.join(FLAGS.chroot_path, 'persistent'))
init = os.path.join(FLAGS.chroot_path, 'etc', 'init', 'persistent.conf')
with open(init, 'w') as fh:
fh.write("""
description "Mount /persistent"
tool_path = os.path.join(FLAGS.chroot_path, 'icon', 'persistent')
os.makedirs(tool_path, exist_ok=True)
start on filesystem
task
emits persistent-ready
script
mount -o data=journal,noatime,sync LABEL=PERSISTENT /persistent
initctl emit --no-wait persistent-ready
end script
script = os.path.join(tool_path, 'startup.sh')
with open(script, 'w') as fh:
os.chmod(fh.fileno(), 0o755)
fh.write("""\
#!/bin/bash
mount -o data=journal,noatime,sync LABEL=PERSISTENT /persistent
""")
with module.ServiceFile('persistent.service') as fh:
fh.write("""
[Unit]
Description=Mount /persistent
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service
Before=sysinit.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/icon/persistent/startup.sh
[Install]
WantedBy=sysinit.target
""")
module.EnableService('persistent.service')
if __name__ == '__main__':
main()