Sha256: d169ca4af3357bc0531f4dd4336ec7fcbe2ca0ef9da42f05b958a01bbbb3b8ec

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

#!/usr/bin/env ruby
# Copyright (c) 2009, Keith Salisbury (www.globalkeith.com)
# All rights reserved.
# All the apache stuff should go in here...

require 'subtrac/template'

module Subtrac
  class Apache
    def initialize
      
    end
    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")
      template.write(File.join(Config.apache_conf_dir,Config.server_hostname))
      puts("template written")
      enable_site()
      puts("enabled site")
      force_reload()
      puts("apache reloaded")
    end
    # creates the files necessary for a new client
    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
    def force_reload
      # reload apache configuration
      `/etc/init.d/apache2 force-reload` if SUBTRAC_ENV != 'test'
    end
    def enable_site
      # tell apache enable site
      `a2ensite #{Config.server_hostname}` if SUBTRAC_ENV != 'test'
    end
    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
    def get_template(name)
      Template.new(File.join(File.dirname(__FILE__), "apache", name))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ktec-subtrac-0.1.44 lib/subtrac/apache.rb
ktec-subtrac-0.1.45 lib/subtrac/apache.rb
ktec-subtrac-0.1.46 lib/subtrac/apache.rb
ktec-subtrac-0.1.47 lib/subtrac/apache.rb
ktec-subtrac-0.1.48 lib/subtrac/apache.rb
ktec-subtrac-0.1.49 lib/subtrac/apache.rb