##// END OF EJS Templates
change owner rights to work with mod_perl authentication. add a test option that just connect to WS and say what should be done...
Nicolas Chuche -
r898:d6e8121ef1bd
parent child
Show More
@@ -37,6 +37,8
37 # -u file:///var/svn/ # if the repository is local
37 # -u file:///var/svn/ # if the repository is local
38 # if this option isn't set, reposman won't register the repository
38 # if this option isn't set, reposman won't register the repository
39 #
39 #
40 # -t, --test
41 # only show what should be done
40 #
42 #
41 # -h, --help:
43 # -h, --help:
42 # show help and exit
44 # show help and exit
@@ -64,6 +66,7 opts = GetoptLong.new(
64 ['--redmine-host', '-r', GetoptLong::REQUIRED_ARGUMENT],
66 ['--redmine-host', '-r', GetoptLong::REQUIRED_ARGUMENT],
65 ['--owner', '-o', GetoptLong::REQUIRED_ARGUMENT],
67 ['--owner', '-o', GetoptLong::REQUIRED_ARGUMENT],
66 ['--url', '-u', GetoptLong::REQUIRED_ARGUMENT],
68 ['--url', '-u', GetoptLong::REQUIRED_ARGUMENT],
69 ['--test', '-t', GetoptLong::NO_ARGUMENT],
67 ['--verbose', '-v', GetoptLong::NO_ARGUMENT],
70 ['--verbose', '-v', GetoptLong::NO_ARGUMENT],
68 ['--version', '-V', GetoptLong::NO_ARGUMENT],
71 ['--version', '-V', GetoptLong::NO_ARGUMENT],
69 ['--help' , '-h', GetoptLong::NO_ARGUMENT],
72 ['--help' , '-h', GetoptLong::NO_ARGUMENT],
@@ -76,6 +79,7 $redmine_host = ''
76 $repos_base = ''
79 $repos_base = ''
77 $svn_owner = 'root'
80 $svn_owner = 'root'
78 $svn_url = false
81 $svn_url = false
82 $test = false
79
83
80 def log(text,level=0, exit=false)
84 def log(text,level=0, exit=false)
81 return if $quiet or level > $verbose
85 return if $quiet or level > $verbose
@@ -91,6 +95,7 begin
91 when '--owner'; $svn_owner = arg.dup
95 when '--owner'; $svn_owner = arg.dup
92 when '--url'; $svn_url = arg.dup
96 when '--url'; $svn_url = arg.dup
93 when '--verbose'; $verbose += 1
97 when '--verbose'; $verbose += 1
98 when '--test'; $test = true
94 when '--version'; puts Version; exit
99 when '--version'; puts Version; exit
95 when '--help'; RDoc::usage
100 when '--help'; RDoc::usage
96 when '--quiet'; $quiet = true
101 when '--quiet'; $quiet = true
@@ -100,6 +105,10 rescue
100 exit 1
105 exit 1
101 end
106 end
102
107
108 if $test
109 log("running in test mode")
110 end
111
103 $svn_url += "/" if $svn_url and not $svn_url.match(/\/$/)
112 $svn_url += "/" if $svn_url and not $svn_url.match(/\/$/)
104
113
105 if ($redmine_host.empty? or $repos_base.empty?)
114 if ($redmine_host.empty? or $repos_base.empty?)
@@ -136,7 +145,7 def set_owner_and_rights(project, repos_path, &block)
136 yield if block_given?
145 yield if block_given?
137 else
146 else
138 uid, gid = Etc.getpwnam($svn_owner).uid, Etc.getgrnam(project.identifier).gid
147 uid, gid = Etc.getpwnam($svn_owner).uid, Etc.getgrnam(project.identifier).gid
139 right = project.is_public ? 0575 : 0570
148 right = project.is_public ? 0775 : 0770
140 yield if block_given?
149 yield if block_given?
141 Find.find(repos_path) do |f|
150 Find.find(repos_path) do |f|
142 File.chmod right, f
151 File.chmod right, f
@@ -176,6 +185,11 projects.each do |project|
176 owner = owner_name(repos_path)
185 owner = owner_name(repos_path)
177 next if project.is_public == other_read and owner == $svn_owner
186 next if project.is_public == other_read and owner == $svn_owner
178
187
188 if $test
189 log("\tchange mode on #{repos_path}")
190 next
191 end
192
179 begin
193 begin
180 set_owner_and_rights(project, repos_path)
194 set_owner_and_rights(project, repos_path)
181 rescue Errno::EPERM => e
195 rescue Errno::EPERM => e
@@ -186,7 +200,13 projects.each do |project|
186 log("\tmode change on #{repos_path}");
200 log("\tmode change on #{repos_path}");
187
201
188 else
202 else
189 project.is_public ? File.umask(0202) : File.umask(0207)
203 project.is_public ? File.umask(0002) : File.umask(0007)
204
205 if $test
206 log("\tcreate repository #{repos_path}")
207 log("\trepository #{repos_path} registered in Redmine with url #{$svn_url}#{project.identifier}") if $svn_url;
208 next
209 end
190
210
191 begin
211 begin
192 set_owner_and_rights(project, repos_path) do
212 set_owner_and_rights(project, repos_path) do
General Comments 0
You need to be logged in to leave comments. Login now