From 1beeda999ef5d093944cebc09baebc8b81069917 Mon Sep 17 00:00:00 2001 From: Sergey Abramchuk Date: Thu, 27 Sep 2018 17:15:51 +0300 Subject: [PATCH] Add remote host and remote port to the profile template --- Scripts/environment.rb.example | 8 ++++++++ Scripts/fill_vpn_profile.rb | 2 ++ Scripts/vpn_profile_template.erb | 11 ++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Scripts/environment.rb.example b/Scripts/environment.rb.example index 957440b..86f6e62 100644 --- a/Scripts/environment.rb.example +++ b/Scripts/environment.rb.example @@ -54,3 +54,11 @@ if ENV["OPENVPN_CONFIGURATION"].nil? END end + +if ENV["OPENVPN_REMOTE_HOST"].nil? + ENV["OPENVPN_REMOTE_HOST"] = "Remote Host Address" +end + +if ENV["OPENVPN_REMOTE_PORT"].nil? + ENV["OPENVPN_REMOTE_PORT"] = "Remote Host Port" +end diff --git a/Scripts/fill_vpn_profile.rb b/Scripts/fill_vpn_profile.rb index d2a9bac..9259968 100644 --- a/Scripts/fill_vpn_profile.rb +++ b/Scripts/fill_vpn_profile.rb @@ -25,6 +25,8 @@ end OPENVPN_USERNAME = ENV["OPENVPN_USERNAME"] OPENVPN_PASSWORD = ENV["OPENVPN_PASSWORD"] OPENVPN_CONFIGURATION = ENV["OPENVPN_CONFIGURATION"] +OPENVPN_REMOTE_HOST = ENV["OPENVPN_REMOTE_HOST"] +OPENVPN_REMOTE_PORT = ENV["OPENVPN_REMOTE_PORT"] template_content = File.read(template_file) erb_template = ERB.new(template_content, nil, ">") diff --git a/Scripts/vpn_profile_template.erb b/Scripts/vpn_profile_template.erb index 6127a9d..4aa7336 100644 --- a/Scripts/vpn_profile_template.erb +++ b/Scripts/vpn_profile_template.erb @@ -9,12 +9,17 @@ import Foundation struct VPNProfile { - static let username = "<%= OPENVPN_USERNAME %>" - static let password = "<%= OPENVPN_PASSWORD %>" - static let configuration = """ + static let username: String = "<%= OPENVPN_USERNAME %>" + static let password: String = "<%= OPENVPN_PASSWORD %>" + + static let configuration: String = """ <% OPENVPN_CONFIGURATION.each_line do |line| %> <%= line %> <% end %> """ + + static let remoteHost: String = "<%= OPENVPN_REMOTE_HOST %>" + static let remotePort: Int = <%= OPENVPN_REMOTE_PORT %> + }