예제 #1
0
 def install(self, package):
     source_path = package.get_file()
     target_dirname = os.path.dirname(self.extract_path)
     try:
         extract_parent_dir = os.path.dirname(self.extract_path)
         extract_dirname = os.path.basename(self.extract_path)
         if not os.path.exists(extract_parent_dir):
             logger.action("mkdir -p %s" % extract_parent_dir)
             os.makedirs(extract_parent_dir)
         elif os.path.exists(self.extract_path):
             # old version present, remove it
             logger.action("rm -rf %s" % self.extract_path)
             shutil.rmtree(self.extract_path)
         package.extract(extract_parent_dir, extract_dirname)
     except:
         logger.exception("Extract for %s failed" % package.get_file())
         error = convert_exc_to_user_error(sys.exc_info(),
                                           errors[ERR_EXTRACT_ERROR],
                                           msg_args={"archive":package.get_file(),
                                                     "dir":self.extract_path})
         raise error
     try:
         if self.group:
             engage.utils.file.set_shared_directory_group_and_permissions(self.extract_path, self.group, logger)
     except:
         logger.exception("Recursive permission set for %s failed" % self.extract_path)
         error = convert_exc_to_user_error(sys.exc_info(),
                                           errors[ERR_PERMSET_ERROR],
                                           msg_args={"dir":self.extract_path, "group":self.group})
         raise error
     self.ran_install = True
     self.validate_post_install()
예제 #2
0
파일: copy_file.py 프로젝트: quaddra/engage
 def install(self, package):
     source_path = package.get_file()
     target_dirname = os.path.dirname(self.file_path)
     try:
         if not os.path.exists(target_dirname):
             logger.action("mkdir -p %s" % target_dirname)
             os.makedirs(target_dirname)
             if self.file_group:
                 engage.utils.file.set_shared_file_group_and_permissions(target_dirname, self.file_group, logger)
         logger.action("cp %s %s" % (source_path, self.file_path))
         shutil.copy(source_path, self.file_path)
     except:
         logger.exception("File copy for %s failed" % package.get_file())
         error = convert_exc_to_user_error(sys.exc_info(),
                                           errors[ERR_INSTALL_COPY_ERROR],
                                           msg_args={"file":self.file_path})
         raise error
     if self.file_group:
         try:
             engage.utils.file.set_shared_file_group_and_permissions(self.file_path, self.file_group, logger)
         except:
             error = convert_exc_to_user_error(sys.exc_info(),
                                               errors[ERR_INSTALL_PERMSET_ERROR],
                                               msg_args={"file":self.file_path, "group":self.file_group})
             raise error
     self.ran_install = True
     self.validate_post_install()
예제 #3
0
    def run(self, package):
        """Run the load operation on the specified port(s).

        Unfortunately, there's no way to query if a port is already loaded.
        To get already this, we make the operation itempotent: we try the
        port load. If it fails, we scan the results to see if we get the error
        message indicating the port was already loaded. In that case, we ignore
        the error.
        """
        port_exe = self.ctx.props.input_ports.macports.macports_exe
        action._check_file_exists(port_exe, self)
        try:
            re_map = {"already_loaded": concat(lit("Error: Target org.macports.load returned:"),
                                               one_or_more(any_except_newline()),
                                               line_ends_with(lit("Already loaded"))).get_value()}
            (rc, result_map) = \
                 iuprocess.run_sudo_program_and_scan_results([port_exe, "load",
                                                              package],
                                                             re_map, self.ctx.logger,
                                                             self.ctx._get_sudo_password(self),
                                                             log_output=True,
                                                             cwd=os.path.dirname(port_exe),
                                                             env=ENV)
        except iuprocess.SudoError, e:
            self.ctx.logger.exception("Port load for %s failed, unexpected exception" % package)
            exc_info = sys.exc_info()
            sys.exc_clear()
            raise convert_exc_to_user_error(exc_info, errors[ERR_MACPORTS_LOAD],
                                            msg_args={"pkg":package, "id":self.ctx.props.id},
                                            nested_exc_info=e.get_nested_exc_info())
