This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/pivotal/pivotal_workstation
- Loading branch information
Showing
5 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |