#!/usr/bin/python import os, sys import logging sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'lib')) from utils import * from cfg import * # commands from gen import gen from newca import newca from list import list from files import files from initfs import initfs from check import check def Usage(): print ''' CAM v0.1 - (c)2006 by A Certification Authority manager for complex situations. Usage: %s [...] Known commands: init Initialize the environment by creating the necessary directory structure newca [ []] Create a new CA certificate (otherwise you can import your own certificates) gen ... Create (or re-create) the certificates corresponding to TAG list List all known certificates files ... Dump all the certificate-related files of this TAG check Should be run weekly from a cron job to warn you if some certificates are about to expire (controlled by the 'warning_days' parameter in the 'global' section of the configuration) The configuration will be read from '%s'. It consists of a ini-style file, with one 'ca' section that specifies global CA parameters, and more sections for each tag with certificate-specific information. See the examples for more details on how to write your own configuration. ''' % (sys.argv[0], config_file_path) sys.exit(0) if len(sys.argv) < 2 or sys.argv[1] == 'help': Usage() cmd = sys.argv[1] if cmd == 'init': initfs() elif cmd == 'gen': for tag in sys.argv[2:]: gen(tag) elif cmd == 'newca': newca() elif cmd == 'list': list(sys.argv[2:]) elif cmd == 'files': for tag in sys.argv[2:]: files(tag) elif cmd == 'check': check() else: print 'Unknown command \'%s\'.' % cmd Usage()