Skip to content

Instantly share code, notes, and snippets.

@russss
Created May 31, 2011 16:46
Show Gist options
  • Save russss/1000854 to your computer and use it in GitHub Desktop.
Save russss/1000854 to your computer and use it in GitHub Desktop.
Easily generate a .tblk Tunnelblick package
#!/usr/bin/env ruby
require 'fileutils'
CA_DIR = '/path/to/ca/keys/'
HOST = '1.2.3.4'
if not ARGV[0]:
raise "Provide a certificate name as an argument"
end
files = ["#{ARGV[0]}.key", "#{ARGV[0]}.crt", "ca.crt", "ta.key"]
files.each do |file|
if not File.exists?("#{CA_DIR}/#{file}"):
raise "File #{file} does not exist"
end
end
dir = "#{ARGV[0]}.tblk"
if File.directory?(dir):
raise "Directory #{dir} exists"
end
FileUtils.mkdir_p("#{dir}/Contents/Resources")
files.each do |file|
FileUtils.copy("#{CA_DIR}/#{file}", "#{dir}/Contents/Resources/#{file}")
end
config = %{
client
dev tun
proto udp
remote #{HOST} 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert #{ARGV[0]}.crt
key #{ARGV[0]}.key
ns-cert-type server
tls-auth ta.key 1
cipher AES-256-CBC
comp-lzo
verb 3
}
File.open("#{dir}/Contents/Resources/config.ovpn", 'w') do |f|
f.write(config)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment