Class: Nginx::Builder::Site

Inherits:
Base
  • Object
show all
Defined in:
lib/shared_infrastructure/nginx/builder.rb

Direct Known Subclasses

Rails, SiteHttp, SiteHttps

Instance Attribute Summary

Attributes inherited from Base

#domain, #server_blocks

Instance Method Summary collapse

Methods inherited from Base

#https_reminder_message, #to_s

Constructor Details

#initialize(user, *server_blocks, domain: nil) ⇒ Site

Returns a new instance of Site.



103
104
105
106
# File 'lib/shared_infrastructure/nginx/builder.rb', line 103

def initialize(user, *server_blocks, domain: nil)
  super(*server_blocks, domain: domain)
  @user = user
end

Instance Method Details

#saveObject



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/shared_infrastructure/nginx/builder.rb', line 108

def save
  domain_root = SharedInfrastructure::Output.file_name(domain.root)
  FileUtils.mkdir_p(domain_root)
  if Process.uid.zero?
    FileUtils.chown(user,
      "www-data",
      domain_root)
  end
  # Set the directory gid bit, so files created inside inherit the group.
  File.chmod(File.stat(domain_root).mode | 0o2000, domain_root)
  super
end

#userObject



121
122
123
# File 'lib/shared_infrastructure/nginx/builder.rb', line 121

def user
  @user ||= Etc.getlogin
end