gitpusshuten 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/.bundle/config +2 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +9 -0
  4. data/Gemfile.lock +53 -0
  5. data/README.md +7 -0
  6. data/bin/gitpusshuten +4 -0
  7. data/bin/heavenly +4 -0
  8. data/bin/ten +4 -0
  9. data/gitpusshuten.gemspec +26 -0
  10. data/lib/gitpusshuten/cli.rb +78 -0
  11. data/lib/gitpusshuten/command.rb +147 -0
  12. data/lib/gitpusshuten/commands/base.rb +246 -0
  13. data/lib/gitpusshuten/commands/delete.rb +27 -0
  14. data/lib/gitpusshuten/commands/help.rb +36 -0
  15. data/lib/gitpusshuten/commands/initialize.rb +61 -0
  16. data/lib/gitpusshuten/commands/push.rb +54 -0
  17. data/lib/gitpusshuten/commands/remote.rb +29 -0
  18. data/lib/gitpusshuten/commands/user.rb +252 -0
  19. data/lib/gitpusshuten/commands/version.rb +21 -0
  20. data/lib/gitpusshuten/configuration.rb +122 -0
  21. data/lib/gitpusshuten/environment.rb +70 -0
  22. data/lib/gitpusshuten/gem.rb +33 -0
  23. data/lib/gitpusshuten/git.rb +111 -0
  24. data/lib/gitpusshuten/helpers/environment/installers.rb +59 -0
  25. data/lib/gitpusshuten/helpers/environment/packages.rb +21 -0
  26. data/lib/gitpusshuten/helpers/environment/scp.rb +57 -0
  27. data/lib/gitpusshuten/helpers/environment/ssh.rb +77 -0
  28. data/lib/gitpusshuten/helpers/environment/ssh_key.rb +79 -0
  29. data/lib/gitpusshuten/helpers/environment/user.rb +70 -0
  30. data/lib/gitpusshuten/helpers/spinner.rb +98 -0
  31. data/lib/gitpusshuten/hook.rb +26 -0
  32. data/lib/gitpusshuten/hooks.rb +147 -0
  33. data/lib/gitpusshuten/initializer.rb +95 -0
  34. data/lib/gitpusshuten/local.rb +35 -0
  35. data/lib/gitpusshuten/log.rb +83 -0
  36. data/lib/gitpusshuten/modules/active_record/hooks.rb +19 -0
  37. data/lib/gitpusshuten/modules/apache/command.rb +354 -0
  38. data/lib/gitpusshuten/modules/bundler/command.rb +43 -0
  39. data/lib/gitpusshuten/modules/bundler/hooks.rb +8 -0
  40. data/lib/gitpusshuten/modules/mysql/command.rb +192 -0
  41. data/lib/gitpusshuten/modules/nanoc/hooks.rb +9 -0
  42. data/lib/gitpusshuten/modules/nginx/command.rb +447 -0
  43. data/lib/gitpusshuten/modules/passenger/command.rb +310 -0
  44. data/lib/gitpusshuten/modules/passenger/hooks.rb +4 -0
  45. data/lib/gitpusshuten/modules/rvm/command.rb +277 -0
  46. data/lib/gitpusshuten.rb +21 -0
  47. data/lib/templates/config.rb +37 -0
  48. data/lib/templates/hooks.rb +40 -0
  49. data/spec/cli_spec.rb +83 -0
  50. data/spec/command_spec.rb +76 -0
  51. data/spec/configuration_spec.rb +45 -0
  52. data/spec/environment_spec.rb +64 -0
  53. data/spec/fixtures/combined_hooks.rb +23 -0
  54. data/spec/fixtures/config.rb +23 -0
  55. data/spec/fixtures/hooks.rb +37 -0
  56. data/spec/fixtures/passenger.json +1 -0
  57. data/spec/gem_spec.rb +28 -0
  58. data/spec/git_spec.rb +59 -0
  59. data/spec/gitpusshuten_spec.rb +9 -0
  60. data/spec/hook_spec.rb +48 -0
  61. data/spec/hooks_spec.rb +150 -0
  62. data/spec/initializer_spec.rb +26 -0
  63. data/spec/log_spec.rb +20 -0
  64. data/spec/spec_helper.rb +43 -0
  65. metadata +220 -0
