Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/pivotal/pivotal_workstation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Jan 8, 2013
2 parents 35c0bc8 + 0495c0f commit 06f274b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 8 deletions.
41 changes: 41 additions & 0 deletions providers/sysctl.rb
@@ -0,0 +1,41 @@
action :set do
def sysctl_conf
::File.open("/etc/sysctl.conf").read.split("\n")
rescue Errno::ENOENT
[]
end

def flush_sysctl_conf(settings)
::File.open("/etc/sysctl.conf", "w+") do |file|
file.write(settings.join("\n"))
end
end

def line_contains_name(line, name)
line =~ /^#{name}=/
end

def set_value_in_sysctl(name, value)
changed = false
sysctl = sysctl_conf.map do |line|
if line_contains_name(line, name)
line.gsub!(/=.*/,"=#{value}")
changed = true
end
line
end

sysctl << "#{name}=#{value}" unless changed
flush_sysctl_conf(sysctl)
end

execute "set #{new_resource.name}=#{new_resource.value}" do
command "/usr/sbin/sysctl -w #{new_resource.name}=#{new_resource.value}"
end

ruby_block "setting #{new_resource.name}=#{new_resource.value} in /etc/sysctl.conf" do
block do
set_value_in_sysctl(new_resource.name, new_resource.value)
end
end
end
15 changes: 7 additions & 8 deletions recipes/increase_shared_memory.rb
@@ -1,12 +1,11 @@
# See http://willbryant.net/software/mac_os_x/postgres_initdb_fatal_shared_memory_error_on_leopard

# Make memory setting persist across reboots...
cookbook_file "/etc/sysctl.conf" do
source "sysctl.conf"
mode "0644"
owner "root"
pivotal_workstation_sysctl "increase shared memory allocation size" do
name "kern.sysv.shmall"
value "65536"
end

# ...and also change them for this session.
execute "sysctl -w kern.sysv.shmall=65536"
execute "sysctl -w kern.sysv.shmmax=16777216"
pivotal_workstation_sysctl "increase shared memory max" do
name "kern.sysv.shmmax"
value "16777216"
end
1 change: 1 addition & 0 deletions recipes/meta_pivotal_specifics.rb
Expand Up @@ -12,4 +12,5 @@
include_recipe "pivotal_workstation::screen_sharing_on"
include_recipe "pivotal_workstation::set_screensaver_preferences"
include_recipe "pivotal_workstation::snmpd"
include_recipe "pivotal_workstation::tcp_keepalive"
include_recipe "pivotal_workstation::timemachine_preferences"
9 changes: 9 additions & 0 deletions recipes/tcp_keepalive.rb
@@ -0,0 +1,9 @@
pivotal_workstation_sysctl "send keepalive packets" do
name "net.inet.tcp.always_keepalive"
value "1"
end

pivotal_workstation_sysctl "send keepalive packets every 74.5 seconds" do
name "net.inet.tcp.keepidle"
value "149000"
end
9 changes: 9 additions & 0 deletions resources/sysctl.rb
@@ -0,0 +1,9 @@
actions :set

attribute :name, :kind_of => String, :name_attribute => true
attribute :value, :kind_of => String

def initialize(name, run_context=nil)
super
@action = :set
end

0 comments on commit 06f274b

Please sign in to comment.