Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 44 lines (36 sloc) 1.134 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
include_recipe "pivotal_workstation::homebrew"
include_recipe "pivotal_workstation::ssl_certificate"

run_unless_marker_file_exists("nginx") do

  execute "uninstall nginx" do
    only_if "brew list | grep nginx"
    command "sudo brew remove nginx"
  end

  brew_install "nginx"

  plist_path = File.expand_path('org.nginx.nginx.plist', File.join('~', 'Library', 'LaunchAgents'))
  if File.exists?(plist_path)
    log "nginx plist found at #{plist_path}"
    execute "unload the plist (shuts down the daemon)" do
      command %'launchctl unload -w #{plist_path}'
      user "root"
    end
  else
    log "Did not find plist at #{plist_path} don't try to unload it"
  end

  launch_agents_path = File.expand_path('.', File.join('~', 'Library', 'LaunchAgents'))
  directory launch_agents_path do
    action :create
    recursive true
    owner WS_USER
  end

  template plist_path do
    source "org.nginx.nginx.plist.erb"
    owner "root"
  end

  execute "start the daemon" do
    command %'sudo launchctl load -w #{plist_path}'
  end
end

template "/usr/local/etc/nginx/nginx.conf" do
  source "nginx.conf.erb"
  owner WS_USER
end
Something went wrong with that request. Please try again.