Class: Nginx::Builder::Base
- Inherits:
- 
      Object
      
        - Object
- Nginx::Builder::Base
 
- Defined in:
- lib/shared_infrastructure/nginx/builder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #domain  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute domain. 
- 
  
    
      #server_blocks  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute server_blocks. 
Instance Method Summary collapse
- #https_reminder_message ⇒ Object
- 
  
    
      #initialize(*server_blocks, domain: nil)  ⇒ Base 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Base. 
- #save ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*server_blocks, domain: nil) ⇒ Base
Returns a new instance of Base.
| 37 38 39 40 41 42 | # File 'lib/shared_infrastructure/nginx/builder.rb', line 37 def initialize(*server_blocks, domain: nil) # puts "Base#initialize domain_name: #{domain_name}" # puts "Base#initialize server_blocks.inspect: #{server_blocks.inspect}" @server_blocks = server_blocks @domain = domain end | 
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
| 57 58 59 | # File 'lib/shared_infrastructure/nginx/builder.rb', line 57 def domain @domain end | 
#server_blocks ⇒ Object (readonly)
Returns the value of attribute server_blocks.
| 57 58 59 | # File 'lib/shared_infrastructure/nginx/builder.rb', line 57 def server_blocks @server_blocks end | 
Instance Method Details
#https_reminder_message ⇒ Object
| 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # File 'lib/shared_infrastructure/nginx/builder.rb', line 19 def puts %(You have to obtain a certificate and enable TLS for the site. To do so, reload the Nginx configuration: sudo nginx -s reload Then run the following command: sudo certbot certonly --webroot -w #{Nginx.root_directory(domain.domain_name)} #{domain.certbot_domain_names} You can test renewal with: sudo certbot renew --dry-run Finally, re-run this script to configure nginx for TLS. ) end | 
#save ⇒ Object
| 44 45 46 47 48 49 50 51 | # File 'lib/shared_infrastructure/nginx/builder.rb', line 44 def save puts "writing server block: #{Nginx.server_block_location(domain.domain_name)}" if Runner.debug File.open(Nginx.server_block_location(domain.domain_name), "w") do |f| f << to_s end puts "enabling site" if Runner.debug `ln -fs ../sites-available/#{domain.domain_name} #{Nginx.enabled_server_block_location(domain.domain_name)}` end | 
#to_s ⇒ Object
| 53 54 55 | # File 'lib/shared_infrastructure/nginx/builder.rb', line 53 def to_s server_blocks.map(&:to_s).join("\n") end |