Changeset 219 for cleverbox

Show
Ignore:
Timestamp:
02/06/08 14:09:34 (4 years ago)
Author:
gperier
Message:

cleverbox :

  • Add Root Group definition to initenv method
Location:
cleverbox/trunk/cleverbox
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • cleverbox/trunk/cleverbox/model/environment.py

    r211 r219  
    1111 
    1212class Environment: 
    13      
     13 
    1414    path = '' 
    15      
     15 
    1616    def __init__(self, envdir): 
    1717        self.path = envdir 
    1818        self.config = ConfigParser.SafeConfigParser() 
    1919        self.config.read(self.get_path('cleverbox.ini')) 
    20      
     20 
    2121    def create(self, version, parameters): 
    2222        """ 
     
    2929           parameters['general']['apache_group'] 
    3030           parameters['general']['clients_root'] 
     31           parameters['general']['root_group'] 
     32 
    3133        except KeyError, e: 
    3234            raise Exception, "Supplied parameters are not complete." 
     35 
    3336 
    3437        # Do not do anything if base directories is not empty 
     
    4144            for (k, v) in section_directives.items(): 
    4245                self.config.set(section_name, k, v) 
    43          
     46 
    4447        # Write all to disk 
    4548        try: 
     
    5356                env_dirs.append(self.get_path(dirname)) 
    5457            map(os.makedirs, env_dirs) 
    55              
     58 
    5659            # Create VERSION file 
    5760            try: 
     
    7679            logging.info("  Creating default configuration profile") 
    7780            print 
    78              
     81 
    7982            for filename in profile_files: 
    8083                shutil.copy( 
     
    8689 
    8790            # Set permissions 
    88             permissions = {self.get_path('VERSION')                               : (0640, 'root', 'www-data'),  
    89                            self.get_path('cleverbox.ini')                         : (0640, 'root', 'www-data'),  
    90                            self.get_path('clients-available')                     : (0750, 'root', 'www-data'),  
    91                            self.get_path('clients-enabled')                       : (0750, 'root', 'www-data'),  
    92                            self.get_path('projects-available')                    : (0750, 'root', 'www-data'),  
    93                            self.get_path('projects-enabled')                      : (0750, 'root', 'www-data'),  
    94                            self.get_path('profiles')                              : (0750, 'root', 'www-data'),  
    95                            self.get_path('profiles/default')                      : (0750, 'root', 'www-data'),  
    96                            self.get_path('profiles/default/trac-defaults.ini')    : (0640, 'root', 'www-data'),  
    97                            self.get_path('profiles/default/project.apache.conf')  : (0640, 'root', 'www-data'),  
    98                            self.get_path('profiles/default/permissions.ini')      : (0640, 'root', 'www-data'), 
    99                            self.config.get('general', 'clients_root')             : (0750, 'root', 'www-data')} 
    100              
     91            permissions = {self.get_path('VERSION')                               : (0640, 'root', self.config.get('general', 'root_group')), 
     92                           self.get_path('cleverbox.ini')                         : (0640, 'root', self.config.get('general', 'root_group')), 
     93                           self.get_path('clients-available')                     : (0750, 'root', self.config.get('general', 'root_group')), 
     94                           self.get_path('clients-enabled')                       : (0750, 'root', self.config.get('general', 'root_group')), 
     95                           self.get_path('projects-available')                    : (0750, 'root', self.config.get('general', 'root_group')), 
     96                           self.get_path('projects-enabled')                      : (0750, 'root', self.config.get('general', 'root_group')), 
     97                           self.get_path('profiles')                              : (0750, 'root', self.config.get('general', 'root_group')), 
     98                           self.get_path('profiles/default')                      : (0750, 'root', self.config.get('general', 'root_group')), 
     99                           self.get_path('profiles/default/trac-defaults.ini')    : (0640, 'root', self.config.get('general', 'root_group')), 
     100                           self.get_path('profiles/default/project.apache.conf')  : (0640, 'root', self.config.get('general', 'root_group')), 
     101                           self.get_path('profiles/default/permissions.ini')      : (0640, 'root', self.config.get('general', 'root_group')), 
     102                           self.config.get('general', 'clients_root')             : (0750, 'root', self.config.get('general', 'root_group'))} 
     103 
    101104            filesystem.set_permissions(permissions) 
    102105 
     
    105108            logging.error("  Environment couldn't be initialized in %(env_dir)s" % {'env_dir' : self.path}) 
    106109            logging.info("   Rolling back changes") 
    107              
     110 
    108111            for entry in os.listdir(self.path): 
    109112                path = os.path.join(self.path, entry) 
     
    112115                else: 
    113116                    os.remove(path) 
    114      
     117 
     118            # we remove clients_root directory 
     119            shutil.rmtree(self.config.get('general', 'clients_root')); 
     120 
     121 
    115122    def needs_upgrade(self, target_version): 
    116123        """ 
     
    118125        """ 
    119126        return parse_version(self.get_version()) < parse_version(target_version) 
    120      
     127 
    121128    def upgrade(self): 
    122129        """ 
     
    133140                break 
    134141            i = i + 1 
    135      
     142 
    136143    def get_version(self): 
    137144        """ 
  • cleverbox/trunk/cleverbox/scripts/admin.py

    r213 r219  
    2727            self.env_set(os.path.abspath(envdir)) 
    2828        self.interactive = False 
    29          
     29 
    3030        # Setup logging 
    3131        screen = logging.StreamHandler(sys.stdout) 
     
    3939 
    4040    def env_set(self, env_path, check_upgrade=True): 
    41          
     41 
    4242        # Load environment 
    4343        self.env = Environment(env_path) 
     
    9494        logging.info("Environment initialisation in %(env_dir)s" % {'env_dir' : self.env.path}) 
    9595 
    96         # Collect local configuration info 
     96        #Collect local configuration info 
    9797        collected_infos = {'general' : {}, 'trac' : {}} 
    9898 
     
    113113        # root user & group 
    114114        # we keep the ssh_user notion for backward compatibility. 
    115         # this will have to disappear in a future release  
     115        # this will have to disappear in a future release 
    116116        collected_infos['general']['ssh_user'] = 'root' 
    117117        collected_infos['general']['ssh_group'] = 'root' 
     
    119119        # Host server domain name 
    120120        collected_infos['general']['domain'] = raw_input('Domain name > ').strip() 
    121          
     121 
    122122        # Authentication backend password (if any) 
    123123        collected_infos['general']['authbackend_pass'] = raw_input('Authentication backend password (if any) []> ').strip() or '' 
     
    126126        dcp = 'default' 
    127127        collected_infos['general']['default_profile'] = raw_input('Default configuration profile [%s]> ' % dcp).strip() or dcp 
    128                  
     128 
    129129        d_lib_dir = '/usr/share/python-support/trac' 
    130130        collected_infos['trac']['lib_dir'] = raw_input('Trac libs directory [%s]> ' % d_lib_dir).strip() or d_lib_dir 
     
    133133        collected_infos['trac']['assets_dir'] = raw_input('Trac assets directory [%s]> ' % d_assets_dir).strip() or d_assets_dir 
    134134 
     135        d_root_gid = 'www-data' 
     136        collected_infos['general']['root_group'] = raw_input('Root group [%s]> ' % d_root_gid).strip() or d_root_gid 
     137 
    135138        # Environment creation 
    136139        self.env.create(cleverbox.version, collected_infos) 
    137          
     140 
    138141        print 
    139142        print termcolors.colorize('', fg='green', opts=('noreset',)) 
     
    145148    _help_upgrade = [('upgrade', 'Executes necessary operation to make environment up to date')] 
    146149    def do_upgrade(self, line=None): 
    147         self.env.upgrade()             
     150        self.env.upgrade() 
    148151 
    149152    ## help 
     
    214217        Displays enabled and disabled clients. 
    215218        ''' 
    216          
     219 
    217220        all_clients = client.get(self.env) 
    218221        if len(all_clients): 
     
    220223            all_clients.sort() 
    221224            en_clients = client.get(self.env, 'enabled') 
    222             dis_clients = client.get(self.env, 'disabled')  
     225            dis_clients = client.get(self.env, 'disabled') 
    223226            for client_name in all_clients: 
    224227                if client_name in en_clients: 
     
    270273        clients = client.get(self.env) 
    271274        clients.sort() 
    272          
     275 
    273276        for client_name in clients: 
    274              
     277 
    275278            all_projects = project.get(self.env, client_name) 
    276279            if not len(all_projects): continue 
    277              
     280 
    278281            all_projects.sort() 
    279                          
     282 
    280283            print styles.style.H1("\n%s :" % client_name) 
    281              
     284 
    282285            enabled_projects = project.get(self.env, client_name, 'enabled') 
    283286            disabled_projects = project.get(self.env, client_name, 'disabled') 
    284287 
    285              
     288 
    286289            for project_name in all_projects: 
    287290                if project_name in enabled_projects: 
     
    291294 
    292295    def _do_project_disable(self, args): 
    293          
     296 
    294297        # Check syntax 
    295298        if not len(args) == 2: 
    296299            self.do_help('project') 
    297300            raise Exception, 'Invalid syntax' 
    298          
     301 
    299302        # Disable project 
    300303        (client_name, project_name) = args 
     
    306309            self.do_help('project') 
    307310            raise Exception, 'Invalid syntax' 
    308              
     311 
    309312        (client_name, project_name) = args 
    310313        project.enable(self.env, client_name, project_name) 
     
    317320        # Extract parameters from command parameters 
    318321        (client_name, project_name) = args 
    319          
     322 
    320323        # Create input specification 
    321324        input_spec = {'full_name' : ('Full name', 'This variable is not used anywhere !', project_name.capitalize()), 
     
    323326                      'enable'    : ('Enable project ?', 'This will make project available on the web.', 'n'), 
    324327                      'tracadmin' : ('Trac administrator', "This user will be granted full privileges on project's Trac instance", project_name + '-admin')} 
    325          
     328 
    326329        # Collect input 
    327330        collected_input = inputcollector.collect(input_spec) 
    328          
     331 
    329332        # Create project 
    330333        project.add(self.env, client_name, project_name, collected_input)