Skip to content

Commit

Permalink
improves domain model and adds vhost prefix in yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Bettina Steger committed Jun 2, 2010
1 parent bfeefc5 commit 06559c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
38 changes: 12 additions & 26 deletions app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,31 @@ def write_config
servername = self.fqdn
serveralias = "www." + servername
email = self.user.email
path = WWW_DIR + '/' + self.mount_point
path = File.join(WWW_DIR,self.mount_point)
php = self.php
rails = self.rails

vhost_template = ERB.new(read_template('apache2_vhost.conf')).result(binding)
index_template = ERB.new(read_template('index.html')).result(binding)

Dir.chdir(VHOST_TARGET_DIR) #definend in config/initializers/gccp.rb

File.open('gccp_' + servername, "w") do |f|
File.open(File.join(VHOST_TARGET_DIR,VHOST_PREFIX + servername), "w") do |f|
f.write(vhost_template)
end
system("a2ensite gccp_#{servername}")
system("/etc/init.d/apache2 reload")

Dir.mkdir(WWW_DIR + folder)
Dir.chdir(WWW_DIR + folder)

if rails
#adduser deploy
#gem install mongrel_cluster
#a2enmod rewrite
#a2enmod proxy
#a2enmod proxy_http
#a2enmod proxy_balancer
system("chown deploy:deploy #{WWW_DIR + folder}")
system("mkdir -p current/public")
system("echo 'hello world' > current/public/index.html")
Dir.mkdir("/etc/mongrel_cluster")
system("chown deploy:deploy /etc/mongrel_cluster")
end
Dir.mkdir(path) unless File.exists?(path)

indexfile = "index.html"
indexfile = "index.php" if php
indexfile = File.join(path, "index.html")
indexfile = File.join(path, "index.php") if php

File.open(indexfile, "w") do |f|
f.write(index_template)
unless File.exists?(indexfile)
File.open(indexfile, "w") do |f|
f.write(index_template)
end
end

system("a2ensite #{VHOST_PREFIX+servername}")
system("/etc/init.d/apache2 reload")

rescue Errno::ENOENT
puts "No such directory"
end
Expand Down
1 change: 1 addition & 0 deletions config/gccp.yml-dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
config:
vhost_target_dir: /etc/apache2/sites-available
www_dir: /var/www
vhost_prefix: gccp_

firstadmin:
name: admin
Expand Down
1 change: 1 addition & 0 deletions config/initializers/gccp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
config = YAML.load_file("#{RAILS_ROOT}/config/gccp.yml")
VHOST_TARGET_DIR = config["config"]["vhost_target_dir"]
WWW_DIR = config["config"]["www_dir"]
VHOST_PREFIX = config["config"]["vhost_prefix"]

0 comments on commit 06559c5

Please sign in to comment.