예제 #4
0
파일: mysql.py 프로젝트: quaddra/engage
def _mysql_secure_installation(config):
    """This function implements the equivalent of the script
    mysql_secure_installation, which comes with the mysql install. We don't
    run that script directly, because it expects a tty for entering passwords,
    which is somewhat problematic when running from python.
    """
    try:
        # remove anonymous users
        _do_query("DELETE FROM mysql.user WHERE User='';", config, "Install",
                  root_pw="")
        # disallow remote root login
        _do_query("DELETE FROM mysql.user WHERE User='******' AND Host!='localhost';",
                  config, "Install", root_pw="")
        # remove the test databae
        _do_query("DROP DATABASE test;", config, "Install", root_pw="")
        _do_query("DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'", config,
                  "Install", root_pw="")
        # change the root password
        pw_cmd = "UPDATE mysql.user SET Password=PASSWORD('%s') WHERE User='******';"\
            % config.admin_password
        _do_query(pw_cmd, config, "Install", root_pw="")
        # reload privilege tables
        _do_query("FLUSH PRIVILEGES;", config, "Install", root_pw="")
    except UserError:
        raise
    except:
        raise convert_exc_to_user_error(sys.exc_info(), errors[ERR_SECURE_EXC])
예제 #5
0
파일: aptget.py 프로젝트: quaddra/engage
def dpkg_install(package_file, sudo_password, may_have_dependencies=True):
    """Given a package's .deb file, install using dpkg. may_have_dependencies should
    be left at True if it is possible that the .deb package has dependencies that aren't
    being managed by Engage. In this case, it will run an apt-get update to make
    sure the package database is up-to-date. If you know that you don't have dependencies,
    set this to False to suppress the apt-get update call, which can fail due
    to remote servers being temporarily unavailable.
    """
    env = _get_env_for_aptget()
    if not os.path.exists(DPKG_PATH):
        raise UserError(errors[ERR_DPKG_NOT_FOUND],
                        msg_args={"path":DPKG_PATH})
    if not os.path.exists(package_file):
        raise UserError(errors[ERR_PKG_FILE_NOT_FOUND],
                        msg_args={"path":package_file})
    
    try:
        if may_have_dependencies:
            run_update_if_not_already_run(sudo_password, env)
        iuprocess.run_sudo_program([DPKG_PATH, "-i", package_file], sudo_password,
                                   logger, env=env)
    except iuprocess.SudoError, e:
        exc_info = sys.exc_info()
        sys.exc_clear()
        raise convert_exc_to_user_error(exc_info, errors[ERR_DPKG_INSTALL],
                                        msg_args={"path":package_file},
                                        nested_exc_info=e.get_nested_exc_info())
예제 #6
0
    def run(self, apache_config, timeout_tries=5, time_between_tries=2.0):
        """If you check whether apache is running just after it was (re)started, it may report that it
        isn't running when it is infact running. This is because apache takes a few seconds before it writes
        its pid file out. Thus, we need to use a timeout to see if apache could really be up when the status
        command reports that it is down. If you haven't just started apache, you can probably reduce the
        timeout duration. Note that time_between_tries is in seconds, so the default timeout is 10 seconds.
        """
        controller_exe = apache_config.controller_exe
        action._check_file_exists(controller_exe, self)
        if controller_exe=='/opt/local/apache2/bin/apachectl':
            """The apachectl for macports is broken. We determine whether apache is
            running by looking for the process
            """
            return _macports_apache_is_running(controller_exe, self.ctx._get_sudo_password(self))

        for i in range(timeout_tries):
            try:
                iuprocess.run_sudo_program([controller_exe, "status"],
                                           self.ctx._get_sudo_password(self), self.ctx.logger)
                self.ctx.logger.debug("Apache status is up")
                return True
            except iuprocess.SudoBadRc, e:
                if e.rc == 1: # this means the server is down
                    self.ctx.logger.debug("Apache status is down")
                    if i != (timeout_tries-1): time.sleep(time_between_tries)
                else:
                    exc_info = sys.exc_info()
                    self.ctx.logger.exception("Unexpected exception when checking for apache status occurred in resource %s" %
                                              self.ctx.props.id)
                    raise convert_exc_to_user_error(exc_info, errors[ERR_APACHE_STATUS], nested_exc_info=e.get_nested_exc_info(),
                                                    msg_args={"id":self.ctx.props.id})
