from ipsilon.login.common import LoginMgrsInstall
from ipsilon.providers.common import ProvidersInstall
import argparse
+import cherrypy
import logging
import os
+import pwd
import shutil
+import socket
import sys
import time
+TEMPLATES = '/usr/share/ipsilon/templates/install'
+CONFDIR = '/etc/ipsilon'
+HTTPDCONFD = '/etc/httpd/conf.d'
+
+
class ConfigurationError(Exception):
def __init__(self, message):
return repr(self.message)
+#Silence cherrypy logging to screen
+cherrypy.log.screen = False
+
+# Regular logging
LOGFILE = '/var/log/ipsilon-install.log'
logger = logging.getLogger()
def install(plugins, args):
logger.info('Installation initiated')
+ now = time.strftime("%Y%m%d%H%M%S", time.gmtime())
+
+ logger.info('Installing default config files')
+ ipsilon_conf = os.path.join(CONFDIR, 'ipsilon.conf')
+ idp_conf = os.path.join(CONFDIR, 'idp.conf')
+ args['httpd_conf'] = os.path.join(HTTPDCONFD, 'idp.conf')
+ if os.path.exists(ipsilon_conf):
+ shutil.move(ipsilon_conf, '%s.bakcup.%s' % (ipsilon_conf, now))
+ if os.path.exists(idp_conf):
+ shutil.move(idp_conf, '%s.backup.%s' % (idp_conf, now))
+ shutil.copy(os.path.join(TEMPLATES, 'ipsilon.conf'), CONFDIR)
+ shutil.copy(os.path.join(TEMPLATES, 'idp.conf'), CONFDIR)
+ if not os.path.exists(args['httpd_conf']):
+ os.symlink(idp_conf, args['httpd_conf'])
+ # Load the cherrypy config from the newly installed file so
+ # that db paths and all is properly set before configuring
+ # components
+ cherrypy.config.update(ipsilon_conf)
+
+ # Move pre-existing admin db away
+ admin_db = cherrypy.config['admin.config.db']
+ if os.path.exists(admin_db):
+ shutil.move(admin_db, '%s.backup.%s' % (admin_db, now))
logger.info('Configuring login managers')
for plugin_name in args['lm_order']:
action='version', version='%(prog)s 0.1')
parser.add_argument('-o', '--login-managers-order', dest='lm_order',
help='Comma separated list of login managers')
+ parser.add_argument('--hostname',
+ help="Machine's fully qualified host name")
+ parser.add_argument('--system-user', default='ipsilon',
+ help="User account used to run the server")
parser.add_argument('--ipa', choices=['yes', 'no'], default='yes',
help='Detect and use an IPA server for authentication')
parser.add_argument('--uninstall', action='store_true',
args = vars(parser.parse_args())
+ if not args['hostname']:
+ args['hostname'] = socket.getfqdn()
+
+ if len(args['hostname'].split('.')) < 2:
+ raise ConfigurationError('Hostname: %s is not a FQDN')
+
+ try:
+ pwd.getpwnam(args['system_user'])
+ except KeyError:
+ raise ConfigurationError('User: %s not found on the system')
+
if args['lm_order'] is None:
args['lm_order'] = []
for name in lms: