Skip to content

Commit

Permalink
Merge pull request #3 from dyoung522/develop
Browse files Browse the repository at this point in the history
Switch to ubuntu/trusty32 to reduce memory footprint
  • Loading branch information
dyoung522 committed Feb 18, 2015
2 parents 37f9120 + 19873fc commit d075bdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
7 changes: 3 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.box = 'ubuntu/trusty32'

config.vm.network :private_network, ip: '192.168.50.100'
config.vm.network :forwarded_port, guest: 3128, host: 3128 # Squid
Expand All @@ -12,19 +12,18 @@ Vagrant.configure(2) do |config|
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
v.name = 'vmproxy'
v.memory = '512'
v.memory = '160'
v.cpus = 1
end

config.vm.provision 'System Configuration', type: 'shell', inline: <<-SHELL
apt-get update
apt-get -y upgrade
apt-get -y autoremove
apt-get -y install openconnect
apt-get -y install nginx
SHELL

config.vm.provision 'Proxy Server', type: 'chef_solo' do |chef|
chef.install = false
chef.add_recipe "squid"
end

Expand Down
24 changes: 13 additions & 11 deletions scripts/build_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
begin
proxy_options = YAML.load_file '/vagrant/proxy.yml'
rescue Psych::SyntaxError
STDERR.puts 'Syntax error in proxy.yml, please check and try again'
exit 1
abort 'Syntax error in proxy.yml, please check and try again'
rescue Errno::ENOENT
STDERR.puts 'Please copy proxy.yml.example to proxy.yml and modify it for your needs'
exit 1
abort 'Please copy proxy.yml.example to proxy.yml and modify it for your needs'
end

# Set static variable
Expand All @@ -27,15 +25,19 @@
end

# Create the PAC file
File.open(OUTPUT_FILE, 'w') do |file|
file.puts "// This file was auto-generated by #{$0} at #{Time.now}"
file.puts 'function FindProxyForURL(url, host) {'
begin
File.open(OUTPUT_FILE, 'w') do |file|
file.puts "// This file was auto-generated by #{$0} at #{Time.now}"
file.puts 'function FindProxyForURL(url, host) {'

file.printf "if (%s) %s\n", proxies[0], PROXY_DIRECT unless proxies[0].empty?
file.printf "if (%s) %s\n", proxies[1], PROXY_PROXY unless proxies[1].empty?
file.printf "if (%s) %s\n", proxies[0], PROXY_DIRECT unless proxies[0].empty?
file.printf "if (%s) %s\n", proxies[1], PROXY_PROXY unless proxies[1].empty?

file.puts proxy_options['default'] =~ /proxy/i ? PROXY_PROXY : PROXY_DIRECT
file.puts '};'
file.puts proxy_options['default'] =~ /proxy/i ? PROXY_PROXY : PROXY_DIRECT
file.puts '};'
end
rescue Errno::ENOENT
abort "Unable to open #{OUTPUT_FILE}"
end

puts 'proxy.pac created successfully'

0 comments on commit d075bdd

Please sign in to comment.