예제 #7
0
def _undo_bad_install(failed_resource_mgr, undo_list, deployment_home, orig_exc):
    m = failed_resource_mgr
    try:
        ## failed_upgrade_dir = os.path.join(deployment_home, "failed_upgrade")
        ## if os.path.exists(failed_upgrade_dir):
        ##     logger.debug("Removing old upgrade directory %s" % failed_upgrade_dir)
        ##     shutil.rmtree(failed_upgrade_dir)
        logger.debug("Force stop and uninstall of resource %s" % failed_resource_mgr.id)
        if m.is_service():
            m.force_stop()
        ## os.makedirs(failed_upgrade_dir)
        m.uninstall(incomplete_install=True)
        logger.debug("Uninstalling remaining resources")
        undo_list.reverse()
        for m in undo_list:
            if m.is_service():
                m.force_stop()
            m.uninstall(incomplete_install=False)
        logger.info("Uninstall of failed version successful")
    except:
        exc_info = sys.exc_info()
        logger.exception("Exception thrown during undo")
        raise convert_exc_to_user_error(exc_info, errors[ERR_ROLLBACK_FAILED],
                                        msg_args={'failed_id':m.id, 'orig_id':failed_resource_mgr.id,
                                                  'orig_exc':orig_exc})
예제 #8
0
def upgrade(backup_dir, file_layout, deployment_home, options,
            atomic_upgrade=True):
    old_resources = get_old_resources(backup_dir)
    mgrs_and_pkgs = cmdline_script_utils.get_mgrs_and_pkgs(file_layout,
                                                           deployment_home,
                                                           options,
                                                           file_layout.get_install_script_file())
    undo_list = []
    for (m, p) in mgrs_and_pkgs:
        id = m.metadata.id
        try:
            if old_resources.has_key(id) and old_resources[id].key['name']==m.metadata.key['name'] and \
               m.metadata.key['version']>=old_resources[id].key['version']:
                logger.info("Calling upgrade for resource %s" % id)
                m.upgrade(p, old_resources[id], backup_dir)
            else:
                if not m.is_installed():
                    logger.info("Installing resource %s" % id)
                    m.install(p)
                else:
                    logger.info("Resource %s already installed" % id)
            m.metadata.set_installed()
            if m.is_service() and not m.is_running():
                m.start()
            undo_list.append(m)
        except:
            if not atomic_upgrade:
                raise
            exc_info = (exc_class, exc_val, exc_tb) = sys.exc_info()
            logger.exception("Upgrade of %s failed, will attempt undo" % m.id)
            _undo_bad_install(m, undo_list, deployment_home, "%s(%s)" % (exc_class.__name__, exc_val))
            user_error = convert_exc_to_user_error(exc_info, errors[ERR_UPGRADE_ROLLBACK],
                                                   msg_args={'id':m.id},
                                                   user_error_class=UpgradeRollbackInProgress)
            user_error.resource_id = m
            raise user_error
        
    install_target_mgr = get_install_target_mgr(mgrs_and_pkgs)
    managers = [mgr for (mgr, pkg) in mgrs_and_pkgs]
    install_target_mgr.write_resources_to_file(managers)
    if options.mgt_backends:
        import mgt_registration
        import install_context
        mgt_registration.register_with_mgt_backends(options.mgt_backends,
                                                    managers,
                                                    deployment_home,
                                                    sudo_password=install_context.get_sudo_password(),
                                                    upgrade=True)
    return 0
