Changeset 466
- Timestamp:
- 05/22/08 11:37:11 (8 months ago)
- Files:
-
- trunk/lib/deprec/recipes/trac.rb (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/deprec/recipes/trac.rb
r332 r466 4 4 5 5 # Master tracd process for server 6 set :tracd_cmd, '/usr/ local/bin/tracd'6 set :tracd_cmd, '/usr/bin/tracd' 7 7 set :tracd_port, '9000' 8 8 set :tracd_pidfile, '/var/run/tracd.pid' 9 9 10 10 # Settings for this projects trac instance 11 set(:tracd_domain_root) { domain.sub(/.*?\./,'') } # strip subdomain from domain 12 set(:tracd_vhost_domain) { "trac-#{application}.#{tracd_domain_root}" } # nginx will proxy this domain to tracd 13 11 14 set(:trac_backup_dir) { "#{backup_dir}/trac" } 12 15 set(:trac_path) { exists?(:deploy_to) ? "#{deploy_to}/trac" : Capistrano::CLI.ui.ask('path to trac config') } 13 set(:tracd_parent_dir) { " #{deploy_to}/../trac/projects" }16 set(:tracd_parent_dir) { "/etc/trac.d" } 14 17 set(:trac_password_file) { "#{trac_path}/conf/users.htdigest" } 15 18 set(:trac_account) { Capistrano::CLI.prompt('enter new trac user account name') } … … 47 50 desc "Install trac on server" 48 51 task :install, :roles => :scm do 49 version = 'trac-0.10.4' 50 set :src_package, { 51 :file => version + '.tar.gz', 52 :md5sum => '52a3a21ad9faafc3b59cbeb87d5a69d2 trac-0.10.4.tar.gz', 53 :dir => version, 54 :url => "http://ftp.edgewall.com/pub/trac/#{version}.tar.gz", 55 :unpack => "tar zxf #{version}.tar.gz;", 56 :install => 'python ./setup.py install --prefix=/usr/local;' 57 } 58 enable_universe 59 apt.install( {:base => %w(build-essential wget python-sqlite sqlite python-clearsilver)}, :stable ) 60 deprec2.download_src(src_package, src_dir) 61 deprec2.install_from_src(src_package, src_dir) 52 install_deps 53 sudo "easy_install Trac==0.11rc1" 54 create_pid_dir 55 create_parent_dir 56 config_gen_system 57 config_system 58 activate_system 59 end 60 61 task :install_deps do 62 apt.install( {:base => %w(sqlite3 python-setuptools python-subversion)}, :stable ) 62 63 end 63 64 … … 73 74 74 75 PROJECT_CONFIG_FILES[:trac] = [ 76 {:template => 'users.htdigest.erb', 77 :path => "conf/users.htdigest", 78 :mode => 0644, 79 :owner => 'root:root'}, 80 75 81 {:template => 'trac.ini.erb', 76 82 :path => "conf/trac.ini", … … 78 84 :owner => 'root:root'}, 79 85 80 {:template => ' apache_vhost.conf.erb',81 :path => "conf/ trac_apache_vhost.conf",86 {:template => 'nginx_vhost.conf.erb', 87 :path => "conf/nginx_vhost.conf", 82 88 :mode => 0644, 83 89 :owner => 'root:root'} … … 106 112 config_system 107 113 config_project 114 restart 115 top.deprec.nginx.restart 108 116 end 109 117 … … 114 122 task :config_project, :roles => :scm do 115 123 deprec2.push_configs(:trac, PROJECT_CONFIG_FILES[:trac]) 124 symlink_nginx_vhost 116 125 end 117 126 118 127 desc "Initialize the trac db for this project" 119 128 task :setup, :roles => :scm do 129 init 120 130 config_gen_project 121 131 config_project 122 init123 set_default_permissions132 activate_project 133 # set_default_permissions # XXX re-enable this 124 134 # create trac account for current user 125 135 set :trac_account, user 126 136 set :trac_passwordfile_exists, false # hack - should check on remote system instead 127 user_add 128 create_pid_dir 137 # user_add # XXX re-enable 129 138 end 130 139 131 140 task :init, :roles => :scm do 132 sudo "trac-admin #{trac_path} initenv #{application} sqlite:db/trac.db svn #{repos_root} /usr/local/share/trac/templates" 141 deprec2.mkdir(trac_path, :via => :sudo) 142 sudo "trac-admin #{trac_path} initenv #{application} sqlite:db/trac.db svn #{repos_root}" 133 143 end 134 144 … … 140 150 task :start, :roles => :scm do 141 151 sudo "/etc/init.d/tracd start" 142 sudo "/etc/init.d/httpd restart"143 152 end 144 153 … … 175 184 176 185 task :deactivate_project, :roles => :scm do 177 # XXX unlink project config 178 # XXX restart tracd 186 unlink_project 187 unlink_nginx_vhost 188 restart 179 189 end 180 190 … … 229 239 # We do this so we can use trac for multiple projects on the same server 230 240 task :symlink_project, :roles => :scm do 231 sudo "ln -sf ../../#{application}/trac#{tracd_parent_dir}/#{application}"241 sudo "ln -sf #{trac_path} #{tracd_parent_dir}/#{application}" 232 242 end 233 243 … … 237 247 end 238 248 239 task :symlink_ apache_vhost, :roles => :scm do240 sudo "ln -sf #{deploy_to}/trac/conf/ trac_apache_vhost.conf #{apache_vhost_dir}/#{application}-trac.conf"241 end 242 243 task :unlink_ apache_vhost, :roles => :scm do244 link = "#{ apache_vhost_dir}/#{application}-trac.conf"249 task :symlink_nginx_vhost, :roles => :scm do 250 sudo "ln -sf #{deploy_to}/trac/conf/nginx_vhost.conf #{nginx_vhost_dir}/tracd-#{application}.conf" 251 end 252 253 task :unlink_nginx_vhost, :roles => :scm do 254 link = "#{nginx_vhost_dir}/tracd-#{application}.conf" 245 255 sudo "test -h #{link} && unlink #{link} || true" 246 256 end 247 257 258 # task :symlink_apache_vhost, :roles => :scm do 259 # sudo "ln -sf #{deploy_to}/trac/conf/trac_apache_vhost.conf #{apache_vhost_dir}/#{application}-trac.conf" 260 # end 261 # 262 # task :unlink_apache_vhost, :roles => :scm do 263 # link = "#{apache_vhost_dir}/#{application}-trac.conf" 264 # sudo "test -h #{link} && unlink #{link} || true" 265 # end 266 248 267 task :create_pid_dir, :roles => :scm do 249 deprec.mkdir(File.dirname(tracd_pidfile)) 250 end 251 268 deprec2.mkdir(File.dirname(tracd_pidfile)) 269 end 270 271 task :create_parent_dir, :roles => :scm do 272 deprec2.mkdir(tracd_parent_dir, :via => :sudo) 273 end 274 252 275 end end 253 276