@@ -0,0 +1,310 @@
1
+ module GitPusshuTen
2
+ module Commands
3
+ class Passenger < GitPusshuTen::Commands::Base
4
+ description "[Module] Phusion Passenger commands."
5
+ usage "passenger <command> for <environment>"
6
+ example "heavenly passenger install for staging # Installs Phusion Passenger with the NginX or Apache2 web server"
7
+ example "heavenly passenger update for staging # Updates Phusion Passenger and the NginX or Apache2 web server if a new version is available"
8
+ example "heavenly passenger restart for production # Restarts the Passenger instance for the specified environment"
9
+
10
+ ##
11
+ # Contains the webserver we're working with
12
+ # Either NginX or Apache
13
+ attr_accessor :webserver
14
+
15
+ def initialize(*objects)
16
+ super
17
+
18
+ @command = cli.arguments.shift
19
+
20
+ help if command.nil? or e.name.nil?
21
+ end
22
+
23
+ ##
24
+ # Restarts a Passenger instance for the specified environment
25
+ def perform_restart!
26
+ message "Restarting Passenger for #{y(c.application)} (#{y(e.name)} environment)."
27
+ e.execute_as_user("cd #{e.app_dir}; mkdir -p tmp; touch tmp/restart.txt")
28
+ end
29
+
30
+ ##
31
+ # Installs Phusion Passenger
32
+ def perform_install!
33
+
34
+ if not e.installed?('gem')
35
+ error "Could not find RubyGems."
36
+ error "Install RVM (Ruby Version Manager) and at least one Ruby version."
37
+ error "To do this, run: #{y("heavenly rvm install for #{e.name}")}."
38
+ exit
39
+ end
40
+
41
+ ##
42
+ # If no web server is specified, it'll prompt the user to
43
+ # select one of the available (NginX or Apache)
44
+ if webserver.nil?
45
+ message "For which web server would you like to install #{y('Phusion Passenger')}?"
46
+ @webserver = webserver?
47
+ end
48
+
49
+ message "Starting #{y('Phusion Passenger')} installation for #{y(webserver)}!"
50
+
51
+ ##
52
+ # Install the latest Passenger Gem
53
+ Spinner.return :message => "Installing latest Phusion Passenger Gem.." do
54
+ e.execute_as_root("gem install passenger --no-ri --no-rdoc")
55
+ g("Done!")
56
+ end
57
+
58
+ ##
59
+ # Install dependencies for Passenger
60
+ Spinner.return :message => "Ensuring #{y('Phusion Passenger')} dependencies are installed.." do
61
+
62
+ ##
63
+ # Install dependencies for installing NginX
64
+ if nginx?
65
+ e.install!("libcurl4-openssl-dev")
66
+ end
67
+
68
+ ##
69
+ # Install dependencies for installing Apache
70
+ if apache?
71
+ e.install!("libcurl4-openssl-dev apache2-mpm-prefork apache2-prefork-dev libapr1-dev libaprutil1-dev")
72
+ end
73
+
74
+ g("Done!")
75
+ end
76
+
77
+ if not @updating
78
+ standard "Installing #{y('Phusion Passenger')} and #{y(webserver)}."
79
+ else
80
+ standard "Updating #{y('Phusion Passenger')} and #{y(webserver)}."
81
+ end
82
+
83
+ Spinner.return :message => "This may take a while.." do
84
+
85
+ ##
86
+ # Run the Passenger NginX installation module if we're working with NginX
87
+ if nginx?
88
+ e.execute_as_root("passenger-install-nginx-module --auto --auto-download --prefix=/etc/nginx")
89
+ end
90
+
91
+ ##
92
+ # Run the Passenger Apache installation module if we're working with Apache
93
+ if apache?
94
+ e.execute_as_root("passenger-install-apache2-module --auto")
95
+ end
96
+
97
+ g("Done!")
98
+ end
99
+
100
+ ##
101
+ # Configures NginX to setup a managable vhost environment like Apache2
102
+ if nginx?
103
+ GitPusshuTen::Initializer.new("nginx", "setup", "#{e.name}", "environment")
104
+ end
105
+
106
+ ##
107
+ # Inject the Passenger paths into the Apache2 configuration file
108
+ if apache?
109
+ Spinner.return :message => "Configuring Apache for Phusion Passenger.." do
110
+ if not e.execute_as_root('cat /etc/apache2/apache2.conf').include?("passenger_module")
111
+ if e.execute_as_root('passenger-config --root') =~ /\/usr\/local\/rvm\/gems\/(.+)\/gems\/passenger-.+/
112
+ @ruby_version = $1.chomp.strip
113
+ @passenger_version = e.execute_as_root('passenger-config --version').chomp.strip
114
+ end
115
+
116
+ e.execute_as_root <<-PASSENGER
117
+ cat <<-CONFIG >> /etc/apache2/apache2.conf
118
+
119
+ LoadModule passenger_module /usr/local/rvm/gems/#{@ruby_version}/gems/passenger-#{@passenger_version}/ext/apache2/mod_passenger.so
120
+ PassengerRoot /usr/local/rvm/gems/#{@ruby_version}/gems/passenger-#{@passenger_version}
121
+ PassengerRuby /usr/local/rvm/wrappers/#{@ruby_version}/ruby
122
+
123
+ CONFIG
124
+ PASSENGER
125
+ end
126
+ g('Done!')
127
+ end # spinner
128
+ end
129
+
130
+ if not @updating
131
+ message "#{y('Phusion Passenger')} and #{y(webserver)} have been installed!"
132
+ else
133
+ message "#{y('Phusion Passenger')} and #{y(webserver)} have been updated!"
134
+ end
135
+
136
+ if nginx?
137
+ message "NginX directory: #{y('/etc/nginx')}"
138
+ end
139
+
140
+ if apache?
141
+ message "Apache directory: #{y('/etc/apache2')}"
142
+ GitPusshuTen::Initializer.new('apache', 'create-vhost', 'for', "#{e.name}")
143
+ end
144
+ end
145
+
146
+ ##
147
+ # Updates the Passenger Gem and NginX or Apache2 itself
148
+ # Compares the currently installed Passenger Gem with the latest (stable) version
149
+ # on RubyGems.org to see if anything newer than the current version is out.
150
+ # If there is, then it will continue to update NginX/Apache2 using Phussions's NginX/Apache2 installation module.
151
+ def perform_update!
152
+ prompt_for_root_password!
153
+
154
+ ##
155
+ # If no web server is specified, it'll prompt the user to
156
+ # select one of the available (NginX or Apache)
157
+ if webserver.nil?
158
+ @webserver = webserver?
159
+ end
160
+
161
+ ##
162
+ # Check if RubyGems (RVM + Ruby) has been installed
163
+ Spinner.return :message => "Checking if RubyGems is installed.." do
164
+ @rubygems_installed = e.installed?('gem')
165
+ if not @rubygems_installed
166
+ r("Couldn't find RubyGems.")
167
+ else
168
+ g("Done!")
169
+ end
170
+ end
171
+
172
+ if not @rubygems_installed
173
+ error "Install RVM (Ruby Version Manager) and at least one Ruby version."
174
+ error "To do this, run: #{y("heavenly rvm install for #{e.name}")}."
175
+ exit
176
+ end
177
+
178
+ ##
179
+ # Check if Phusion Passenger is installed
180
+ Spinner.return :message => "Checking if Phusion Passenger is installed.." do
181
+ @passenger_installed = e.installed?("passenger")
182
+ if not @passenger_installed
183
+ @ruby_version = e.execute_as_root("ruby -v").chomp
184
+ r("Couldn't find Phusion Passenger")
185
+ else
186
+ g("Found!")
187
+ end
188
+ end
189
+
190
+ if not @passenger_installed
191
+ error "Passenger has not been installed for #{y(@ruby_version)}"
192
+ error "If you want to install Passenger, please run the following command:"
193
+ error y("heavenly passenger install for #{e.name}")
194
+ exit
195
+ end
196
+
197
+ ##
198
+ # Check if a newer version of Phusion Passenger Gem is available
199
+ Spinner.return :message => "Checking if there's a newer (stable) Phusion Passenger available.." do
200
+ @latest_passenger_version = GitPusshuTen::Gem.new(:passenger).latest_version
201
+ @current_passenger_version = e.execute_as_root("passenger-config --version").chomp.strip
202
+ if @latest_passenger_version > @current_passenger_version
203
+ @new_passenger_version_available = true
204
+ y("There appears to be a newer version of Phusion Passenger available!")
205
+ else
206
+ g("Your Phusion Passenger is #{@current_passenger_version}. This is the latest version.")
207
+ end
208
+ end
209
+
210
+ exit unless @new_passenger_version_available
211
+
212
+ message "Phusion Passenger #{y(@latest_passenger_version)} is out!"
213
+ message "You are currently using version #{y(@current_passenger_version)}.\n\n"
214
+ message "Would you like to update Phusion Passenger?"
215
+ message "This will update the #{y('Phusion Passenger Gem')} as well as #{y(webserver)} and #{y("Phusion Passenger's #{webserver} Module")}."
216
+
217
+ ##
218
+ # Prompt user for confirmation for the update
219
+ if yes?
220
+
221
+ ##
222
+ # Search for NginX installation directory by finding the configuration file
223
+ if nginx?
224
+ find_nginx_conf!
225
+
226
+ if not @nginx_conf
227
+ error "Could not find the NginX configuration file in #{y('/etc/nginx')} or #{y('/etc/nginx/conf')}."
228
+ exit
229
+ end
230
+ end
231
+
232
+ ##
233
+ # Ensures the Apache2 configuration file exists
234
+ if apache?
235
+ find_apache2_conf!
236
+
237
+ if not @apache2_conf
238
+ error "Could not find the Apache2 configuration file in #{y('/etc/apache2')}."
239
+ exit
240
+ end
241
+ end
242
+
243
+ ##
244
+ # Installation directory has been found
245
+ message "#{y(webserver)} installation found in #{y(@nginx_conf || @apache2_conf)}."
246
+
247
+ ##
248
+ # Invoke the installation command to install NginX
249
+ @updating = true
250
+ perform_install!
251
+
252
+ ##
253
+ # Update the webserver configuration file
254
+ message "The #{y(webserver)} configuration file needs to be updated with the new #{y('Passenger')} version."
255
+ message "Invoking #{y("heavenly #{webserver.downcase} update-configuration for #{e.name}")} for you..\n\n\n"
256
+ GitPusshuTen::Initializer.new([webserver.downcase, 'update-configuration', 'for', "#{e.name}"])
257
+ end
258
+ end
259
+
260
+ ##
261
+ # Returns true if we're working with NginX
262
+ def nginx?
263
+ webserver == 'NginX'
264
+ end
265
+
266
+ ##
267
+ # Returns true if we're working with Apache
268
+ def apache?
269
+ webserver == 'Apache'
270
+ end
271
+
272
+ ##
273
+ # Prompts the user to select a webserver
274
+ def webserver?
275
+ choose do |menu|
276
+ menu.prompt = ''
277
+ menu.choice('NginX')
278
+ menu.choice('Apache')
279
+ end
280
+ end
281
+
282
+ ##
283
+ # Finds and sets the NginX Conf path
284
+ def find_nginx_conf!
285
+ ##
286
+ # NginX Conf path you get from Passenger
287
+ if e.file?('/etc/nginx/conf/nginx.conf')
288
+ @nginx_conf = '/etc/nginx/conf/nginx.conf'
289
+ end
290
+
291
+ ##
292
+ # NginX Conf path you get from Aptitude
293
+ if e.file?('/etc/nginx/nginx.conf')
294
+ @nginx_conf = '/etc/nginx/nginx.conf'
295
+ end
296
+ end
297
+
298
+ ##
299
+ # Finds and sets the Apache2 Conf path
300
+ def find_apache2_conf!
301
+ ##
302
+ # Apache2 Conf path you get from Aptitude
303
+ if e.file?('/etc/apache2/apache2.conf')
304
+ @apache2_conf = '/etc/apache2/apache2.conf'
305
+ end
306
+ end
307
+
308
+ end
309
+ end
310
+ end
@@ -0,0 +1,4 @@
1
+ post 'Restart Passenger for Application' do
2
+ run "mkdir -p tmp"
3
+ run "touch tmp/restart.txt"
4
+ end
@@ -0,0 +1,277 @@
1
+ # encoding: utf-8
2
+ module GitPusshuTen
3
+ module Commands
4
+ class Rvm < GitPusshuTen::Commands::Base
5
+ description "[Module] Ruby Version Manager (RVM) commands."
6
+ usage "rvm <command> for <environment>"
7
+ example "heavenly rvm install for staging # Installs RVM (system wide)."
8
+ example "heavenly rvm update for staging # Updates RVM."
9
+ example "heavenly rvm list for staging # Lists installed Rubies under RVM."
10
+ example "heavenly rvm install-ruby for production # Installs one of the available Ruby versions."
11
+ example "heavenly rvm uninstall-ruby for production # Uninstalls an installed Ruby under RVM."
12
+ example "heavenly rvm remove-ruby for production # Uninstalls and removes the Ruby's complete source from RVM."
13
+ example "heavenly rvm set-default-ruby for production # Sets the system wide default Ruby."
14
+ example " This is required if you want to change the Ruby version"
15
+ example " for your Ruby applications running Passenger."
16
+
17
+ def initialize(*objects)
18
+ super
19
+
20
+ @command = cli.arguments.shift
21
+
22
+ help if command.nil? or e.name.nil?
23
+
24
+ @command = @command.underscore
25
+ end
26
+
27
+ ##
28
+ # Installs RVM (Ruby Version Manager)
29
+ def perform_install!
30
+ prompt_for_root_password!
31
+
32
+ message "Which Ruby would you like to install and use as your default Ruby Interpreter?"
33
+ ruby_version = choose_ruby_version!
34
+ message "Going to install #{y(ruby_version)} after the #{y('RVM')} installation finishes."
35
+
36
+ ##
37
+ # Update aptitude package list and install git/curl/wget
38
+ Spinner.return :message => "Updating package list and installing #{y('RVM')} requirements.." do
39
+ e.install!("git-core curl wget;")
40
+ g("Done!")
41
+ end
42
+
43
+ ##
44
+ # Download Packages
45
+ Spinner.return :message => "Downloading Git Pusshu Ten #{y('packages')}.." do
46
+ e.download_packages!("$HOME", :root)
47
+ g("Done!")
48
+ end
49
+
50
+ ##
51
+ # Install RVM (system wide)
52
+ Spinner.return :message => "Installing #{y('RVM')}.." do
53
+ e.execute_as_root("cd $HOME; wget -O rvm-install-system-wide --no-check-certificate http://bit.ly/rvm-install-system-wide; bash rvm-install-system-wide; rm rvm-install-system-wide;")
54
+ g("Done!")
55
+ end
56
+
57
+ ##
58
+ # Download Git Packages and add the rvm load snippet into /etc/profile.
59
+ if not e.execute_as_root("cat /etc/profile").include?('source "/usr/local/rvm/scripts/rvm"')
60
+ Spinner.return :message => "Configuring #{y('/etc/profile')}.." do
61
+ e.execute_as_root("cd $HOME; cat gitpusshuten-packages/modules/rvm/profile >> /etc/profile")
62
+ g("Done!")
63
+ end
64
+ end
65
+
66
+ ##
67
+ # Add the gemrc into the root's home directory
68
+ if not e.file?('/root/.gemrc')
69
+ Spinner.return :message => "Configuring #{y('.gemrc')} file.." do
70
+ e.execute_as_root("cd $HOME; cat gitpusshuten-packages/modules/rvm/gemrc > ~/.gemrc")
71
+ g("Done!")
72
+ end
73
+ end
74
+
75
+ ##
76
+ # Create a .bashrc in $HOME to load /etc/profile for non-interactive sessions
77
+ if not e.execute_as_root("cat $HOME/.bashrc").include?('source /etc/profile')
78
+ Spinner.return :message => "Configuring #{y('.bashrc')}.." do
79
+ e.execute_as_root("echo 'source /etc/profile' > $HOME/.bashrc; source $HOME/.bashrc")
80
+ g("Done!")
81
+ end
82
+ end
83
+
84
+ ##
85
+ # Install required packages for installing Ruby
86
+ Spinner.return :message => "Installing the Ruby Interpreter #{y('dependency packages')}.." do
87
+ e.install!("build-essential bison openssl libreadline5 libreadline5-dev curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev")
88
+ g("Done!")
89
+ end
90
+
91
+ ##
92
+ # Install a Ruby version
93
+ Spinner.return :message => "Installing #{y(ruby_version)} with #{y('rvm')}. This may take a while.." do
94
+ e.execute_as_root("rvm install #{ruby_version}")
95
+ g("Done!")
96
+ end
97
+
98
+ ##
99
+ # Set the Ruby version as the default Ruby
100
+ Spinner.return :message => "Making #{y(ruby_version)} the default Ruby.." do
101
+ e.execute_as_root("rvm use #{ruby_version} --default")
102
+ g("Done!")
103
+ end
104
+
105
+ ##
106
+ # Clean up Packages
107
+ Spinner.return :message => "Cleaning up Git Pusshu Ten #{y('packages')}.." do
108
+ e.clean_up_packages!("$HOME", :root)
109
+ g("Done!")
110
+ end
111
+
112
+ message "Finished!"
113
+ end
114
+
115
+ ##
116
+ # Performs an update for RVM
117
+ def perform_update!
118
+ prompt_for_root_password!
119
+
120
+ message "Updating RVM."
121
+ message "Would you like to get the latest stable, or bleeding edge version?"
122
+ option = rvm_version?
123
+ Spinner.return :message => "Updating #{y('rvm')} to the #{y(option.nil? ? 'latest stable' : 'bleeding edge')}." do
124
+ e.execute_as_root("rvm update #{option}")
125
+ g("Done!")
126
+ end
127
+ end
128
+
129
+ ##
130
+ # Displays a list of installed gems
131
+ def perform_list!
132
+ prompt_for_root_password!
133
+
134
+ Spinner.return :message => "Getting a list of installed Rubies.", :put => true do
135
+ e.execute_as_root("rvm list")
136
+ end
137
+ message "The ( #{y("=>")} ) arrow indicates which Ruby version is currently being used."
138
+ end
139
+
140
+ ##
141
+ # Installs a Ruby version with RVM
142
+ def perform_install_ruby!
143
+ perform_list! # prompts root
144
+
145
+ message "Which Ruby version would you like to install?"
146
+ ruby_version = choose_ruby_version!
147
+
148
+ message "Would you like to make #{y(ruby_version)} your default Ruby?"
149
+ yes? ? make_default = true : make_default = false
150
+
151
+ Spinner.return :message => "Installing #{y(ruby_version)}, this may take a while.." do
152
+ e.execute_as_root("rvm install #{ruby_version}")
153
+ g("Done!")
154
+ end
155
+
156
+ if make_default
157
+ Spinner.return :message => "Setting #{y(ruby_version)} as the system wide default Ruby." do
158
+ e.execute_as_root("rvm use #{ruby_version} --default")
159
+ g("Done!")
160
+ end
161
+
162
+ ask_to_use_default_ruby_with_passenger!(ruby_version)
163
+ end
164
+ end
165
+
166
+ ##
167
+ # Uninstalls a Ruby version
168
+ def perform_uninstall_ruby!
169
+ perform_list! # prompts root
170
+
171
+ message "Which Ruby version would you like to uninstall?"
172
+ ruby_version = choose_ruby_version!
173
+
174
+ Spinner.return :message => "Uninstalling #{y(ruby_version)}.." do
175
+ if not e.execute_as_root("rvm uninstall #{ruby_version}") =~ /has already been removed/
176
+ g("Ruby version #{ruby_version} has been uninstalled.")
177
+ else
178
+ r("Ruby version #{ruby_version} has already been removed.")
179
+ end
180
+ end
181
+ end
182
+
183
+ ##
184
+ # Remove a Ruby version
185
+ def perform_remove_ruby!
186
+ perform_list! # prompts root
187
+
188
+ message "Which Ruby version would you like to remove?"
189
+ ruby_version = choose_ruby_version!
190
+
191
+ Spinner.return :message => "Removing #{y(ruby_version)}.." do
192
+ if not e.execute_as_root("rvm remove #{ruby_version}") =~ /is already non existent/
193
+ g("Ruby version #{ruby_version} has been removed.")
194
+ else
195
+ r("Ruby version #{ruby_version} is already non existent.")
196
+ end
197
+ end
198
+ end
199
+
200
+ ##
201
+ # Change the default Ruby on the server
202
+ def perform_set_default_ruby!
203
+ perform_list! # prompts root
204
+
205
+ message "Which Ruby version would you like to make the system wide default?"
206
+ ruby_version = choose_ruby_version!
207
+
208
+ Spinner.return :message => "Changing system wide default Ruby to #{y(ruby_version)}" do
209
+ if not e.execute_as_root("rvm use #{ruby_version} --default") =~ /not installed/
210
+ @succeeded = true
211
+ g("Ruby version #{ruby_version} is now set as the system wide default.")
212
+ else
213
+ r("Could not set #{ruby_version} as default")
214
+ end
215
+ end
216
+
217
+ if @succeeded
218
+ ask_to_use_default_ruby_with_passenger!(ruby_version)
219
+ end
220
+ end
221
+
222
+ ##
223
+ # Prompts the user to choose a Ruby to install
224
+ def choose_ruby_version!
225
+ choose do |menu|
226
+ menu.prompt = ''
227
+
228
+ %w[ruby-1.8.6 ruby-1.8.7 ruby-1.9.1 ruby-1.9.2].each do |mri|
229
+ menu.choice(mri)
230
+ end
231
+
232
+ %w[ree-1.8.6 ree-1.8.7].each do |ree|
233
+ menu.choice(ree)
234
+ end
235
+ end
236
+ end
237
+
238
+ ##
239
+ # Prompts the user to choose a RVM version to install
240
+ def rvm_version?
241
+ choose do |menu|
242
+ menu.prompt = ''
243
+ menu.choice('latest stable') { nil }
244
+ menu.choice('bleeding edge') { '--head' }
245
+ end
246
+ end
247
+
248
+ ##
249
+ # Prompts the user to select a webserver
250
+ def webserver?
251
+ choose do |menu|
252
+ menu.prompt = ''
253
+ menu.choice('NginX')
254
+ menu.choice('Apache')
255
+ end
256
+ end
257
+
258
+ ##
259
+ # Asks the user if he intends to make the newly set default ruby version
260
+ # as the ruby version for the passenger driven ruby applications
261
+ def ask_to_use_default_ruby_with_passenger!(ruby_version)
262
+ message("If you want to use #{y(ruby_version)} for your Ruby applications with Phusion Passenger")
263
+ message("you must update your #{y("webserver's")} configuration file.\n\n")
264
+ message("Would you like to do this now?\n\n")
265
+
266
+ if yes?
267
+ message "Which webserver are you using?"
268
+ webserver = webserver?
269
+
270
+ message "Invoking #{y("heavenly #{webserver.downcase} update-configuration for #{e.name}")} for you..\n\n\n"
271
+ GitPusshuTen::Initializer.new(webserver.downcase, 'update-configuration', 'for', "#{e.name}")
272
+ end
273
+ end
274
+
275
+ end
276
+ end
277
+ end
@@ -0,0 +1,21 @@
1
+ require 'open-uri'
2
+ require 'yaml'
3
+
4
+ require 'rubygems'
5
+ require 'bundler/setup' unless @ignore_bundler
6
+ require 'active_support/inflector'
7
+ require 'net/ssh'
8
+ require 'net/scp'
9
+ require 'highline/import'
10
+ require 'rainbow'
11
+ require 'json'
12
+
13
+ Dir[File.expand_path(File.join(File.dirname(__FILE__), 'gitpusshuten/**/*'))].each do |file|
14
+ if not File.directory?(file) and not file =~ /\/modules\/.+\/hooks\.rb/
15
+ require file
16
+ end
17
+ end
18
+
19
+ module GitPusshuTen
20
+ VERSION = '0.0.1'
21
+ end
@@ -0,0 +1,37 @@
1
+ ##
2
+ # Git Pusshu Ten - Configuration
3
+ #
4
+ # Here you specify all your environments. Most people will be
5
+ # satisfied with just 2: "staging" and "production". These are included
6
+ # in this configuration template. If you need more, feel free to add more.
7
+ #
8
+ # For more information, visit:
9
+ # http://gitpusshuten.com/documentation/getting-started/configuration/
10
+
11
+
12
+ ##
13
+ # Example of configuring both a staging and production environment
14
+ pusshuten 'My Application', :staging, :production do
15
+
16
+ configure do |c|
17
+ c.user = 'gitpusshuten'
18
+ c.ip = '123.45.678.90'
19
+ # c.password = 'my-password'
20
+ # c.passphrase = 'my-ssh-passphrase'
21
+ # c.port = '22'
22
+
23
+ c.path = '/var/applications/'
24
+ end
25
+
26
+ modules do |m|
27
+ # m.add :bundler
28
+ # m.add :active_record
29
+ # m.add :passenger
30
+ # m.add :nginx
31
+ # m.add :apache
32
+ # m.add :nanoc
33
+ # m.add :rvm
34
+ # m.add :mysql
35
+ end
36
+
37
+ end
@@ -0,0 +1,40 @@
1
+ ##
2
+ # Git Pusshu Ten - Hooks
3
+ #
4
+ # These are actions performed on the remote server
5
+ # from within the application root. Depending on what
6
+ # modules you included in the "config.rb" file, you might
7
+ # not have to create extra hooks here.
8
+ #
9
+ # For example, if you specified the :nginx module in the "config.rb"
10
+ # then you do not need to specify a nginx restart hook here since the
11
+ # module will automatically add a hook that already does that for you.
12
+ #
13
+ # For more information, visit:
14
+ # http://secretpreview.gitpusshuten.com/documentation/getting-started/deployment-hooks/
15
+
16
+ perform_on :staging, :production do
17
+ # pre "Echo out something" do
18
+ # run 'echo "Ready to Deploy"'
19
+ # end
20
+ end
21
+
22
+ perform_on :staging do
23
+ # post "Display application root directory contents" do
24
+ # run 'ls -la'
25
+ # end
26
+
27
+ # post "Restart NginX" do
28
+ # run '/etc/init.d/nginx restart'
29
+ # end
30
+ end
31
+
32
+ perform_on :production do
33
+ # post "Display application root directory contents" do
34
+ # run 'ls -la'
35
+ # end
36
+
37
+ # post "Restart NginX" do
38
+ # run '/etc/init.d/nginx restart'
39
+ # end
40
+ end