Sha256: bc32da4ff8540fcbcd859371a328c2f290e540acf2e338f5d093d9531705025e

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 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")
      file_name = File.join(Config.apache_conf_dir,Config.server_hostname)
      template.write(file_name)
      enable_site()
      force_reload()
    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'
      puts("Apache reloaded...")
    end
    def enable_site
      # tell apache enable site
      `a2ensite #{Config.server_hostname}` if SUBTRAC_ENV != 'test'
      puts("Apache site enabled...")
    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

8 entries across 8 versions & 1 rubygems

Version Path
ktec-subtrac-0.1.50 lib/subtrac/apache.rb
ktec-subtrac-0.1.51 lib/subtrac/apache.rb
ktec-subtrac-0.1.52 lib/subtrac/apache.rb
ktec-subtrac-0.1.54 lib/subtrac/apache.rb
ktec-subtrac-0.1.55 lib/subtrac/apache.rb
ktec-subtrac-0.1.56 lib/subtrac/apache.rb
ktec-subtrac-0.1.57 lib/subtrac/apache.rb
ktec-subtrac-0.1.58 lib/subtrac/apache.rb