osx_provision 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWJhMWEwNmI1MGFjZjAzNjE0ODRiZGNhMTM3ZDEwZDczN2JiNTkzOQ==
5
+ data.tar.gz: !binary |-
6
+ Y2EzZDdhMjhlMWM4YTAxNDczMGUxNWI2MDFhYmJmY2ZjMzQwOWZlMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZjdjYjkwNDA5NGZlMjRjOThjNzM5YTA0ODJmY2IyZmRkNGY2MWM0M2RiZjI3
10
+ ZmI3NWJmYjk4NzkwZjY0MTQzYmIzODhhZTE0MWQ3NmI4YWFmZGNjMDg1OGQ2
11
+ ODhiMzc5MWFhYjg5MjliMTk2ZjJkNWE3ZmUzN2IwMWU2YmZkMjM=
12
+ data.tar.gz: !binary |-
13
+ NDM4ZmIzOGNhNzMyMWFjYjNmMTdhZWUxZTNkYjMxYmEyMWQ2YWJkZDI1MzZl
14
+ NjE5Mzg5MTMzMTUzOTcyZjljYjZhMWQ0OTg3ZjEzNTg0ZDMyNGYwNGVlYzMx
15
+ NmQxYTdkYThlNmZhNDBmNmFjNTlmMWIwMThkNTIxM2IyZWRkODI=
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /.idea
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ osx_provision
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.9.3
data/CHANGES ADDED
@@ -0,0 +1,6 @@
1
+ = OSX Provision Changelog
2
+
3
+ == Version 0.9.0
4
+
5
+ * Initial release.
6
+
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :default do
4
+ gem "text-interpolator", "~>1.0"
5
+ gem "script_executor", "~>1.4"
6
+ gem "thor", "~>0.19"
7
+ gem "json_pure", "~>1.8"
8
+ end
9
+
10
+ group :development do
11
+ gem "gemspec_deps_gen", "~>1.1"
12
+ gem "gemcutter", "~>0.7"
13
+ end
14
+
15
+ group :test do
16
+ gem "rspec"
17
+ gem "mocha"
18
+ end
19
+
20
+
21
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Alexander Shvets
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ OSX Provision
2
+
3
+ Library and thor tasks for provisioning of Macbook computer initial setup for Ruby/Rails development
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```bash
8
+ gem 'osx_provision'
9
+ ```
10
+ And then execute:
11
+
12
+ ```bash
13
+ bundle
14
+ ```
15
+
16
+ Or install it yourself as:
17
+
18
+ ```bash
19
+ gem install osx_provision
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Provisioning of initial computer setup is done as set of thor commands. You can execute them in one shot
25
+ or run each command separately.
26
+
27
+ * Execute all commands:
28
+
29
+ ```bash
30
+ thor osx_install:all
31
+ ```
32
+ or separately:
33
+
34
+ ```bash
35
+ thor osx_install:brew
36
+ thor osx_install:rvm
37
+ thor osx_install:qtpostgres
38
+ thor osx_install:brew
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env rake
2
+
3
+ $LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
4
+
5
+ require "rspec/core/rake_task"
6
+ require "osx_provision/version"
7
+ require "gemspec_deps_gen/gemspec_deps_gen"
8
+
9
+ version = OsxProvision::VERSION
10
+ project_name = File.basename(Dir.pwd)
11
+
12
+ task :gen do
13
+ generator = GemspecDepsGen.new
14
+
15
+ generator.generate_dependencies "spec", "#{project_name}.gemspec.erb", "#{project_name}.gemspec"
16
+ end
17
+
18
+ task :build => :gen do
19
+ system "gem build #{project_name}.gemspec"
20
+ end
21
+
22
+ task :install do
23
+ system "gem install #{project_name}-#{version}.gem"
24
+ end
25
+
26
+ task :uninstall do
27
+ system "gem uninstall #{project_name}"
28
+ end
29
+
30
+ task :release => :build do
31
+ system "gem push #{project_name}-#{version}.gem"
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new do |task|
35
+ task.pattern = 'spec/**/*_spec.rb'
36
+ task.verbose = false
37
+ end
38
+
39
+
data/Thorfile ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ unless defined? Thor::Runner
4
+ require 'bundler'
5
+
6
+ gems = Bundler::Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil).requested_specs
7
+
8
+ gem = gems.find { |gem| gem.name == 'thor'}
9
+
10
+ load "#{ENV['GEM_HOME']}/gems/#{gem.name}-#{gem.version}/bin/thor"
11
+ end
12
+
13
+ require 'thor'
14
+
15
+ Dir.glob("thor/**/*.thor") do |name|
16
+ Thor::Util.load_thorfile(name)
17
+ end
18
+
19
+ # $LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
@@ -0,0 +1 @@
1
+ require 'osx_provision/osx_provision'
@@ -0,0 +1,47 @@
1
+ require 'json'
2
+ require "highline"
3
+
4
+ require 'text_interpolator'
5
+ require 'script_executor/executable'
6
+ require 'script_executor/script_locator'
7
+
8
+ class GenericProvision
9
+ include Executable, ScriptLocator
10
+
11
+ attr_reader :interpolator, :env, :script_list, :server_info
12
+
13
+ def initialize config_file_name, scripts_file_name
14
+ @interpolator = TextInterpolator.new
15
+
16
+ @env = read_config(config_file_name)
17
+
18
+ @script_list = scripts(File.expand_path(scripts_file_name, File.dirname(__FILE__)))
19
+
20
+ @server_info = env[:node] ? env[:node] : {}
21
+ end
22
+
23
+ protected
24
+
25
+ def read_config config_file_name
26
+ hash = JSON.parse(File.read(config_file_name), :symbolize_names => true)
27
+
28
+ interpolator.interpolate hash
29
+ end
30
+
31
+ def terminal
32
+ @terminal ||= HighLine.new
33
+ end
34
+
35
+ def ask_password message
36
+ terminal.ask(message) { |q| q.echo = "*" }
37
+ end
38
+
39
+ def run server_info, script_name, params
40
+ execute(server_info) { evaluate_script_body(script_list[script_name], params, :string) }
41
+ end
42
+
43
+ def run_command server_info, command
44
+ execute(server_info.merge({script: command}))
45
+ end
46
+
47
+ end
@@ -0,0 +1,226 @@
1
+ require 'osx_provision/generic_provision'
2
+
3
+ class OsxProvision < GenericProvision
4
+ USER_LOCAL_BIN = "/usr/local/bin"
5
+
6
+ def prepare
7
+ env['password'] = ask_password("Enter password for #{env[:node][:user]}: ")
8
+
9
+ run(server_info.merge(capture_output: false, sudo: true), "prepare", env)
10
+ end
11
+
12
+ def homebrew_install
13
+ installed = package_installed("#{USER_LOCAL_BIN}/brew")
14
+
15
+ if installed
16
+ puts "homebrew already installed."
17
+ else
18
+ run(server_info, "brew", env)
19
+ end
20
+ end
21
+
22
+ def rvm_install
23
+ installed = package_installed "#{ENV['HOME']}/.rvm/bin/rvm"
24
+
25
+ if installed
26
+ puts "rvm already installed."
27
+ else
28
+ run(server_info, "rvm", env)
29
+ end
30
+ end
31
+
32
+ def npm_install
33
+ installed = package_installed "#{USER_LOCAL_BIN}/npm"
34
+
35
+ if installed
36
+ puts "npm already installed."
37
+ else
38
+ run(server_info, "npm", env)
39
+ end
40
+ end
41
+
42
+ def qt_install
43
+ installed = package_installed "#{USER_LOCAL_BIN}/qmake"
44
+
45
+ if installed
46
+ puts "qt already installed."
47
+ else
48
+ run(server_info, "qt", env)
49
+ end
50
+ end
51
+
52
+ def init_launch_agent
53
+ run(server_info, "init_launch_agent", env)
54
+ end
55
+
56
+ def mysql_install
57
+ installed = package_installed "#{USER_LOCAL_BIN}/mysql"
58
+
59
+ if installed
60
+ puts "mysql already installed."
61
+ else
62
+ run(server_info, "mysql", env)
63
+ end
64
+ end
65
+
66
+ def mysql_restart
67
+ started = service_started("homebrew.mxcl.mysql")
68
+
69
+ run(server_info, "mysql_restart", env.merge({started: started}))
70
+ end
71
+
72
+ def postgres_install
73
+ installed = package_installed "#{USER_LOCAL_BIN}/postgres"
74
+
75
+ if installed
76
+ puts "postgres already installed."
77
+ else
78
+ run(server_info, "postgres", env)
79
+ end
80
+ end
81
+
82
+ def postgres_restart
83
+ started = service_started("homebrew.mxcl.postgres")
84
+
85
+ run(server_info, "postgres_restart", env.merge({started: started}))
86
+ end
87
+
88
+ def postgres_stop
89
+ run server_info, "postgres_stop", env
90
+ end
91
+
92
+ def postgres_start
93
+ run server_info, "postgres_start", env
94
+ end
95
+
96
+ def ruby_install
97
+ installed = package_installed "#{ENV['HOME']}/.rvm/rubies/ruby-1.9.3-p429/bin/ruby"
98
+
99
+ if installed
100
+ puts "ruby already installed."
101
+ else
102
+ run(server_info, "ruby", env)
103
+ end
104
+ end
105
+
106
+ def jenkins_install
107
+ installed = package_installed "/usr/local/opt/jenkins/libexec/jenkins.war"
108
+
109
+ if installed
110
+ puts "jenkins already installed."
111
+ else
112
+ run(server_info, "jenkins", env)
113
+ end
114
+ end
115
+
116
+ def jenkins_restart
117
+ started = service_started("homebrew.mxcl.jenkins")
118
+
119
+ run(server_info, "jenkins_restart", env.merge({started: started}))
120
+ end
121
+
122
+ def selenium_install
123
+ installed = package_installed "/usr/local/opt/selenium-server-standalone/selenium-server-standalone*.jar"
124
+
125
+ if installed
126
+ puts "selenium already installed."
127
+ else
128
+ run(server_info, "selenium", env)
129
+ end
130
+ end
131
+
132
+ def selenium_restart
133
+ started = service_started("homebrew.mxcl.selenium-server-standalone")
134
+
135
+ run(server_info, "selenium_restart", env.merge({started: started}))
136
+ end
137
+
138
+ def postgres_create user, schemas
139
+ create_postgres_user user, schemas.first
140
+
141
+ schemas.each do |schema|
142
+ create_postgres_schema user, schema
143
+ end
144
+ end
145
+
146
+ def postgres_drop user, schemas
147
+ schemas.each do |schema|
148
+ drop_postgres_schema schema
149
+ end
150
+
151
+ drop_postgres_user user, schemas.first
152
+ end
153
+
154
+ def postgres_test schema
155
+ result = get_postgres_schemas schema
156
+
157
+ puts result
158
+ end
159
+
160
+ private
161
+
162
+ def service_started name
163
+ result = run server_info.merge(:suppress_output => true, :capture_output => true),
164
+ "service_started", env.merge({name: name})
165
+
166
+ result.chomp.size > 0
167
+ end
168
+
169
+ def create_mysql_user app_user
170
+ run(server_info, "create_mysql_user", env.merge({app_user: app_user}))
171
+ end
172
+
173
+ def create_mysql_schema schema
174
+ schema_exists = mysql_schema_exist?(config[:mysql][:hostname], config[:mysql][:user], config[:mysql][:password], schema)
175
+
176
+ run(server_info, "create_mysql_schema", env) unless schema_exists
177
+ end
178
+
179
+ def mysql_schema_exist?(hostname, user, password, schema)
180
+ get_mysql_schemas(hostname, user, password, schema).include?(schema)
181
+ end
182
+
183
+ def get_mysql_schemas hostname, user, password, schema
184
+ command = "#{USER_LOCAL_BIN}/mysql -h #{hostname} -u #{user} -p\"#{password}\" -e \"SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA;\""
185
+
186
+ run_command server_info.merge(:suppress_output => true, :capture_output => true), command
187
+ end
188
+
189
+ def postgres_schema_exist?(schema)
190
+ get_postgres_schemas(schema).include?(schema)
191
+ end
192
+
193
+ def get_postgres_schemas schema
194
+ command = "#{USER_LOCAL_BIN}/psql -d #{schema} -c '\\l'"
195
+
196
+ run_command server_info.merge(:suppress_output => true, :capture_output => true), command
197
+ end
198
+
199
+ def create_postgres_user app_user, schema
200
+ run(server_info, "create_postgres_user", env.merge({app_user: app_user, schema: schema}))
201
+ end
202
+
203
+ def drop_postgres_user app_user, schema
204
+ command = "#{USER_LOCAL_BIN}/dropuser #{app_user}"
205
+
206
+ run_command server_info, command
207
+ end
208
+
209
+ def create_postgres_schema app_user, schema
210
+ run(server_info, "create_postgres_schema", env.merge({app_user: app_user, schema: schema}))
211
+ end
212
+
213
+ def drop_postgres_schema schema
214
+ command = "#{USER_LOCAL_BIN}/dropdb #{schema}"
215
+
216
+ run_command server_info, command
217
+ end
218
+
219
+ def package_installed package_path
220
+ result = run server_info.merge(:suppress_output => true, :capture_output => true),
221
+ "package_installed", env.merge({package_path: package_path})
222
+
223
+ result.chomp == package_path
224
+ end
225
+
226
+ end
@@ -0,0 +1,249 @@
1
+ #!/bin/sh
2
+
3
+ #######################################
4
+ [prepare]
5
+
6
+ xcodebuild -license
7
+
8
+
9
+ #######################################
10
+ [brew]
11
+
12
+ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
13
+
14
+ brew update
15
+ brew doctor
16
+
17
+ brew tap homebrew/dupes
18
+ brew tap homebrew/versions
19
+
20
+
21
+ #######################################
22
+ [rvm]
23
+
24
+ PATH=$PATH:/usr/local/bin
25
+ USER_HOME="#{node.home}"
26
+
27
+ curl -L https://get.rvm.io | bash
28
+
29
+ source $USER_HOME/.rvm/scripts/rvm
30
+
31
+
32
+ #######################################
33
+ [git]
34
+
35
+ brew install git
36
+
37
+
38
+ #######################################
39
+ [qt]
40
+
41
+ PATH=$PATH:/usr/local/bin
42
+
43
+ brew install qt
44
+
45
+
46
+ #######################################
47
+ [init_launch_agent]
48
+
49
+ mkdir #{home}/Library/LaunchAgents/
50
+
51
+
52
+ #######################################
53
+ [mysql]
54
+
55
+ PATH=$PATH:/usr/local/bin
56
+ USER_HOME="#{node.home}"
57
+
58
+ brew install mysql
59
+
60
+ mkdir -p $USER_HOME/Library/LaunchAgents
61
+
62
+ ln -sfv /usr/local/opt/mysql/*.plist $USER_HOME/Library/LaunchAgents
63
+
64
+ mysqladmin -u root password 'root'
65
+
66
+
67
+ #######################################
68
+ [mysql_restart]
69
+
70
+ STARTED="[#{started}]"
71
+ USER_HOME="#{node.home}"
72
+
73
+ if [ "$STARTED" = "[true]" ] ; then
74
+ launchctl unload $USER_HOME/Library/LaunchAgents/homebrew.mxcl.mysql.plist
75
+ fi
76
+
77
+ launchctl load $USER_HOME/Library/LaunchAgents/homebrew.mxcl.mysql.plist
78
+
79
+
80
+ #######################################
81
+ [create_mysql_user]
82
+
83
+ PATH=$PATH:/usr/local/bin
84
+
85
+ APP_USER='#{app_user}'
86
+ HOST_NAME='#{mysql[:hostname]}'
87
+ USER='#{mysql[:user]}'
88
+ PASSWORD='#{mysql][:password]}'
89
+
90
+ mysql -h $HOST_NAME -u root -p"root" -e "DROP USER '$APP_USER'@'$HOST_NAME';"
91
+ mysql -h $HOST_NAME -u root -p"root" -e "CREATE USER '$APP_USER'@'$HOST_NAME' IDENTIFIED BY '$APP_USER';"
92
+
93
+ mysql -h $HOST_NAME -u root -p"root" -e "grant all privileges on *.* to '$APP_USER'@'$HOST_NAME' identified by '$APP_USER' with grant option;"
94
+ mysql -h $HOST_NAME -u root -p"root" -e "grant all privileges on *.* to '$APP_USER'@'%' identified by '$APP_USER' with grant option;"
95
+
96
+
97
+ #######################################
98
+ [create_mysql_schema]
99
+
100
+ PATH=$PATH:/usr/local/bin
101
+
102
+ SCHEMA='#{schema}'
103
+ HOST_NAME='#{mysql[:hostname]}'
104
+ USER='#{mysql[:user]}'
105
+ PASSWORD='#{mysql[:password]}'
106
+
107
+ mysql -h $HOST_NAME -u root -p"root" -e "create database $SCHEMA;"
108
+
109
+
110
+ #######################################
111
+ [postgres]
112
+
113
+ PATH=$PATH:/usr/local/bin
114
+ USER_HOME="#{node.home}"
115
+
116
+ brew install postgres
117
+
118
+ ln -sfv /usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist $USER_HOME/Library/LaunchAgents
119
+
120
+ initdb /usr/local/var/postgres -E utf8
121
+
122
+
123
+ #######################################
124
+ [postgres_stop]
125
+
126
+ USER_HOME="#{node.home}"
127
+
128
+ launchctl unload -w $USER_HOME/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
129
+
130
+
131
+ #######################################
132
+ [postgres_start]
133
+
134
+ USER_HOME="#{node.home}"
135
+
136
+ launchctl load -w $USER_HOME/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
137
+
138
+
139
+ #######################################
140
+ [postgres_restart]
141
+
142
+ STARTED="[#{started}]"
143
+ USER_HOME="#{node.home}"
144
+
145
+ if [ "$STARTED" = "[true]" ] ; then
146
+ launchctl unload -w $USER_HOME/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
147
+ fi
148
+
149
+ launchctl load -w $USER_HOME/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
150
+
151
+
152
+ #######################################
153
+ [create_postgres_user]
154
+
155
+ PATH=$PATH:/usr/local/bin
156
+
157
+ APP_USER='#{app_user}'
158
+
159
+ createuser -s -d -r $APP_USER
160
+
161
+
162
+ #######################################
163
+ [create_postgres_schema]
164
+
165
+ PATH=$PATH:/usr/local/bin
166
+
167
+ APP_USER='#{app_user}'
168
+ SCHEMA='#{schema}'
169
+
170
+ createdb -U $APP_USER $SCHEMA
171
+
172
+
173
+ #######################################
174
+ [ruby]
175
+
176
+ PATH=$PATH:/usr/local/bin
177
+
178
+ rvm install 1.9.3
179
+
180
+
181
+ #######################################
182
+ [jenkins]
183
+
184
+ PATH=$PATH:/usr/local/bin
185
+ USER_HOME="#{node.home}"
186
+
187
+ brew install jenkins
188
+
189
+ ln -sfv /usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist $USER_HOME/Library/LaunchAgents
190
+
191
+
192
+ #######################################
193
+ [jenkins_restart]
194
+
195
+ STARTED="[#{started}]"
196
+ USER_HOME="#{node.home}"
197
+
198
+ if [ "$STARTED" = "[true]" ] ; then
199
+ launchctl unload $USER_HOME/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
200
+ fi
201
+
202
+ launchctl load $USER_HOME/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
203
+
204
+
205
+ #######################################
206
+ [selenium]
207
+
208
+ PATH=$PATH:/usr/local/bin
209
+ USER_HOME="#{node.home}"
210
+
211
+ brew install selenium-server-standalone
212
+
213
+ ln -sfv /usr/local/opt/selenium-server-standalone/*.plist $USER_HOME/Library/LaunchAgents
214
+
215
+
216
+ #######################################
217
+ [selenium_restart]
218
+
219
+ STARTED="[#{started}]"
220
+ USER_HOME="#{node.home}"
221
+
222
+ if [ "$STARTED" = "true" ] ; then
223
+ launchctl unload $USER_HOME/Library/LaunchAgents/homebrew.mxcl.selenium-server-standalone.plist
224
+ fi
225
+
226
+ launchctl load $USER_HOME/Library/LaunchAgents/homebrew.mxcl.selenium-server-standalone.plist
227
+
228
+
229
+ #######################################
230
+ [npm]
231
+
232
+ brew install node
233
+
234
+
235
+ #######################################
236
+ [package_installed]
237
+
238
+ ls #{package_path}
239
+
240
+
241
+ #######################################
242
+ [service_started]
243
+
244
+ NAME="#{name%}"
245
+
246
+ TEMPFILE="$(mktemp XXXXXXXX)"
247
+ launchctl list | grep $NAME > $TEMPFILE
248
+ cat $TEMPFILE
249
+ rm $TEMPFILE
@@ -0,0 +1,3 @@
1
+ class OsxProvision
2
+ VERSION = "0.9.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/osx_provision/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "osx_provision"
7
+ spec.summary = %q{Library for building Mac OSX provisioning}
8
+ spec.description = %q{Library for building Mac OSX computer provisioning}
9
+ spec.email = "alexander.shvets@gmail.com"
10
+ spec.authors = ["Alexander Shvets"]
11
+ spec.homepage = "http://github.com/shvets/osx_provision"
12
+
13
+ spec.files = `git ls-files`.split($\)
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+ spec.version = OsxProvision::VERSION
17
+
18
+
19
+ <%= project_dependencies %>
20
+ end
21
+
@@ -0,0 +1,23 @@
1
+ {
2
+ "node": {
3
+ "domain": "127.0.0.1",
4
+ "user": "ENV['USER']",
5
+ "home": "ENV['HOME']",
6
+ "remote": false
7
+ },
8
+
9
+ "postgres": {
10
+ "hostname": "localhost", "user": "postgres", "password": "postgres",
11
+
12
+ "app_user": "ruby_dev_user",
13
+ "app_schemas": ["ruby_dev_test", "ruby_dev_dev", "ruby_dev_prod"]
14
+ },
15
+
16
+ "mysql": {
17
+ "hostname": "localhost", "user": "root", "password": "root",
18
+
19
+ "app_user": "ruby_dev_user",
20
+ "app_schemas": ["ruby_dev_test", "ruby_dev_dev", "ruby_dev_prod"]
21
+ }
22
+
23
+ }
@@ -0,0 +1,25 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ require 'osx_provision/osx_provision'
4
+
5
+ describe OsxProvision do
6
+ subject { OsxPrivision.new ".osx_provision.json", "osx_provision_scripts.sh"}
7
+
8
+ describe "#init_launch_agent" do
9
+ it "calls prepare method" do
10
+ subject.jenkins_install
11
+ end
12
+ end
13
+
14
+ describe "#init_launch_agent" do
15
+ it "calls init_launch_agent method" do
16
+ subject.init_launch_agent
17
+ end
18
+ end
19
+
20
+ describe "#homebrew_install" do
21
+ it "calls homebrew_install method" do
22
+ subject.homebrew_install
23
+ end
24
+ end
25
+ end
@@ -0,0 +1 @@
1
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
@@ -0,0 +1,145 @@
1
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
2
+
3
+ require 'osx_provision/osx_installer'
4
+
5
+ class OsxInstall < Thor
6
+ attr_reader :installer
7
+
8
+ def initialize *params
9
+ @installer = OsxProvision.new ".osx_provision.json", "osx_provision_scripts.sh"
10
+
11
+ super *params
12
+ end
13
+
14
+ desc "all", "Installs all required packages"
15
+ def all
16
+ invoke :brew
17
+ invoke :rvm
18
+ invoke :qt
19
+
20
+ invoke :mysql
21
+ invoke :mysql_restart
22
+
23
+ invoke :init_launch_agent
24
+
25
+ invoke :postgres
26
+ invoke :postgres_restart
27
+
28
+ invoke :jenkins
29
+ invoke :jenkins_restart
30
+
31
+ invoke :selenium
32
+
33
+ invoke :ruby
34
+
35
+ invoke :postgres_create
36
+ end
37
+
38
+ desc "prepare", "prepare"
39
+ def prepare
40
+ installer.prepare
41
+ end
42
+
43
+ desc "brew", "Installs homebrew"
44
+ def brew
45
+ installer.homebrew_install
46
+ end
47
+
48
+ desc "rvm", "Installs rvm"
49
+ def rvm
50
+ installer.rvm_install
51
+ end
52
+
53
+ desc "npm", "Installs npm"
54
+ def npm
55
+ installer.npm_install
56
+ end
57
+
58
+ desc "qt", "Installs qt"
59
+ def qt
60
+ installer.qt_install
61
+ end
62
+
63
+ desc "init_launch_agent", "Inits launch agent"
64
+ def init_launch_agent
65
+ installer.init_launch_agent
66
+ end
67
+
68
+ desc "mysql", "Installs mysql server"
69
+ def mysql
70
+ installer.mysql_install
71
+ end
72
+
73
+ # brew uninstall mysql
74
+
75
+ desc "mysql_restart", "Restarts mysql server"
76
+ def mysql_restart
77
+ installer.mysql_restart
78
+ end
79
+
80
+ desc "postgres", "Installs postgres server"
81
+ def postgres
82
+ installer.postgres_install
83
+ end
84
+
85
+ desc "postgres_restart", "Restarts postgres server"
86
+ def postgres_restart
87
+ installer.postgres_restart
88
+ end
89
+
90
+ desc "postgres_stop", "Stop postgres server"
91
+ def postgres_stop
92
+ installer.postgres_stop
93
+ end
94
+
95
+ desc "postgres_start", "Start postgres server"
96
+ def postgres_start
97
+ installer.postgres_start
98
+ end
99
+
100
+ desc "ruby", "Installs ruby"
101
+ def ruby
102
+ installer.ruby_install
103
+ end
104
+
105
+ desc "jenkins", "Installs jenkins server"
106
+ def jenkins
107
+ installer.jenkins_install
108
+ end
109
+
110
+ desc "jenkins_restart", "Restart jenkins server"
111
+ def jenkins_restart
112
+ installer.jenkins_restart
113
+ end
114
+
115
+ desc "selenium", "Installs selenium server"
116
+ def selenium
117
+ installer.selenium_install
118
+ end
119
+
120
+ desc "selenium_restart", "Restarts selenium server"
121
+ def selenium_restart
122
+ installer.selenium_restart
123
+ end
124
+
125
+ desc "postgres_create", "Initializes postgres project schemas"
126
+ def postgres_create
127
+ installer.postgres_create env["app_user"], env["app_schemas"]
128
+ end
129
+
130
+ desc "postgres_drop", "Drops postgres project schemas"
131
+ def postgres_drop
132
+ installer.postgres_drop env["app_user"], env["app_schemas"]
133
+ end
134
+
135
+ desc "postgres_test", "Test postgres schemas"
136
+ def postgres_test
137
+ installer.postgres_test env["app_user"]
138
+ end
139
+
140
+ desc "test", "test"
141
+ def test
142
+ puts "test"
143
+ end
144
+
145
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: osx_provision
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Shvets
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: text-interpolator
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: script_executor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.19'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.19'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json_pure
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gemspec_deps_gen
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: gemcutter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '0.7'
97
+ description: Library for building Mac OSX computer provisioning
98
+ email: alexander.shvets@gmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - .gitignore
104
+ - .ruby-gemset
105
+ - .ruby-version
106
+ - CHANGES
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - Thorfile
112
+ - lib/osx_provision.rb
113
+ - lib/osx_provision/generic_provision.rb
114
+ - lib/osx_provision/osx_provision.rb
115
+ - lib/osx_provision/osx_provision_scripts.sh
116
+ - lib/osx_provision/version.rb
117
+ - osx_provision.gemspec.erb
118
+ - osx_provision.json
119
+ - spec/osx_provision_spec.rb
120
+ - spec/spec_helper.rb
121
+ - thor/osx_install.thor
122
+ homepage: http://github.com/shvets/osx_provision
123
+ licenses: []
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.2.2
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Library for building Mac OSX provisioning
145
+ test_files:
146
+ - spec/osx_provision_spec.rb
147
+ - spec/spec_helper.rb