예제 #9
0
 def restore(self, backup_to_directory, package):
     backup_location = self._find_backup_archive(backup_to_directory)
     try:
         logger.debug("Restoring resource %s from %s" % (self.id, backup_location))
         if os.geteuid() != 0 and backup.check_if_restore_requires_superuser(backup_location):
             logger.info("Running restore via sudo for resource %s" % self.id)
             backup.restore_as_sudo_subprocess(backup_location, self._get_sudo_password(), move=False)
         else:
             backup.restore(backup_location, move=False)
     except:
         exc_info = (exc_tp, exc_v, ecx_tb) = sys.exc_info()
         raise convert_exc_to_user_error(
             exc_info,
             errors[EXC_IN_RESTORE_CALL],
             msg_args={"id": self.id, "file": backup_location, "exc_typ": exc_tp.__name__, "exc_val": exc_v},
         )
예제 #10
0
파일: aptget.py 프로젝트: quaddra/engage
def apt_get_install(package_list, sudo_password):
    env = _get_env_for_aptget()
    if not os.path.exists(APT_GET_PATH):
        raise UserError(errors[ERR_APT_GET_NOT_FOUND],
                        msg_args={"path":APT_GET_PATH})
    
    try:
        run_update_if_not_already_run(sudo_password, env)
        iuprocess.run_sudo_program([APT_GET_PATH, "-q", "-y", "install"]+package_list, sudo_password,
                                   logger,
                                   env=env)
    except iuprocess.SudoError, e:
        exc_info = sys.exc_info()
        sys.exc_clear()
        raise convert_exc_to_user_error(exc_info, errors[ERR_APT_GET_INSTALL],
                                        msg_args={"pkgs":package_list.__repr__()},
                                        nested_exc_info=e.get_nested_exc_info())
예제 #11
0
    def run(self, password_file, username, password, apache_config):
        class LogProxy:
            """We need to wrap the logger and capture any action events, as those may
            contain the password.
            """
            def __init__(self, logger):
                #Set attribute.
                self._logger = logger
            def __getattr__(self, attrib):
                if attrib == "action":
                    return self.action
                else:
                    return getattr(self._logger, attrib)
            def action(self, msg):
                pass

        htpasswd_exe = apache_config.htpasswd_exe
        action._check_file_exists(htpasswd_exe, self)
        if os.path.exists(password_file):
            cmd = [htpasswd_exe, "-b", password_file, username, password]
        else:
            cmd = [htpasswd_exe, "-b", "-c", password_file, username, password]
        if self.ctx._get_sudo_password(self)==None or iuprocess.is_running_as_root():
            self.ctx.logger.action("%s <password>" % " ".join(cmd[0:-1]))
            rc = iuprocess.run_and_log_program(cmd, {}, LogProxy(self.ctx.logger))
            if rc != 0:
                raise UserError(errors[ERR_APACHE_HTPASSWD],
                                msg_args={"exe": htpasswd_exe,
                                          "file": password_file,
                                          "id":self.ctx.props.id},
                                developer_msg="return code was %d" % rc)
        else:
            try:
                logger.action("sudo %s <password>" % " ".join(cmd[0:-1]))
                iuprocess.run_sudo_program(cmd, self.ctx._get_sudo_password(self),
                                           LogProxy(self.ctx.logger))
            except Exception, e:
                exc_info = sys.exc_info()
                logger.exception("exception in htpasswd: %s, resource %s" % (e.__repr__(),
                                                                             ctx.props.id))
                raise convert_exc_to_user_error(exc_info, errors[ERR_APACHE_HTPASSWD],
                                                msg_args={"exe": htpasswd_exe,
                                                          "file": password_file,
                                                          "id":self.ctx.props.id},
                                                developer_msg="exception" % e.__repr__())
예제 #12
0
 def backup(self, backup_to_directory, compress=True):
     backup_location = self._get_backup_location(backup_to_directory, self.id, compress)
     logger.debug("Saving resource %s files to %s" % (self.id, backup_location))
     files = self._get_backup_file_list()
     if len(files) == 0:
         raise UserError(errors[ERR_BACKUP_FILE_LIST_EMPTY], msg_args={"id": self.id})
     try:
         if os.geteuid() != 0 and backup.check_if_save_requires_superuser(files):
             logger.info("Running backup via sudo for resource %s" % self.id)
             backup.save_as_sudo_subprocess(files, backup_location, self._get_sudo_password(), move=False)
         else:
             backup.save(files, backup_location, move=False)
     except:
         exc_info = (exc_tp, exc_v, ecx_tb) = sys.exc_info()
         raise convert_exc_to_user_error(
             exc_info,
             errors[EXC_IN_BACKUP_CALL],
             msg_args={"id": self.id, "file": backup_location, "exc_typ": exc_tp.__name__, "exc_val": exc_v},
         )
