From 1e8496aae5c8b95bbe049c158bdb27d9ff8eec7f Mon Sep 17 00:00:00 2001 From: Sergey Abramchuk Date: Thu, 27 Sep 2018 16:41:48 +0300 Subject: [PATCH] Implement ruby script to fill VPN profile --- Scripts/fill_vpn_profile.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Scripts/fill_vpn_profile.rb diff --git a/Scripts/fill_vpn_profile.rb b/Scripts/fill_vpn_profile.rb new file mode 100644 index 0000000..d2a9bac --- /dev/null +++ b/Scripts/fill_vpn_profile.rb @@ -0,0 +1,33 @@ +environment_file = File.join(ENV["SRCROOT"], "Scripts", "environment.rb") +if File.exist?(environment_file) + require "#{environment_file}" +end + +require "erb" + +if ENV["OPENVPN_USERNAME"].nil? || ENV["OPENVPN_PASSWORD"].nil? || ENV["OPENVPN_CONFIGURATION"].nil? + puts "warning: VPN profile data is missing, you need to fill VPNProfile.swift manually." + exit(true) +end + +template_file = File.join(ENV["SRCROOT"], "Scripts", "vpn_profile_template.erb") +unless File.exist?(template_file) + puts "error: Template file does not exist." + exit(false) +end + +output_file = File.join(ENV["SRCROOT"], "Tests", "VPNProfile.swift") +unless File.exist?(output_file) + puts "error: Output file does not exist." + exit(false) +end + +OPENVPN_USERNAME = ENV["OPENVPN_USERNAME"] +OPENVPN_PASSWORD = ENV["OPENVPN_PASSWORD"] +OPENVPN_CONFIGURATION = ENV["OPENVPN_CONFIGURATION"] + +template_content = File.read(template_file) +erb_template = ERB.new(template_content, nil, ">") + +result = erb_template.result +File.write(output_file, result)