Changeset 466

Show
Ignore:
Timestamp:
05/22/08 11:37:11 (8 months ago)
Author:
mbailey
Message:

trac now installs - still to setup permissions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/deprec/recipes/trac.rb

    r332 r466  
    44         
    55  # Master tracd process for server 
    6   set :tracd_cmd, '/usr/local/bin/tracd' 
     6  set :tracd_cmd, '/usr/bin/tracd' 
    77  set :tracd_port, '9000' 
    88  set :tracd_pidfile, '/var/run/tracd.pid' 
    99   
    1010  # 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   
    1114  set(:trac_backup_dir) { "#{backup_dir}/trac" } 
    1215  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" } 
    1417  set(:trac_password_file)  { "#{trac_path}/conf/users.htdigest" } 
    1518  set(:trac_account) { Capistrano::CLI.prompt('enter new trac user account name') } 
     
    4750  desc "Install trac on server" 
    4851  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 ) 
    6263  end 
    6364   
     
    7374   
    7475  PROJECT_CONFIG_FILES[:trac] = [ 
     76    {:template => 'users.htdigest.erb', 
     77     :path => "conf/users.htdigest", 
     78     :mode => 0644, 
     79     :owner => 'root:root'}, 
     80      
    7581    {:template => 'trac.ini.erb', 
    7682     :path => "conf/trac.ini", 
     
    7884     :owner => 'root:root'}, 
    7985      
    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", 
    8288     :mode => 0644, 
    8389     :owner => 'root:root'} 
     
    106112    config_system 
    107113    config_project 
     114    restart 
     115    top.deprec.nginx.restart 
    108116  end 
    109117   
     
    114122  task :config_project, :roles => :scm do 
    115123    deprec2.push_configs(:trac, PROJECT_CONFIG_FILES[:trac]) 
     124    symlink_nginx_vhost 
    116125  end 
    117126 
    118127  desc "Initialize the trac db for this project" 
    119128  task :setup, :roles => :scm do 
     129    init 
    120130    config_gen_project 
    121131    config_project 
    122     ini
    123     set_default_permissions  
     132    activate_projec
     133    # set_default_permissions  # XXX re-enable this 
    124134    # create trac account for current user  
    125135    set :trac_account, user 
    126136    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 
    129138  end 
    130139   
    131140  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}" 
    133143  end 
    134144   
     
    140150  task :start, :roles => :scm do 
    141151    sudo "/etc/init.d/tracd start" 
    142     sudo "/etc/init.d/httpd restart" 
    143152  end 
    144153 
     
    175184   
    176185  task :deactivate_project, :roles => :scm do 
    177     # XXX unlink project config 
    178     # XXX restart tracd 
     186    unlink_project 
     187    unlink_nginx_vhost 
     188    restart 
    179189  end 
    180190   
     
    229239  # We do this so we can use trac for multiple projects on the same server 
    230240  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}" 
    232242  end 
    233243   
     
    237247  end 
    238248   
    239   task :symlink_apache_vhost, :roles => :scm do 
    240     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 do 
    244     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" 
    245255    sudo "test -h #{link} && unlink #{link} || true" 
    246256  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   
    248267  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     
    252275end end 
    253276