pam: use a pam object method instead of pam module function
[cascardo/ipsilon.git] / ipsilon / install / ipsilon-server-install
index 0625125..64fa413 100755 (executable)
@@ -97,6 +97,7 @@ def install(plugins, args):
                 'publicdatadir': args['public_data_dir'],
                 'wellknowndir': args['wellknown_dir'],
                 'sysuser': args['system_user'],
+                'cleanup_interval': args['cleanup_interval'],
                 'ipsilondir': BINDIR,
                 'staticdir': STATICDIR,
                 'cachedir': CACHEDIR,
@@ -242,9 +243,14 @@ def uninstall(plugins, args):
                               'ipsilon-%s.conf' % args['instance'])
     data_dir = os.path.join(DATADIR, args['instance'])
 
-    tconf = ConfigParser.SafeConfigParser()
-    tconf.read(os.path.join(instance_conf, 'ipsilon.conf'))
-    cache_dir = tconf.get('global', 'cache_dir').replace('"', '')
+    try:
+        tconf = ConfigParser.SafeConfigParser()
+        tconf.read(os.path.join(instance_conf, 'ipsilon.conf'))
+        cache_dir = tconf.get('global', 'cache_dir')
+    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
+        cache_dir = None
+    else:
+        cache_dir = cache_dir.replace('"', '')
 
     if not os.path.exists(instance_conf):
         raise Exception('Could not find instance %s configuration'
@@ -376,7 +382,11 @@ def parse_args(plugins):
     parser.add_argument('--transaction-dburi',
                         help='Transaction database URI (override template)')
     parser.add_argument('--samlsessions-dburi',
-                        help='SAML 2 sessions database URI (override template)')
+                        help='SAML 2 sessions database URI (override ' +
+                             'template)')
+    parser.add_argument('--cleanup-interval', default=30,
+                        help='Interval between cleaning up stale database ' +
+                             'entries (in minutes, default: 30 minutes)')
 
     lms = []
 
@@ -400,7 +410,8 @@ def parse_args(plugins):
         return args
 
     if len(args['hostname'].split('.')) < 2:
-        raise ConfigurationError('Hostname: %s is not a FQDN')
+        raise ConfigurationError('Hostname: %s is not a FQDN' %
+                                 args['hostname'])
 
     for plugin_group in plugins:
         for plugin_name in plugins[plugin_group]:
@@ -410,7 +421,8 @@ def parse_args(plugins):
     try:
         pwd.getpwnam(args['system_user'])
     except KeyError:
-        raise ConfigurationError('User: %s not found on the system')
+        raise ConfigurationError('User: %s not found on the system' %
+                                 args['system_user'])
 
     if args['lm_order'] is None:
         args['lm_order'] = []
@@ -431,12 +443,12 @@ if __name__ == '__main__':
     opts = []
     out = 0
     openlogs()
+    logger.setLevel(logging.DEBUG)
+
     try:
         fplugins = find_plugins()
         opts = parse_args(fplugins)
 
-        logger.setLevel(logging.DEBUG)
-
         logger.debug('Installation arguments:')
         for k in sorted(opts.iterkeys()):
             logger.debug('%s: %s', k, opts[k])
@@ -449,7 +461,8 @@ if __name__ == '__main__':
         else:
             install(fplugins, opts)
     except Exception, e:  # pylint: disable=broad-except
-        logger.debug(e, exc_info=1)
+        logger.info(str(e))         # emit message to console
+        logger.debug(e, exc_info=1) # add backtrace information to logfile
 
         if 'uninstall' in opts and opts['uninstall'] is True:
             logger.info('Uninstallation aborted.')