Wrap text
Report abuse
|
|
class AddProject
#Defines Path to Save Configuration Files
writepath = "/etc/apache2/projects/"
#Defines Authorization File
authfile = "/etc/apache2/authfile"
#Defines Base SVN Path
basesvn = "/var/svn/"
#Defines Base Trac Path
basetrac = "/var/lib/trac/"
print "Project Name "
while projectname = STDIN.gets
projectname.chop!
break
end
print "Project Directory Name "
while projectshortname = STDIN.gets
projectshortname.chop!
break
end
puts ""
puts ""
puts "Project Name = " + projectname
puts "Project Short Name = " + projectshortname
puts "SVN Path = " + basesvn + projectshortname
puts "Trac Path = " + basetrac + projectshortname
puts ""
print "Write File #{writepath}#{projectshortname}.conf? "
while answer = STDIN.gets
answer.chop!
if answer == "y" or answer == "Y"
puts "WRITING FILES ;)"
myfile = File.new(writepath + projectshortname + ".conf", "w")
myfile.puts ""
myfile.puts " SSLRequireSSL"
myfile.puts " AuthType Basic"
myfile.puts " AuthName \"#{projectname} Subversion Repository\""
myfile.puts " AuthUserFile #{authfile}"
myfile.puts " Require valid-user"
myfile.puts " DAV svn"
myfile.puts " SVNPath #{basesvn}#{projectshortname}"
myfile.puts ""
myfile.puts ""
myfile.puts "ScriptAlias /#{projectshortname} /var/www/localhost/cgi-bin/trac.fcgi"
myfile.puts ""
myfile.puts " SSLRequireSSL"
myfile.puts " AuthType Basic"
myfile.puts " AuthName \"#{projectname} Trac\""
myfile.puts " AuthUserFile #{authfile}"
myfile.puts " Require valid-user"
myfile.puts " SetEnv TRAC_ENV \"#{basetrac}#{projectshortname}\""
myfile.puts ""
myfile.close
puts "Creating Subversion Repository"
system("svnadmin create #{basesvn}#{projectshortname}")
puts "Apache should own it!"
system("chown -R apache #{basesvn}#{projectshortname}")
system("chgrp -R apache #{basesvn}#{projectshortname}")
puts "Trac Env Init, set svn path to /var/svn/#{projectshortname}"
system("trac-admin #{basetrac}#{projectshortname} initenv")
puts "Set Apache as Owner/Group"
system("chown -R apache #{basetrac}#{projectshortname}")
system("chgrp -R apache #{basetrac}#{projectshortname}")
break
else
puts "ABORTING"
break
end
end
end
|