Class: Subtrac::Apache

Inherits:
Object
  • Object
show all
Defined in:
lib/subtrac/apache.rb

Instance Method Summary collapse

Constructor Details

#initializeApache

Returns a new instance of Apache.



10
11
12
# File 'lib/subtrac/apache.rb', line 10

def initialize
  
end

Instance Method Details

#create_client(client) ⇒ Object

creates the files necessary for a new client



23
24
25
26
27
28
29
30
# File 'lib/subtrac/apache.rb', line 23

def create_client(client)
  client_config = File.join(Config.locations_dir,"#{Config.client.path}.conf")
  if (!File.exists?(client_config)) then
    template = get_template("location.conf.erb")
    template.write(client_config)
    force_reload()
  end
end

#create_project(project) ⇒ Object



41
42
43
44
# File 'lib/subtrac/apache.rb', line 41

def create_project(project)
  # we dont need to do anything for each project, but we do need to ensure a client location exists
  create_client(project.client)
end

#create_virtual_hostObject



13
14
15
16
17
18
19
20
21
# File 'lib/subtrac/apache.rb', line 13

def create_virtual_host()
  puts "\n==== Creating new virtual host ===="
  # TODO: Place a file in apache2 conf with Include directive which points to our conf folder
  template = get_template("vhost.conf.erb")
  file_name = File.join(Config.apache_conf_dir,Config.server_hostname)
  template.write(file_name)
  enable_site()
  force_reload()
end

#enable_siteObject



36
37
38
39
40
# File 'lib/subtrac/apache.rb', line 36

def enable_site
  # tell apache enable site
  `a2ensite #{Config.server_hostname}` if SUBTRAC_ENV != 'test'
  puts("Apache site enabled...")
end

#force_reloadObject



31
32
33
34
35
# File 'lib/subtrac/apache.rb', line 31

def force_reload
  # reload apache configuration
  `/etc/init.d/apache2 force-reload` if SUBTRAC_ENV != 'test'
  puts("Apache reloaded...")
end

#get_template(name) ⇒ Object



45
46
47
# File 'lib/subtrac/apache.rb', line 45

def get_template(name)
  Template.new(File.join(File.dirname(__FILE__), "apache", name))
end