files/aerobase-cookbooks/aerobase/libraries/unifiedpush.rb
# guards against creating secrets on non-bootstrap node
guards against creating secrets on non-bootstrap node
guards against creating secrets on non - bootstrap node
def parse_external_url
      return unless external_url
      uri = URI(external_url.to_s)
      unless uri.host
        raise "Aerobase external URL must include a schema and FQDN, e.g. http://aerobase.example.com/"
      end
      info("Installing according to external_url -> " + uri.host)
      Unifiedpush['global']['fqdn'] = external_url.to_s
      Unifiedpush['global']['top_domain'] = DomainHelper.new(node).parse_domain(uri.host)
      Unifiedpush['global']['access_port'] = uri.port
      config_dir = node['package']['config-dir']
      case uri.scheme
      when "http"
        server_https = false
      when "https"
        server_https = true
        Unifiedpush['nginx']['ssl_certificate'] ||= "#{config_dir}/ssl/#{uri.host}.crt"
        Unifiedpush['nginx']['ssl_certificate_key'] ||= "#{config_dir}/ssl/#{uri.host}.key"
      else
        raise "Unsupported external URL scheme: #{uri.scheme}"
      end
      [
        [%w{aerobase_server server_host}, %W{#{uri.host}}],
        [%w{aerobase_server server_https}, [server_https]]
      ].each do |left, right|
        if Unifiedpush[left.first][left.last].nil?
          Unifiedpush[left.first][left.last] = right.first
        end
      end
      Unifiedpush['aerobase_server']['webapp_host'] = Unifiedpush['global']['top_domain']
      unless ["", "/"].include?(uri.path)
        raise "Unsupported external URL path: #{uri.path}"
      end
    end
def parse_external_url return unless external_url uri = URI ( external_url . to_s ) unless uri . host raise "Aerobase external URL must include a schema and FQDN, e.g. http://aerobase.example.com/" end info ( "Installing according to external_url -> " + uri . host ) Unifiedpush [ 'global' ] [ 'fqdn' ] = external_url . to_s Unifiedpush [ 'global' ] [ 'top_domain' ] = DomainHelper . new ( node ) . parse_domain ( uri . host ) Unifiedpush [ 'global' ] [ 'access_port' ] = uri . port config_dir = node [ 'package' ] [ 'config-dir' ] case uri . scheme when "http" server_https = false when "https" server_https = true Unifiedpush [ 'nginx' ] [ 'ssl_certificate' ] ||= "#{config_dir}/ssl/#{uri.host}.crt" Unifiedpush [ 'nginx' ] [ 'ssl_certificate_key' ] ||= "#{config_dir}/ssl/#{uri.host}.key" else raise "Unsupported external URL scheme: #{uri.scheme}" end [ [ %w{ aerobase_server server_host } , %W{ #{ uri . host } } ] , [ %w{ aerobase_server server_https } , [ server_https ] ] ] . each do | left , right | if Unifiedpush [ left . first ] [ left . last ] . nil? Unifiedpush [ left . first ] [ left . last ] = right . first end end Unifiedpush [ 'aerobase_server' ] [ 'webapp_host' ] = Unifiedpush [ 'global' ] [ 'top_domain' ] unless [ "" , "/" ] . include? ( uri . path ) raise "Unsupported external URL path: #{uri.path}" end end
guards against creating secrets on non-bootstrap node
guards against creating secrets on non - bootstrap node
# access_port is derived from external url  # %w{aerobase_server server_host} corresponds to # Unifiedpush['aerobase_server']['server_host'], etc. # Only If the user does not explicitly sets a value for e.g.