Class: OsxProvision

Inherits:
GenericProvision show all
Defined in:
lib/osx_provision/version.rb,
lib/osx_provision/osx_provision.rb

Constant Summary collapse

VERSION =
"0.9.6"
USER_LOCAL_BIN =
"/usr/local/bin"

Instance Attribute Summary

Attributes inherited from GenericProvision

#env, #interpolator, #script_list, #server_info

Instance Method Summary collapse

Constructor Details

#initialize(parent_class, config_file_name = ".osx_provision.json", scripts_file_names = []) ⇒ OsxProvision

Returns a new instance of OsxProvision.



6
7
8
9
10
# File 'lib/osx_provision/osx_provision.rb', line 6

def initialize parent_class, config_file_name=".osx_provision.json", scripts_file_names=[]
  scripts_file_names.unshift(File.expand_path("osx_provision_scripts.sh", File.dirname(__FILE__))) # make it first

  super
end

Instance Method Details

#brewObject



18
19
20
21
22
23
24
25
26
# File 'lib/osx_provision/osx_provision.rb', line 18

def brew
  installed = package_installed("#{USER_LOCAL_BIN}/brew")

  if installed
    puts "homebrew already installed."
  else
    run(server_info, "brew", env)
  end
end

#init_launch_agentObject



58
59
60
# File 'lib/osx_provision/osx_provision.rb', line 58

def init_launch_agent
  run(server_info, "init_launch_agent", env)
end

#jenkinsObject



112
113
114
115
116
117
118
119
120
# File 'lib/osx_provision/osx_provision.rb', line 112

def jenkins
  installed = package_installed "/usr/local/opt/jenkins/libexec/jenkins.war"

  if installed
    puts "jenkins already installed."
  else
    run(server_info, "jenkins", env)
  end
end

#jenkins_restartObject



122
123
124
125
126
# File 'lib/osx_provision/osx_provision.rb', line 122

def jenkins_restart
  started = service_started("homebrew.mxcl.jenkins")

  run(server_info, "jenkins_restart", env.merge({started: started}))
end

#mysqlObject



62
63
64
65
66
67
68
69
70
# File 'lib/osx_provision/osx_provision.rb', line 62

def mysql
  installed = package_installed "#{USER_LOCAL_BIN}/mysql"

  if installed
    puts "mysql already installed."
  else
    run(server_info, "mysql", env)
  end
end

#mysql_create_schemasObject



172
173
174
175
176
# File 'lib/osx_provision/osx_provision.rb', line 172

def mysql_create_schemas
  env[:mysql][:app_schemas].each do |schema|
    run(server_info, "mysql_create_schema", env.merge(schema: schema))
  end
end

#mysql_create_userObject



164
165
166
# File 'lib/osx_provision/osx_provision.rb', line 164

def mysql_create_user
  run(server_info, "mysql_create_user", env)
end

#mysql_drop_schemasObject



178
179
180
181
182
# File 'lib/osx_provision/osx_provision.rb', line 178

def mysql_drop_schemas
  env[:mysql][:app_schemas].each do |schema|
    run(server_info, "mysql_drop_schema", env.merge(schema: schema))
  end
end

#mysql_drop_userObject



168
169
170
# File 'lib/osx_provision/osx_provision.rb', line 168

def mysql_drop_user
  run(server_info, "mysql_drop_user", env)
end

#mysql_restartObject



72
73
74
75
76
# File 'lib/osx_provision/osx_provision.rb', line 72

def mysql_restart
  started = service_started("homebrew.mxcl.mysql")

  run(server_info, "mysql_restart", env.merge({started: started}))
end

#npmObject



38
39
40
41
42
43
44
45
46
# File 'lib/osx_provision/osx_provision.rb', line 38

def npm
  installed = package_installed "#{USER_LOCAL_BIN}/npm"

  if installed
    puts "npm already installed."
  else
    run(server_info, "npm", env)
  end
end

#postgresObject



78
79
80
81
82
83
84
85
86
# File 'lib/osx_provision/osx_provision.rb', line 78

def postgres
  installed = package_installed "#{USER_LOCAL_BIN}/postgres"

  if installed
    puts "postgres already installed."
  else
    run(server_info, "postgres", env)
  end
end

#postgres_create_schemasObject



148
149
150
151
152
# File 'lib/osx_provision/osx_provision.rb', line 148

def postgres_create_schemas
  env[:postgres][:app_schemas].each do |schema|
    run(server_info, "postgres_create_schema", env.merge(schema: schema))
  end
end

#postgres_create_userObject



144
145
146
# File 'lib/osx_provision/osx_provision.rb', line 144

def postgres_create_user
  run(server_info, "postgres_create_user", env)
end

#postgres_drop_schemasObject



154
155
156
157
158
# File 'lib/osx_provision/osx_provision.rb', line 154

def postgres_drop_schemas
  env[:postgres][:app_schemas].each do |schema|
    run(server_info, "postgres_drop_schema", env.merge(schema: schema))
  end
end

#postgres_drop_userObject



160
161
162
# File 'lib/osx_provision/osx_provision.rb', line 160

def postgres_drop_user
  run(server_info, "postgres_drop_user", env)
end

#postgres_restartObject



88
89
90
91
92
# File 'lib/osx_provision/osx_provision.rb', line 88

def postgres_restart
  started = service_started("homebrew.mxcl.postgres")

  run(server_info, "postgres_restart", env.merge({started: started}))
end

#postgres_startObject



98
99
100
# File 'lib/osx_provision/osx_provision.rb', line 98

def postgres_start
  run server_info, "postgres_start", env
end

#postgres_stopObject



94
95
96
# File 'lib/osx_provision/osx_provision.rb', line 94

def postgres_stop
  run server_info, "postgres_stop", env
end

#prepareObject



12
13
14
15
16
# File 'lib/osx_provision/osx_provision.rb', line 12

def prepare
  env['password'] = ask_password("Enter password for #{env[:node][:user]}: ")

  run(server_info.merge(capture_output: false, sudo: true), "prepare", env)
end

#qtObject



48
49
50
51
52
53
54
55
56
# File 'lib/osx_provision/osx_provision.rb', line 48

def qt
  installed = package_installed "#{USER_LOCAL_BIN}/qmake"

  if installed
    puts "qt already installed."
  else
    run(server_info, "qt", env)
  end
end

#rubyObject



102
103
104
105
106
107
108
109
110
# File 'lib/osx_provision/osx_provision.rb', line 102

def ruby
  installed = package_installed "#{ENV['HOME']}/.rvm/rubies/ruby-1.9.3-p527/bin/ruby"

  if installed
    puts "ruby already installed."
  else
    run(server_info, "ruby", env)
  end
end

#rvmObject



28
29
30
31
32
33
34
35
36
# File 'lib/osx_provision/osx_provision.rb', line 28

def rvm
  installed = package_installed "#{ENV['HOME']}/.rvm/bin/rvm"

  if installed
    puts "rvm already installed."
  else
    run(server_info, "rvm", env)
  end
end

#seleniumObject



128
129
130
131
132
133
134
135
136
# File 'lib/osx_provision/osx_provision.rb', line 128

def selenium
  installed = package_installed "/usr/local/opt/selenium-server-standalone/selenium-server-standalone*.jar"

  if installed
    puts "selenium already installed."
  else
    run(server_info, "selenium", env)
  end
end

#selenium_restartObject



138
139
140
141
142
# File 'lib/osx_provision/osx_provision.rb', line 138

def selenium_restart
  started = service_started("homebrew.mxcl.selenium-server-standalone")

  run(server_info, "selenium_restart", env.merge({started: started}))
end