Changeset 143

Show
Ignore:
Timestamp:
08/10/07 13:54:50 (4 years ago)
Author:
trivoallan
Message:

cleverbox :


fixes #2, #10

Location:
cleverbox/trunk
Files:
1 removed
3 modified
1 moved

Legend:

Unmodified
Added
Removed
  • cleverbox/trunk/README

    r141 r143  
    11= Cleverbox = 
     2 
     3[[PageOutline]] 
    24 
    35The Cleverbox sits on top of [http://trac.edgewall.org Trac] and [http://subversion.tigris.org Subversion]. 
     
    68== Features == 
    79 
    8  * Apache configuration templates 
    9  * `trac.ini` configuration templates 
     10 * Configuration profiles : 
     11   * Apache configuration templates 
     12   * `trac.ini` configuration template 
     13   * Default permissions 
    1014 * Easy to setup 
    11  * Easy to use  
     15 * Easy to use 
    1216  
    1317== Prerequisites == 
     
    7983== Advanced usage == 
    8084 
    81 === Customising Apache configuration templates for your needs === 
    82  
    83 When creating a new project, the cleverbox will look for Apache configuration templates in directory referenced by `assets_dir` configuration directive. 
    84  
    85 Provided defaults work out of the box, but you may want to use custom configuration templates.  
    86 You just have to change the value of `assets_dir` configuration directive and the Cleverbox will look for configuration templates in this new directory. 
    87  
    88 The available configuration templates are `apache.conf.single` or `apache.conf.multi` (depending on the value of `vhost_mode` cleverbox directive). 
    89  
    90 At project creation, the selected template's variables are subtituted with concrete values : 
     85=== Creating your own configuration profile === 
     86 
     87The Cleverbox comes with a default set of configuration files. It is located in ``/etc/cleverbox/profiles/default/`. 
     88 
     89When creating a new project, the Cleverbox will ask the user what configuration profile should be used.  
     90It will then look for configuration files in `/etc/cleverbox/profiles/<profile>/` 
     91 
     92The `default` profile works out of the box, but you may want to create your own. 
     93Just copy `/etc/cleverbox/profiles/default/` to `/etc/cleverbox/profiles/<profile>/` and start modifying the files until they fit to your needs. 
     94 
     95A configuration profiles is composed of the following files : 
     96 
     97 * `project.apache.conf` : Apache configuration for a project 
     98 * `trac-defaults.ini` : Overriding of default Trac preferences 
     99 * `permissions.ini` : Default Trac permissions 
     100 
     101Let's see how these files can be customised : 
     102 
     103==== `project.apache.conf` ==== 
     104 
     105This file is used as a basis for creating project's Apache configuration. Resulting file will be stored in `/etc/cleverbox/projects-available/<client>-<project>`. 
     106 
     107At project creation, the file is parsed and variables are substituted with concrete values : 
     108 
    91109 * `client_name` : client's short name 
    92110 * `project_name` : project's short name 
     
    94112 * `authbackend_pass` : password for hypothetical authentication backend (ldap, etc) 
    95113 * `trac_install_dir` : directory where Trac is installed on the server 
    96  * `domain_name` : if in "single" `vhost_mode`, host's domain name 
    97  
    98 === Customising `trac-defaults.ini` configuration for your needs === 
    99  
    100 This file resides in Cleverbox's `assets_dir` directory.  It holds values that will override standard's trac.ini values. 
    101  
    102 For instance, you may want The webadmin plugin to be enabled by default in all new project instances. 
    103 You just have to add these lines to the file : 
    104 {{{ 
    105 [components] 
    106 webadmin.* = enabled 
    107 }}} 
    108  
    109 === Defining defaut permission profiles === 
     114 * `domain_name` : host's domain name 
     115 
     116For instance, here's how the file provided by the `default` profile looks like : 
     117 
     118[[Include(source:cleverbox/trunk/assets/project.apache.conf, text/plain)]] 
     119 
     120==== `trac-defaults.ini` ==== 
     121 
     122This file holds values that will override generated project's standard `trac.ini` values. 
     123 
     124At project creation, the file is parsed and variables are substituted with concrete values : 
     125 
     126 * `client_name` : client's short name 
     127 * `project_name` : project's short name 
     128 * `clients_root` : directory holding Subversion and Trac data for each project 
     129 * `authbackend_pass` : password for hypothetical authentication backend (ldap, etc) 
     130 * `trac_install_dir` : directory where Trac is installed on the server 
     131 * `domain_name` : host's domain name 
     132 
     133For instance, here's how the file provided by the `default` profile looks like : 
     134 
     135[[Include(source:cleverbox/trunk/assets/trac-defaults.ini, text/ini)]] 
     136 
     137It rises the allowed attachment size to 10M and enables ``webadmin` and ``themeengine` plugins by default. 
     138 
     139=== `permissions.ini` === 
    110140 
    111141At project creation, the Cleverbox removes the `anonymous` permission profile and creates new profiles based on the contents of the 
    112 `permissions.ini` file (which resides in `assets_dir` directory). Example file : 
    113 {{{ 
    114 [trac] 
    115 authenticated = BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW TICKET_CREATE TICKET_MODIFY TICKET_VIEW TIMELINE_VIEW WIKI_CREATE WIKI_MODIFY WIKI_VIEW 
    116 privileged = TRAC_ADMIN 
    117 }}} 
     142`permissions.ini`. 
     143 
     144For instance, here's how the file provided by the `default` profile looks like : 
     145 
     146[[Include(source:cleverbox/trunk/assets/permissions.ini, text/ini)]] 
     147 
     148== Design documentation == 
     149 
     150=== The environment directory === 
     151 
     152'''Default directory is `/etc/cleverbox`'''. 
     153 
     154This directory holds configuration information about one Cleverbox environment. It looks like this : 
     155 
     156 * `clients-available` : holds apache configuration available for every client. 
     157 * `clients-enabled` : contains symlinks to files located in the ''clients-available'' dir. Each file located in this directory is loaded at apache startup. 
     158 * `projects-available` : holds apache configuration available for every project. 
     159 * `projects-enabled` : contains symlinks to files located in the ''projects-available'' dir. Each file located in this directory is included by the client's apache configuration file (located in ''clients-available''). 
     160 * `VERSION` : this files contains the version number of the Cleverbox used to initiliaze the environment 
     161 * `cleverbox.ini` : this file holds configuration for the Cleverbox environment  
     162 
     163=== The data directory === 
     164 
     165'''Default directory is `/var/cleverbox`'''. 
     166 
     167Each client has a dedicated project environment. It looks like this : 
     168 
     169{{{ 
     170 |- htdocs 
     171    |- <project> 
     172 |- logs 
     173 |- tmp 
     174 |- uploads 
     175 |- var 
     176    |- svn 
     177       |- <project> 
     178    |- trac 
     179       |- <project> 
     180}}} 
     181 
     182=== The assets directory === 
     183 
     184'''Default directory is `/usr/share/cleverbox/assets`'''. 
     185 
     186It holds the files used to generate the `default` configuration profile when instanciating a new Cleverbox environment. 
     187 
     188Usage and customisation of these files is explained in the "Advanced usage" section above. 
    118189 
    119190== Roadmap == 
    120191 
     192=== Unplanned === 
     193 
     194 * [ticket:3 Integrate import / export capabilities] 
     195 * [ticket:9 More integrty checking] 
     196 
    121197=== 0.4-beta === 
    122198 
    123  * Integrity checks prior to environment initialisation in `ìnitenv` task 
    124  * Better unix rights usage 
    125  * Integration of `cleverbox-backup.sh` script 
     199 * [ticket:1 trac.ini-defaults should be interpolated]  
     200 * [ticket:2 Rework apache templates handling] 
     201 * [ticket:4 Use setuptools over distutils] 
     202 * [ticket:10 Subversion hooks handling] 
    126203 
    127204== Changelog == 
     
    129206=== 2007-08-07 | trunk === 
    130207 
    131  * removed hardcoded paths in apache configuration templates (backported to 0.3) 
     208 * Added documentation about design 
     209 * Removed hardcoded paths in apache configuration templates (backported to 0.3) 
     210 * Rewrote documentation for new "configuration profiles". Tried to make it a bit clearer 
     211 * '''[BC BREAK]''' Implemented "[ticket:2 Rework apache templates handling]" 
     212 * fixed [ticket:10 Subversion hooks handling] : http://trac-hacks.org/wiki/TracSvnHooksPlugin is enabled by default 
    132213 
    133214=== 2007-08-07 | 0.3-beta === 
  • cleverbox/trunk/assets/project.apache.conf

    r140 r143  
    3434  # -- File based authentification 
    3535  # -- Users can be used using : 
    36   # --  htpasswd2 %(clients_root)s/%(client_name)s/var/trac/%(project_name)s/.htusers <username> 
     36  # --  htpasswd %(clients_root)s/%(client_name)s/var/trac/%(project_name)s/.htusers <username> 
    3737  AuthUserFile %(clients_root)s/%(client_name)s/var/trac/%(project_name)s/.htusers 
    3838 
  • cleverbox/trunk/assets/trac-defaults.ini

    r129 r143  
    11[attachment] 
    2 max_size = 25600 
     2max_size = 10485760 
    33 
    44[components] 
    55webadmin.* = enabled 
    66themeengine.* = enabled 
     7svnhooks.svnhooks 
  • cleverbox/trunk/cleverbox/scripts/admin.py

    r133 r143  
    11# -*- coding: utf-8 -*- 
    22 
     3import shutils 
    34import cmd 
    45import os 
     
    1213 
    1314_defaults = { 
    14     'env_dir_layout'       : ('clients-available', 'clients-enabled', 
    15                               'projects-available', 'projects-enabled'), 
     15    'env_dir_layout'    : ('clients-available', 'clients-enabled', 
     16                           'projects-available', 'projects-enabled', 
     17                           'profiles/default'), 
    1618    'client_dir_layout' : ('htdocs', 'logs', 'tmp', 'uploads', 
    1719                           'var/svn', 'var/trac'), 
     20    'profile_files'     : ('project.apache.conf', 'trac-defaults.ini', 'permissions.ini') 
    1821} 
    1922 
     
    133136        collected_infos['apache_group'] = raw_input('Webserver group id [%d]> ' % d_gid).strip() or d_gid 
    134137 
    135         # SSH user & group 
    136         d_uid = '1001' 
    137         d_gid = '1001' 
    138         collected_infos['ssh_user'] = raw_input('SSH user id [%s]> ' % d_uid).strip() or d_uid 
    139         collected_infos['ssh_group'] = raw_input('SSH group id [%s]> ' % d_gid).strip() or d_gid 
    140  
    141         # Virtual Host mode : single or multi ? 
    142         d_vhost_mode = 'single' 
    143         collected_infos['vhost_mode'] = raw_input('Virtual host mode (either "single" or "multi") [%s]> ' % d_vhost_mode).strip() or d_vhost_mode 
     138        # root user & group 
     139        # we keep the ssh_user notion for backward compatibility. 
     140        # this will have to disappear in a future release  
     141        collected_infos['ssh_user'] = 0 
     142        collected_infos['ssh_group'] = 0 
     143 
     144        # Host server domain name 
     145        collected_infos['domain'] = raw_input('Domain name > ').strip() 
    144146         
    145         if collected_infos['vhost_mode'] == 'multi': 
    146             collected_infos['domain'] = raw_input('Domain name > ').strip() 
    147          
    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  
    152147        # Authentication backend password (if any) 
    153148        collected_infos['authbackend_pass'] = raw_input('Authentication backend password (if any) []> ').strip() or '' 
     149 
     150        # Default configuration profile 
     151        dcp = 'default' 
     152        collected_infos['default_profile'] = raw_input('Default configuration profile [%s]> ' % dcp).strip() or dcp 
    154153                 
    155154        # Write ini file 
     
    174173        # Create directory structure 
    175174        try: 
    176             print "\n\tCreating directory structure\n" 
     175            print "\n\tCreating directory layout\n" 
    177176            env_dirs = [] 
    178177            for dirname in _defaults['env_dir_layout']: 
     
    185184        # Create VERSION file 
    186185        try: 
     186            print "\n\tCreating VERSION file\n" 
    187187            fd = open( os.path.join(self.envname, 'VERSION'), 'w' ) 
    188188            fd.write(_version) 
    189189        finally: 
    190190            fd.close() 
     191 
     192        # Default configuration profile 
     193        print "\n\tCreating default configuration profile\n" 
     194        for filename in _defaults['profile_files']: 
     195            shutils.copy('/usr/share/cleverbox/assets/' + filename, os.path.join(self.envname, 'profile', 'default')) 
     196         
    191197 
    192198        print 
     
    695701            collected_infos['full_name'] = raw_input('Full Name [%s]> ' % dfn).strip() or dfn 
    696702 
     703            print 
     704            print "  What configuration profile should be used ?" 
     705            print "  Those reside in %s/profiles/" % self.envname 
     706            print 
     707 
     708            dp = self.getConfig('default_profile', 'general') 
     709            collected_infos['profile'] = raw_input('Configuration profile [%s]> ' % dp).strip() or dp 
     710 
    697711            # Project creation 
    698712            print 
     
    751765        TODO : clients may not be stored in 'clients_root', be careful with that. 
    752766        """ 
    753         conf_template = open('%s/%s.%s' % (self.getConfig('assets_dir', 'general'), 'apache.conf', self.getConfig('vhost_mode', 'general'))) 
     767        conf_template = open(os.path.join(self.envname, 'profiles', infos['profile'], 'project.apache.conf')) 
    754768        conf_data = conf_template.read() % {'client_name'      : infos['client'], 
    755769                                            'project_name'     : infos['short_name'], 
     
    841855        # Grant default permissions 
    842856        perms_config = ConfigParser.SafeConfigParser() 
    843         perms_config.read(os.path.join(self.getConfig('assets_dir', 'general'), 'permissions.ini')) 
     857        perms_config.read(os.path.join(self.envname, 'profiles', infos['profile'], 'permissions.ini')) 
    844858        for profile in perms_config.options('trac'): 
    845859            os.system( trac_perms_cmd % {'env_path'   : trac_env_path, 
     
    868882        chmod g+w /$CLIENTSROOT/$CLIENTNAME/var/svn/$PROJECTNAME 
    869883        chown -R www-data:dev /$CLIENTSROOT/$CLIENTNAME/var/trac/$PROJECTNAME/db 
    870         chown dev:www-data /$CLIENTSROOT/$CLIENTNAME/var/trac/conf/trac.ini 
    871         chmod g+w /$CLIENTSROOT/$CLIENTNAME/var/trac/conf/trac.ini 
     884            chown dev:www-data /$CLIENTSROOT/$CLIENTNAME/var/trac/conf/trac.ini 
     885            chmod g+w /$CLIENTSROOT/$CLIENTNAME/var/trac/conf/trac.ini 
    872886        """ 
    873887 
     
    909923 
    910924    def _project_trac_defaultconf(self, infos): 
     925        """ 
     926        Overrides project's default trac.ini with values provided in configuration profile. 
     927        """ 
     928         
    911929        # New defaults 
    912930        tracdefaults_config = ConfigParser.SafeConfigParser() 
    913         tracdefaults_config.read(os.path.join(self.getConfig('assets_dir', 'general'), 'trac-defaults.ini')) 
     931        tracdefaults_config.read(os.path.join(self.envname, 'profiles', infos['profile'], 'trac-defaults.ini')) 
    914932         
    915933        # Trac base config file 
    916         project_config_path = os.path.join('%s/%s/var/trac/%s/conf/trac.ini' % (self.getConfig('clients_root', 'general'), infos['client'], infos['short_name'])) 
     934        project_config_path = os.path.join(self.getConfig('clients_root', 'general', infos['client'], 'var', 'trac', infos['short_name'], 'conf', 'trac.ini')) 
    917935        tracproject_config = ConfigParser.SafeConfigParser() 
    918936        tracproject_config.read(project_config_path)