Show
Ignore:
Timestamp:
07/26/07 12:24:34 (5 years ago)
Author:
trivoallan
Message:

cleverbox : templates for apache configuration files.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cleverbox/trunk/cleverbox/scripts/admin.py

    r123 r124  
    146146            collected_infos['domain'] = raw_input('Domain name > ').strip() 
    147147         
     148        # Cleverbox assets 
     149        d_cleverbox_assets = '/usr/share/cleverbox' 
     150        collected_infos['assets_dir'] = raw_input('Cleverbox assets directory [%s]> ' % d_cleverbox_assets).strip() or d_cleverbox_assets 
     151 
     152         
    148153        # Write ini file 
    149154        self._config.add_section('general') 
     
    153158        trac_infos = {} 
    154159        d_lib_dir = '/usr/share/python-support/trac' 
    155         trac_infos['lib_dir'] = raw_input('Trac libs dir [%s]> ' % d_lib_dir).strip() or d_lib_dir 
     160        trac_infos['lib_dir'] = raw_input('Trac libs directory [%s]> ' % d_lib_dir).strip() or d_lib_dir 
    156161 
    157162        d_assets_dir = '/usr/share/trac' 
    158         trac_infos['assets_dir'] = raw_input('Trac assets dir [%s]> ' % d_assets_dir).strip() or d_assets_dir 
     163        trac_infos['assets_dir'] = raw_input('Trac assets directory [%s]> ' % d_assets_dir).strip() or d_assets_dir 
    159164 
    160165        self._config.add_section('trac') 
     
    741746        TODO : clients may not be stored in 'clients_root', be careful with that. 
    742747        """ 
    743         conf_data = getattr(self, '_project_apache_conf_' + self.getConfig('vhost_mode', 'general')).__call__() % {'client_name'  : infos['client'], 
    744                                                                                                                   'project_name' : infos['short_name'], 
    745                                                                                                                   'clients_root' : self.getConfig('clients_root', 'general'), 
    746                                                                                                                   'ldap_password'    : self.getConfig('ldap_password', 'general'), 
    747                                                                                                                   'trac_install_dir' : self.getConfig('lib_dir', 'trac'), 
    748                                                                                                                   'domain_name'      : self.getConfig('domain', 'general')} 
     748        conf_template = open('%s/%s.%s' % (self.getConfig('assets_dir', 'general'), 'apache.conf', self.getConfig('vhost_mode', 'general'))) 
     749        conf_data = conf_template.read() % {'client_name'      : infos['client'], 
     750                                            'project_name'     : infos['short_name'], 
     751                                            'clients_root'     : self.getConfig('clients_root', 'general'), 
     752                                            'ldap_password'    : self.getConfig('ldap_password', 'general'), 
     753                                            'trac_install_dir' : self.getConfig('lib_dir', 'trac'), 
     754                                            'domain_name'      : self.getConfig('domain', 'general')} 
    749755 
    750756        apache_conf_filepath = os.path.join( self.envname, 'projects-available', '%s-%s' % (infos['client'], infos['short_name']) ) 
     
    754760 
    755761        print "  Apache configuration written to %s\n" % apache_conf_filepath 
    756  
    757     def _project_apache_conf_single(self): 
    758         return """ 
    759 # 
    760 # Client  : %(client_name)s 
    761 # Project : %(project_name)s 
    762 # 
    763  
    764 # -- Subversion 
    765 <Location /%(client_name)s/%(project_name)s/svn> 
    766   DAV svn 
    767   SVNPath %(clients_root)s/%(client_name)s/var/svn/%(project_name)s 
    768   AuthType Basic 
    769   AuthName \"%(client_name)s :: %(project_name)s :: SVN\" 
    770  
    771   # -- File based authentification 
    772   AuthUserFile %(clients_root)s/%(client_name)s/var/svn/%(project_name)s/.htusers 
    773  
    774   require valid-user 
    775 </Location> 
    776  
    777 # -- Trac 
    778 <Location /%(client_name)s/%(project_name)s/trac> 
    779   SetHandler mod_python 
    780   PythonPath "['%(trac_install_dir)s'] + sys.path" 
    781   PythonHandler trac.web.modpython_frontend 
    782   PythonOption TracEnv %(clients_root)s/%(client_name)s/var/trac/%(project_name)s 
    783   PythonOption TracUriRoot /%(client_name)s/%(project_name)s/trac 
    784   SetEnv PYTHON_EGG_CACHE %(clients_root)s/%(client_name)s/tmp 
    785 </Location> 
    786  
    787 # Note : the match against "timeline" is needed to provide authenticated RSS feeds (see http://lab.clever-age.net/ticket/35) 
    788 <LocationMatch /%(client_name)s/%(project_name)s/trac/(login|timeline)> 
    789   AuthType Basic 
    790   AuthName \"%(client_name)s :: %(project_name)s :: Trac\" 
    791  
    792   # -- File based authentification 
    793   # -- Users can be used using : 
    794   # --  htpasswd2 %(clients_root)s/%(client_name)s/var/trac/%(project_name)s/.htusers <username> 
    795   AuthUserFile %(clients_root)s/%(client_name)s/var/trac/%(project_name)s/.htusers 
    796  
    797   Require valid-user 
    798 </LocationMatch> 
    799  
    800 # -- Files under src/ will be available on the web 
    801 AliasMatch /%(client_name)s/%(project_name)s/src(.*) /home/%(client_name)s/htdocs/%(project_name)s$1 
    802 """ 
    803  
    804     def _project_apache_conf_multi(self): 
    805         return """ 
    806 # 
    807 # Client  : %(client_name)s 
    808 # Project : %(project_name)s 
    809 # 
    810 <VirtualHost *> 
    811  
    812   # -- Virtual host general configuration 
    813   ServerName %(client_name)s-%(project_name)s.%(domain_name)s 
    814  
    815   # -- Subversion 
    816   <Location /%(project_name)s/svn> 
    817     DAV svn 
    818     SVNPath %(clients_root)s/%(client_name)s/var/svn/%(project_name)s 
    819     AuthType Basic 
    820     AuthName \"%(client_name)s :: %(project_name)s :: SVN\" 
    821  
    822     # -- File based authentification 
    823     AuthUserFile %(clients_root)s/%(client_name)s/var/svn/%(project_name)s/.htusers 
    824  
    825     require valid-user 
    826   </Location> 
    827  
    828   # -- Trac 
    829   <Location /%(project_name)s/trac> 
    830     SetHandler mod_python 
    831     PythonPath "['%(trac_install_dir)s'] + sys.path" 
    832     PythonHandler trac.web.modpython_frontend 
    833     PythonOption TracEnv %(clients_root)s/%(client_name)s/var/trac/%(project_name)s 
    834     PythonOption TracUriRoot /%(project_name)s/trac 
    835     SetEnv PYTHON_EGG_CACHE %(clients_root)s/%(client_name)s/tmp 
    836   </Location> 
    837  
    838   # Note : the match against "timeline" is needed to provide authenticated RSS feeds (see http://lab.clever-age.net/ticket/35) 
    839   <LocationMatch /%(project_name)s/trac/(login|timeline)> 
    840     AuthType Basic 
    841     AuthName \"%(client_name)s :: %(project_name)s :: Trac\" 
    842  
    843     # -- File based authentification 
    844     # -- Users can be used using : 
    845     # --  htpasswd2 %(clients_root)s/%(client_name)s/var/trac/%(project_name)s/.htusers <username> 
    846     AuthUserFile %(clients_root)s/%(client_name)s/var/trac/%(project_name)s/.htusers 
    847  
    848     Require valid-user 
    849   </LocationMatch> 
    850  
    851   # -- Files under src/ will be available on the web 
    852   AliasMatch /%(project_name)s/src(.*) /home/%(client_name)s/htdocs/%(project_name)s$1 
    853 </VirtualHost> 
    854 """ 
    855762 
    856763    def _project_create_svn_repos(self, infos):