Class: Rsm::Install::Nginx

Inherits:
Base
  • Object
show all
Defined in:
lib/tasks/install/nginx.rb

Constant Summary

Constant Summary

Constants inherited from Base

Base::SERVERS

Constants included from Actions

Actions::TAR_OPTS

Instance Attribute Summary (collapse)

Attributes inherited from Base

#server, #socket_per_worker, #worker_processes

Instance Method Summary (collapse)

Methods inherited from Base

#set_server, #set_worker_processes, source_root, template_path

Methods included from Actions

#application_root, #downloaded_file, #fetch_temporary_archive, #run_ruby_binary, #unpack_compressed_archive

Instance Attribute Details

- (Object) auth_basic (readonly)

Returns the value of attribute auth_basic



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def auth_basic
  @auth_basic
end

- (Object) auth_basic_realm (readonly)

Returns the value of attribute auth_basic_realm



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def auth_basic_realm
  @auth_basic_realm
end

- (Object) auth_basic_user_file (readonly)

Returns the value of attribute auth_basic_user_file



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def auth_basic_user_file
  @auth_basic_user_file
end

- (Object) domain (readonly)

Returns the value of attribute domain



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def domain
  @domain
end

- (Object) rewrite_www (readonly)

Returns the value of attribute rewrite_www



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def rewrite_www
  @rewrite_www
end

- (Object) upstream_name (readonly)

Returns the value of attribute upstream_name



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def upstream_name
  @upstream_name
end

Instance Method Details

- (Object) enable_nginx_site



44
45
46
# File 'lib/tasks/install/nginx.rb', line 44

def enable_nginx_site
  link_file "#{destination_root}/sites-available.d/#{domain}.conf", "sites-enabled.d/#{domain}.conf" unless FileTest.symlink?("#{destination_root}/sites-enabled.d/#{domain}.conf")
end

- (Object) nginx_config_include_vhosts



18
19
20
21
22
23
# File 'lib/tasks/install/nginx.rb', line 18

def nginx_config_include_vhosts
  include_str = "include sites-enabled.d/*.conf;"
  unless File.read("#{destination_root}/nginx.conf").include?(include_str)
    inject_into_file "nginx.conf", "#{include_str}\n", :after => "index index.html;\n"
  end
end

- (Object) nginx_server_config



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tasks/install/nginx.rb', line 25

def nginx_server_config
  @domain = options[:domain]
  unless @domain
    @domain = `hostname -f`.strip
    @domain = "#{name}.#{@domain}"
  end

  @rewrite_www = options[:rewrite_www]

  @auth_basic = options[:auth_basic]
  @auth_basic_realm = options[:auth_basic_realm]
  @auth_basic_realm = name.to_s.capitalize unless @auth_basic_realm
  @auth_basic_user_file = options[:auth_basic_user_file]

  @upstream_name = "#{domain}_server"

  template "nginx-server.conf.erb", "sites-available.d/#{domain}.conf"
end

- (Object) set_destination_root



14
15
16
# File 'lib/tasks/install/nginx.rb', line 14

def set_destination_root
  self.destination_root = options[:nginx_root]
end