예제 #13
0
 def run(self, package_list):
     """Install the specified port(s). If you have variants, include them in
     the package list. Expects the context to have an input port "macports"
     with a property "macports_exe".
     """
     port_exe = self.ctx.props.input_ports.macports.macports_exe
     action._check_file_exists(port_exe, self)
     try:
         iuprocess.run_sudo_program([port_exe, "install"]+package_list,
                                    self.ctx._get_sudo_password(self),
                                    self.ctx.logger,
                                    cwd=os.path.dirname(port_exe),
                                    env=ENV)
     except iuprocess.SudoError, e:
         exc_info = sys.exc_info()
         self.ctx.logger.exception("Port install for %s failed, unexpected exception" % package_list)
         sys.exc_clear()
         raise convert_exc_to_user_error(exc_info, errors[ERR_MACPORTS_INSTALL],
                                         msg_args={"pkg":package_list.__repr__(),
                                                   "id":self.ctx.props.id},
                                         nested_exc_info=e.get_nested_exc_info())
예제 #14
0
    if os.path.exists(install_request.config_error_file):
        os.remove(install_request.config_error_file)
    try:
        return run(install_request, logger)
    except upgrade_engine.UpgradeRollbackInProgress, e:
        e.write_error_to_file(os.path.join(install_request.installer_file_layout.get_log_directory(), "upgrade_error.json"))
        return 3 # magic number to indicate rollback is in progress
    except UserError, e:
        if installer_file_layout:
            raise # if called from another script, let that one handle it
        logger.exception("Aborting install due to error.")
        if not os.path.exists(install_request.error_file):
            e.write_error_to_file(install_request.error_file)
        return 1
    except:
        (ec, ev, et) = sys.exc_info()
        logger.exception("Unexpected exception: %s(%s)" %  (ec.__name__, ev))
        user_error = convert_exc_to_user_error(sys.exc_info(),
                                               errors[ERR_UNEXPECTED_EXC])
        user_error.write_error_to_log(logger)
        if not os.path.exists(install_request.error_file):
            user_error.write_error_to_file(install_request.error_file)
        return 1
        

def call_from_console_script():
    sys.exit(main(sys.argv[1:]))

