diff options
Diffstat (limited to 'morphlib/exts/fstab.configure')
-rwxr-xr-x | morphlib/exts/fstab.configure | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/morphlib/exts/fstab.configure b/morphlib/exts/fstab.configure index b9154eee..3bbc9102 100755 --- a/morphlib/exts/fstab.configure +++ b/morphlib/exts/fstab.configure @@ -1,6 +1,5 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# Copyright © 2013-2015 Codethink Limited +#!/usr/bin/python +# Copyright (C) 2013,2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,9 +19,21 @@ import os import sys -import morphlib -envvars = {k: v for (k, v) in os.environ.iteritems() if k.startswith('FSTAB_')} +def asciibetical(strings): -conf_file = os.path.join(sys.argv[1], 'etc/fstab') -morphlib.util.write_from_dict(conf_file, envvars) + def key(s): + return [ord(c) for c in s] + + return sorted(strings, key=key) + + +fstab_filename = os.path.join(sys.argv[1], 'etc', 'fstab') + +fstab_vars = asciibetical(x for x in os.environ if x.startswith('FSTAB_')) +with open(fstab_filename, 'a') as f: + for var in fstab_vars: + f.write('%s\n' % os.environ[var]) + +os.chown(fstab_filename, 0, 0) +os.chmod(fstab_filename, 0644) |