Changeset 143 for cleverbox/trunk/cleverbox
- Timestamp:
- 08/10/07 13:54:50 (5 years ago)
- Files:
-
- 1 modified
-
cleverbox/trunk/cleverbox/scripts/admin.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cleverbox/trunk/cleverbox/scripts/admin.py
r133 r143 1 1 # -*- coding: utf-8 -*- 2 2 3 import shutils 3 4 import cmd 4 5 import os … … 12 13 13 14 _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'), 16 18 'client_dir_layout' : ('htdocs', 'logs', 'tmp', 'uploads', 17 19 'var/svn', 'var/trac'), 20 'profile_files' : ('project.apache.conf', 'trac-defaults.ini', 'permissions.ini') 18 21 } 19 22 … … 133 136 collected_infos['apache_group'] = raw_input('Webserver group id [%d]> ' % d_gid).strip() or d_gid 134 137 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() 144 146 145 if collected_infos['vhost_mode'] == 'multi':146 collected_infos['domain'] = raw_input('Domain name > ').strip()147 148 # Cleverbox assets149 d_cleverbox_assets = '/usr/share/cleverbox'150 collected_infos['assets_dir'] = raw_input('Cleverbox assets directory [%s]> ' % d_cleverbox_assets).strip() or d_cleverbox_assets151 152 147 # Authentication backend password (if any) 153 148 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 154 153 155 154 # Write ini file … … 174 173 # Create directory structure 175 174 try: 176 print "\n\tCreating directory structure\n"175 print "\n\tCreating directory layout\n" 177 176 env_dirs = [] 178 177 for dirname in _defaults['env_dir_layout']: … … 185 184 # Create VERSION file 186 185 try: 186 print "\n\tCreating VERSION file\n" 187 187 fd = open( os.path.join(self.envname, 'VERSION'), 'w' ) 188 188 fd.write(_version) 189 189 finally: 190 190 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 191 197 192 198 print … … 695 701 collected_infos['full_name'] = raw_input('Full Name [%s]> ' % dfn).strip() or dfn 696 702 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 697 711 # Project creation 698 712 print … … 751 765 TODO : clients may not be stored in 'clients_root', be careful with that. 752 766 """ 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')) 754 768 conf_data = conf_template.read() % {'client_name' : infos['client'], 755 769 'project_name' : infos['short_name'], … … 841 855 # Grant default permissions 842 856 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')) 844 858 for profile in perms_config.options('trac'): 845 859 os.system( trac_perms_cmd % {'env_path' : trac_env_path, … … 868 882 chmod g+w /$CLIENTSROOT/$CLIENTNAME/var/svn/$PROJECTNAME 869 883 chown -R www-data:dev /$CLIENTSROOT/$CLIENTNAME/var/trac/$PROJECTNAME/db 870 chown dev:www-data /$CLIENTSROOT/$CLIENTNAME/var/trac/conf/trac.ini871 chmod g+w /$CLIENTSROOT/$CLIENTNAME/var/trac/conf/trac.ini884 chown dev:www-data /$CLIENTSROOT/$CLIENTNAME/var/trac/conf/trac.ini 885 chmod g+w /$CLIENTSROOT/$CLIENTNAME/var/trac/conf/trac.ini 872 886 """ 873 887 … … 909 923 910 924 def _project_trac_defaultconf(self, infos): 925 """ 926 Overrides project's default trac.ini with values provided in configuration profile. 927 """ 928 911 929 # New defaults 912 930 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')) 914 932 915 933 # 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')) 917 935 tracproject_config = ConfigParser.SafeConfigParser() 918 936 tracproject_config.read(project_config_path)