if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
예제 #15
0
파일: trac_pm.py 프로젝트: quaddra/engage
    def install(self, download_url):
	logger.debug("installing trac project %s" % self.config.projectname )
        # get the passwords that we will need from the repository
        sudo_password = \
            install_context.password_repository.get_value(self.config.sudo_password)
        admin_password = \
            install_context.password_repository.get_value(self.config.admin_password)
        try:
            trac_admin_exe = os.path.join(self.config.trachome, "bin/trac-admin")
            rc = iuprocess.run_and_log_program([trac_admin_exe, self.config.projecthome, "initenv", 
                                                self.config.projectname,
                                                self.config.projectdb,
                                                self.config.version_control,
                                                self.config.repository],
                                                   {}, logger, None, None)
            if rc != 0:
                raise UserError(errors[ERR_TRACADMIN_FAILURE])
            logger.debug("trac-admin ran successfully.")
	    permissions = [ "BROWSER_VIEW",
			    "CHANGESET_VIEW",
			    "FILE_VIEW",
			    "LOG_VIEW",
			    "MILESTONE_VIEW",
			    "REPORT_SQL_VIEW",
			    "REPORT_VIEW",
			    "ROADMAP_VIEW",
			    "SEARCH_VIEW",
			    "TICKET_CREATE",
			    "TICKET_APPEND",
			    "TICKET_MODIFY",
			    "TICKET_VIEW",
			    "TIMELINE_VIEW",
			    "WIKI_CREATE",
			    "WIKI_MODIFY",
			    "WIKI_DELETE",
			    "WIKI_VIEW" ]
	    # drop permissions for anonymous
            rc = iuprocess.run_and_log_program([trac_admin_exe, self.config.projecthome, 
                                                "permission", "remove", "anonymous"] + permissions, 
						{}, logger, None, None)
            if rc != 0:
                raise UserError(errors[ERR_TRACADMIN_FAILURE])
            logger.debug("trac-admin removed permissions for anonymous.")
	    # add permissions for authenticated
            rc = iuprocess.run_and_log_program([trac_admin_exe, self.config.projecthome, 
                                                "permission", "remove", "authenticated", '*'],
						{}, logger, None, None)
            rc = iuprocess.run_and_log_program([trac_admin_exe, self.config.projecthome, 
                                                "permission", "add", "authenticated"] + permissions, 
						{}, logger, None, None)
            if rc != 0:
                raise UserError(errors[ERR_TRACADMIN_FAILURE])
            logger.debug("trac-admin added permissions for authenticated.")
            # now add permission for admin user
            rc = iuprocess.run_and_log_program([trac_admin_exe, self.config.projecthome, "permission", "add",
                                           self.config.administrator, "TRAC_ADMIN"],
                                          {}, logger, None, None)
            logger.debug("trac-admin added permissions successfully.")
            if os.path.exists(self.config.password_file) == False:
               # set up the password file and add admin with initial password
               logger.debug("about to make password file")
               # TODO: htpasswd_exe is the program installed with Apache to create/update passwords.
               # This causes us to have an implicit dependency on apache. Need to figure out
               # a way to remove this dependency. Perhaps we can provide generic methods on the webserver
               # service class or in the engage.utils package.
               htpasswd_exe = self.config.input_ports.webserver.htpasswd_exe
               rc = iuprocess.run_and_log_program([htpasswd_exe, "-cbm", self.config.password_file,
                                                   self.config.administrator, admin_password], 
                                                  {}, logger, None, None)
            else: 
               pass # XXX: check user administrator exists
            trac_ini_file = os.path.abspath(os.path.join(self.config.projecthome, "conf/trac.ini"))
            logger.debug("Looking for ini file " + trac_ini_file)
            if os.path.exists(trac_ini_file) == False:
            	raise UserError(errors[ERR_TRAC_INI_NOT_FOUND])
	     
            # now hack the trac.ini file for git plugin
            if self.config.version_control == "git":
                trac_ini_file_changed = trac_ini_file + ".changed" 
                git_bin = self.config.input_ports.repository.git_exe
                escaped_git_bin = string.replace(git_bin, "/", "\/")
                logger.debug("git path is " + git_bin)
                f = open(trac_ini_file, "r")
                (tmpf, tmpn) = tempfile.mkstemp()
                for line in f :
                   cline = line.replace("cached_repository = false", "cached_repository = true")
                   cline = cline.replace("persistent_cache = false", "persistent_cache = true")
                   cline = re.sub("git_bin = .*$", "git_bin = " + git_bin, cline)
                   os.write(tmpf, cline)
                os.write(tmpf, "[components]\ntracext.git.* = enabled\n");
                f.close()
                os.close(tmpf)
                shutil.copyfile(tmpn, trac_ini_file) 

            cfg = TracConfig(trac_ini_file)
            # basic setup
	    # set base_url
            cfg.update("trac", "base_url", self.config.get_base_url())
	    # set up notification
	    # By default, use SMTP
	    # See http://trac.edgewall.org/wiki/TracNotification 
	    notification_string = self.config.get_smtp_notification_string()
	    cfg.set_config(json.loads(notification_string))
            #plugins
            logger.debug(self.config.acctmgrconf)
	    conf = json.loads((self.config.acctmgrconf).__str__())
	    logger.debug(conf)
	    cfg.set_config(conf) 
	    cfg.update("account-manager", "password_file", self.config.password_file)
	    # disable new users registering on the web
	    cfg.update("components", "acct_mgr.web_ui.registrationmodule", "disabled")
            logger.debug(self.config.gitpluginconf)
	    conf = json.loads((self.config.gitpluginconf).__str__())
	    cfg.set_config(conf) 
            logger.debug(self.config.iniadminconf)
	    conf = json.loads((self.config.iniadminconf).__str__())
	    cfg.set_config(conf) 
            logger.debug(self.config.themeengineconf)
	    conf = json.loads((self.config.themeengineconf).__str__())
	    cfg.set_config(conf) 
            logger.debug(self.config.gfappconf)
	    conf = json.loads((self.config.gfappconf).__str__())
	    cfg.set_config(conf) 
	    cfg.update("gfapp", "tracbin", self.config.trachome)
	    cfg.update("gfapp", "trachome", self.config.projecthome)
            logger.debug(self.config.permredirectconf)
	    conf = json.loads((self.config.permredirectconf).__str__())
	    cfg.set_config(conf) 
            logger.debug(self.config.gfdownloadconf)
	    conf = json.loads((self.config.gfdownloadconf).__str__())
	    cfg.set_config(conf) 
	
	    # enable logging
	    cfg.update("logging", "log_file", os.path.join(self.config.projecthome, "trac.log"))
	    cfg.update("logging", "log_type", "file") 
	    cfg.update("logging", "log_level", "DEBUG") 
	    cfg.update("trac", "mainnav", "wiki,genforma,search")

	    menu_string = self.config.get_menu_string()
            menu_f = cStringIO.StringIO(menu_string)
	    menu_cfg = ConfigParser.SafeConfigParser()
            menu_cfg.readfp(menu_f)
	    menu_f.close()
            for section in menu_cfg.sections():
                for (menuname, menuval) in menu_cfg.items(section):
                    cfg.update(section, menuname, menuval) 

	    cfg.writeback()
            logger.debug("Done updating trac.ini file")
	    # upgrade trac environment
            rc = iuprocess.run_and_log_program([trac_admin_exe, self.config.projecthome,
                                                "upgrade"],
                                                {}, logger, None, None)
            if rc != 0:
            	raise UserError(errors[ERR_TRAC_DEPLOY])

            # set up Apache + Fastcgi
            if self.config.webserver == "apache-fastcgi" :
                logger.debug("setting up apache fastcgi")
                # trac deploy
                # make fastcgi config file
                rc = iuprocess.run_and_log_program([trac_admin_exe, self.config.projecthome,
                                                    "deploy",
                                                    os.path.join(self.config.projecthome, "www")],
                                                   {}, logger, None, None)
                if rc != 0:
                    raise UserError(errors[ERR_TRAC_DEPLOY])
                fcgi_config_file_path = os.path.join(self.config.additional_config_dir,
                                                     self.config.projectname + ".conf")
                if os.path.exists(fcgi_config_file_path):
                   logger.warn("Apache configuration file already exists. Will be overwritten.")
                httpd_config_string = self.config.get_httpd_config_string([("TRAC_ENV", self.config.projecthome),
                                                                           ("TRAC_ENV_PARENT_DIR",
                                                                            "%s/../" % self.config.projecthome)])
                (tmpf, tmpn) = tempfile.mkstemp()
                os.write(tmpf, httpd_config_string)
                if self.config.protocol == "https":
                       https_config_string = self.config.get_https_config_string()
                       os.write(tmpf, https_config_string)
                os.close(tmpf)
                iuprocess.sudo_copy([tmpn,
                                     fcgi_config_file_path],
                                     sudo_password, logger)

                self._update_and_copy_fcgi_file(sudo_password)

                # make sure the project directory is writeable by apache user
                iuprocess.sudo_chown(self.config.input_ports.webserver.apache_user,
                                     [self.config.projecthome], sudo_password, logger, recursive=True)
                # XXX: hack: need to fix. tracd runs as current user and needs access to log directory
                # but apache does not
                iuprocess.sudo_chown(os.environ["LOGNAME"], [self.config.logdir], sudo_password, logger,
                                     recursive=True)
                logger.debug("Done installing httpd configuration files")
        except iuprocess.SudoError, e:
            exc_info = sys.exc_info()
            sys.exc_clear()
            raise convert_exc_to_user_error(exc_info, errors[ERR_TRAC_SUDO_CALL],
                                            nested_exc_info=e.get_nested_exc_info())