published the encrypted file with passwds included now that we have checked the key
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 16 Jun 2010 15:17:03 +0000 (17:17 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 16 Jun 2010 15:17:03 +0000 (17:17 +0200)
omf/export-omf.py
omf/export-omf.sh

index d470471..21db926 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/plcsh
+#!/usr/bin/python /usr/bin/plcsh
 
 # utility to store, read and diff our user base data for exporting to OMF
 
@@ -20,8 +20,7 @@ def getPersons(filter={}):
 
 class OmfUserBase:
 
-    def __init__ (self, options, filename):
-        self.filename=filename
+    def __init__ (self, options):
         self.options=options
             
 
@@ -44,12 +43,15 @@ class OmfUserBase:
         for key_id in person['key_ids']:
             print >>file, "ssh=%s"%pubkeys_by_id[key_id]
 
-    def save(self):
+    def save(self, output):
         """
         Write configuration store to file.
         """
-
-        fileout = open(self.filename, 'w')
+        
+        if output:
+            fileout = open(output, 'w')
+        else:
+            fileout=sys.stdout
         print >>fileout, "# myplc simple userbase extration tools export-omf.py"
         print >>fileout, "# generated on %s"%time.strftime("%Y-%m-%d @ %H:%M UTC",time.gmtime())
         # store all ssh keys by key_id - keep only the public key
@@ -65,18 +67,22 @@ class OmfUserBase:
 
 
 def main ():
-    parser = OptionParser (usage="%prog [options] OUTPUT_FILE")
+    parser = OptionParser (usage="""%prog [options]
+Default output is on stdout""")
     parser.add_option ("-n","--no-password", action="store_true",
                        dest="no_password", default=False, help="Don't include encrypted passwords")
+    parser.add_option ("-o","--output", action="store",
+                       dest="output", default=None, help="Specify output filename")
     options,args = parser.parse_args()
 
-    try:
-        output = args[0]
-    except IndexError:
-        parser.error("no output file")
+    if len(args)!=0:
+        parser.print_help()
+        sys.exit(1)
+
+    userbase=OmfUserBase(options)
+    userbase.save(options.output)
 
-    userbase=OmfUserBase(options, output)
-    userbase.save()
+    
 
 if __name__ == '__main__':
     main()
index 87bf944..8d881ad 100755 (executable)
@@ -16,13 +16,8 @@ DIRNAME=$(dirname $0)
 
 cd $DIRNAME
 
-# refresh EXPORT and EXPORT.snip with the python script
-
-plcsh ./export-omf.py -- -n EXPORT.snip
-plcsh ./export-omf.py -- EXPORT
-
-yes | gpg -r CERTH -e < EXPORT.snip > EXPORT.snip.nitlab
-yes | gpg -r CERTH -e < EXPORT > EXPORT.nitlab
+# refresh the gpg encrypted version of the export file 
+plcsh ./export-omf.py | gpg -r CERTH -e --output EXPORT.nitlab.gpg
 
 # publish under /var/www/html/download/EXPORT.nitlab
-# or whatever the name is
+cp EXPORT.nitlab.gpg /var/www/html/download/EXPORT.nitlab.gpg