This repository has been archived by the owner on Nov 23, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 678
/
default.rb
113 lines (98 loc) · 2.87 KB
/
default.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#
# Cookbook Name:: trac
# Recipe:: default
#
# Copyright 2009, Peter Crossley <peterc@xley.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "apache2"
include_recipe "apache2::mod_rewrite"
include_recipe "apache2::mod_fcgid"
include_recipe "apache2::mod_deflate"
package "trac" do
action :upgrade
end
directory node[:trac][:basedir] do
owner "root"
group "root"
mode 0755
end
directory "#{node[:trac][:basedir]}/cgi-bin" do
owner "root"
group "root"
mode 0755
end
template "trac-fcgi" do
path "#{node[:trac][:basedir]}/cgi-bin/trac.fcgi"
source "trac.fcgi.erb"
owner "root"
group "root"
mode 0755
variables(
:trac_environment => "#{node[:trac][:basedir]}/environment"
)
end
execute "trac-environment" do
command "trac-admin #{node[:trac][:basedir]}/environment initenv '#{node[:trac][:project_name]}' 'sqlite:db/trac.db' svn #{node[:trac][:svn_dir]}"
only_if "/usr/bin/test ! -d #{node[:trac][:basedir]}/environment"
end
directory "#{node[:trac][:basedir]}/environment" do
owner "www-data"
group "www-data"
recursive true
end
execute "trac-owner-change" do
command "chown -Rf www-data:www-data #{node[:trac][:basedir]}/environment"
end
template "trac-ini" do
path "#{node[:trac][:basedir]}/environment/conf/trac.ini"
source "trac.ini.erb"
owner "www-data"
group "www-data"
mode 0775
variables(
:trac_project_desc => node[:trac][:project_description],
:trac_project_name => node[:trac][:project_name],
:trac_mainnav => node[:trac][:mainnav],
:trac_metanav => node[:trac][:metanav],
:trac_url => node[:trac][:vhosts].first,
:trac_svn_branches => node[:trac][:svn_branches],
:trac_svn_tags => node[:trac][:svn_tags],
:trac_svn_repo => node[:trac][:svn_dir]
)
end
template "trac-conf" do
path "/etc/apache2/sites-available/trac.conf"
source "trac.conf.erb"
owner "root"
group "root"
mode 0644
variables(
:trac_dir => node[:trac][:basedir],
:trac_project_name => node[:trac][:project_name],
:trac_required_groups => node[:trac][:required_groups],
:trac_vhosts => node[:trac][:vhosts]
)
end
apache_site "trac.conf"
apache_site "default" do
action :disable
end
# help keep the repo in sync
cron "trac-sync" do
minute "0"
command "trac-admin #{node[:trac][:basedir]}/environment resync"
user "www-data"
only_if do File.exists?("#{node[:trac][:basedir]}/environment") end
end