gitpusshuten 0.0.2 → 0.0.3

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.
data/gitpusshuten.gemspec CHANGED
@@ -1,7 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/gitpusshuten/version')
4
+
1
5
  Gem::Specification.new do |gem|
2
6
 
3
7
  gem.name = 'gitpusshuten'
4
- gem.version = '0.0.2' #GitPusshuTen::VERSION
8
+ gem.version = GitPusshuTen::VERSION
5
9
  gem.platform = Gem::Platform::RUBY
6
10
  gem.authors = 'Michael van Rooijen'
7
11
  gem.email = 'meskyanichi@gmail.com'
data/lib/gitpusshuten.rb CHANGED
@@ -18,5 +18,4 @@ Dir[File.expand_path(File.join(File.dirname(__FILE__), 'gitpusshuten/**/*'))].ea
18
18
  end
19
19
 
20
20
  module GitPusshuTen
21
- VERSION = '0.0.2'
22
- end
21
+ end
@@ -25,7 +25,9 @@ module GitPusshuTen
25
25
  # Sets up a new UNIX user and configures it based on the .gitpusshuten/config.rb
26
26
  def perform_add!
27
27
  if not e.user_exists? # prompts root
28
- ensure_git_installed!
28
+ ensure_git_installed!
29
+ ensure_common_dependencies_are_installed!
30
+
29
31
  message "It looks like #{y(c.user)} does not yet exist."
30
32
  message "Would you like to add #{y(c.user)} to #{y(c.application)} (#{y(c.ip)})?"
31
33
  if yes?
@@ -173,6 +175,13 @@ module GitPusshuTen
173
175
  end
174
176
  end
175
177
 
178
+ ##
179
+ # Installs common dependencies that applications typically use
180
+ # for XML parsing and image manipulation
181
+ def ensure_common_dependencies_are_installed!
182
+ e.install!('libxml2-dev libxslt1-dev imagemagick')
183
+ end
184
+
176
185
  ##
177
186
  # Configures the user. Overwrites all current configurations (if any exist)
178
187
  def configure_user!
@@ -48,10 +48,12 @@ module GitPusshuTen
48
48
  def ignore!
49
49
  if File.exist?('.gitignore')
50
50
  if not File.read('.gitignore').include?('.gitpusshuten/**/*')
51
- %x[echo '.gitpusshuten/**/*' >> .gitignore]
51
+ File.open('.gitignore', 'a') do |file|
52
+ file << "\n.gitpusshuten/**/*"
53
+ end
52
54
  end
53
55
  else
54
- %x[echo '.gitpusshuten/**/*' >> .gitignore]
56
+ %x[echo ".gitpusshuten/**/*" >> .gitignore]
55
57
  end
56
58
  end
57
59
 
@@ -6,7 +6,9 @@ module GitPusshuTen
6
6
  example "heavenly apache install to staging # Installs the Apache2 web server"
7
7
  example "heavenly apache update-configuration for staging # Only for Passenger users, when updating Ruby/Passenger versions."
8
8
  example "heavenly apache download-configuration from staging # Downloads the Apache2 configuration file from the specified environment."
9
+ example " download-config # Alias."
9
10
  example "heavenly apache upload-configuration to staging # Uploads the Apache2 configuration file to the specified environment."
11
+ example " upload-config # Alias."
10
12
  example "heavenly apache create-vhost for production # Creates a local vhost template for the specified environment."
11
13
  example "heavenly apache delete-vhost from production # Deletes the remote vhost for the specified environment."
12
14
  example "heavenly apache upload-vhost to staging # Uploads your local vhost to the server for the specified environment."
@@ -84,7 +86,7 @@ module GitPusshuTen
84
86
 
85
87
  ##
86
88
  # Downloads the Apache2 configuration file
87
- def perform_download_config!
89
+ def perform_download_configuration!
88
90
  if not e.file?('/etc/apache2/apache2.conf')
89
91
  error "Could not find the Apache2 configuration file in #{y('/etc/apache2/apache2.conf')}"
90
92
  exit
@@ -98,9 +100,15 @@ module GitPusshuTen
98
100
  end
99
101
  end
100
102
 
103
+ ##
104
+ # Alias to perform_download_configuration!
105
+ def perform_download_config!
106
+ perform_download_configuration!
107
+ end
108
+
101
109
  ##
102
110
  # Uploads the Apache2 configuration file
103
- def perform_upload_config!
111
+ def perform_upload_configuration!
104
112
  if not e.directory?('/etc/apache2')
105
113
  error "Could not find the Apache2 installation directory in #{y('/etc/apache2')}"
106
114
  exit
@@ -118,6 +126,12 @@ module GitPusshuTen
118
126
  end
119
127
  end
120
128
 
129
+ ##
130
+ # Alias to perform_upload_configuration!
131
+ def perform_upload_config!
132
+ perform_upload_configuration!
133
+ end
134
+
121
135
  def perform_download_vhost!
122
136
  remote_vhost = File.join(@configuration_directory, "sites-enabled", "#{e.sanitized_app_name}.#{e.name}.vhost")
123
137
  if not e.file?(remote_vhost) #prompts root
@@ -7,7 +7,9 @@ module GitPusshuTen
7
7
  example "heavenly nginx setup staging environment # Sets up a managable vhost environment."
8
8
  example "heavenly nginx update-configuration for staging # Only for Passenger users, when updating Ruby/Passenger versions."
9
9
  example "heavenly nginx download-configuration from staging # Downloads the Nginx configuration file from the specified environment."
10
+ example " download-config # Alias."
10
11
  example "heavenly nginx upload-configuration to staging # Uploads the NginX configuration file to the specified environment."
12
+ example " upload-config # Alias."
11
13
  example "heavenly nginx create-vhost for production # Creates a local vhost template for the specified environment."
12
14
  example "heavenly nginx delete-vhost from production # Deletes the remote vhost for the specified environment."
13
15
  example "heavenly nginx upload-vhost to staging # Uploads your local vhost to the server for the specified environment."
@@ -86,49 +88,37 @@ module GitPusshuTen
86
88
  def perform_setup!
87
89
  find_nginx!
88
90
 
89
- ##
90
- # Creates a tmp dir
91
- local.create_tmp_dir!
92
-
93
- ##
94
- # Downloads the NginX configuration file to tmp dir
95
- e.scp_as_root(:download, @nginx_conf, local.tmp_dir)
96
-
97
- ##
98
- # Set the path to the downloaded file
99
- local_file = File.join(local.tmp_dir, @nginx_conf_name)
100
-
101
- if not File.read(local_file).include?('include sites-enabled/*;')
102
- message "Configuring NginX configuration file."
103
-
104
- ##
105
- # Inject the 'include sites-enabled/*'
106
- contents = File.read(local_file).sub(/http(\s|\t|\n){0,}\{/, "http {\n\s\s\s\sinclude sites-enabled/*;\n")
107
- File.open(local_file, 'w') do |file|
108
- file << contents
109
- end
91
+ if not e.execute_as_root("cat '#{@nginx_conf}'").include?('GIT PUSSHUTEN GENERATED NGINX CONFIGURATION FILE')
110
92
 
111
93
  ##
112
94
  # Make a backup of the old nginx.conf
113
- message "Creating a backup of old NginX configuration file."
114
- e.execute_as_root("cp '#{@nginx_conf}' '#{@nginx_conf}.backup.#{Time.now.to_i}'")
95
+ Spinner.return :message => "Creating a backup of the current NginX configuration file.." do
96
+ e.execute_as_root("cp '#{@nginx_conf}' '#{@nginx_conf}.backup.#{Time.now.to_i}'")
97
+ g('Done!')
98
+ end
115
99
 
116
100
  ##
117
- # Upload the file back
118
- message "Updating NginX configuration file."
119
- e.scp_as_root(:upload, local_file, @nginx_conf)
101
+ # Replace the old NginX configuration file with the pre-configured one
102
+ Spinner.return :message => "Generating pre-configured NginX configuration file.." do
103
+ e.download_packages!("$HOME", :root)
104
+ e.execute_as_root("cp $HOME/gitpusshuten-packages/modules/nginx/nginx.conf '#{@nginx_conf}'")
105
+ e.clean_up_packages!("$HOME", :root)
106
+ g('Done!')
107
+ end
120
108
 
121
109
  ##
122
110
  # Create the vhosts dir on the server
123
- message "Creating #{@nginx_vhosts_dir} directory."
124
- e.execute_as_root("mkdir -p #{@nginx_vhosts_dir}")
111
+ Spinner.return :message => "Creating #{@nginx_vhosts_dir} directory.." do
112
+ e.execute_as_root("mkdir -p #{@nginx_vhosts_dir}")
113
+ g('Done!')
114
+ end
115
+
116
+ if e.installed?('passenger')
117
+ perform_update_configuration!
118
+ end
119
+
125
120
  end
126
121
 
127
- ##
128
- # Removes the tmp dir
129
- message "Cleaning up #{local.tmp_dir}"
130
- local.remove_tmp_dir!
131
-
132
122
  ##
133
123
  # Create NginX directory
134
124
  # Create NginX vhost file (if it doesn't already exist)
@@ -137,7 +127,7 @@ module GitPusshuTen
137
127
 
138
128
  ##
139
129
  # Downloads the NginX configuration file
140
- def perform_download_config!
130
+ def perform_download_configuration!
141
131
  find_nginx!
142
132
  if not @nginx_conf
143
133
  error "Could not find the NginX configuration file in #{y(@nginx_conf)}"
@@ -152,15 +142,21 @@ module GitPusshuTen
152
142
  end
153
143
  end
154
144
 
145
+ ##
146
+ # Alias to perform_download_configuration!
147
+ def perform_download_config!
148
+ perform_download_configuration!
149
+ end
150
+
155
151
  ##
156
152
  # Uploads the NginX configuration file
157
- def perform_upload_config!
153
+ def perform_upload_configuration!
158
154
  find_nginx!
159
155
  if not e.directory?('/etc/nginx')
160
156
  error "Could not find the NginX installation directory in #{y('/etc/nginx')}"
161
157
  exit
162
158
  end
163
-
159
+
164
160
  local_configuration_file = File.join(local.gitpusshuten_dir, 'nginx', 'nginx.conf')
165
161
  if not File.exist?(local_configuration_file)
166
162
  error "Could not find the local NginX configuration file in #{y(local_configuration_file)}"
@@ -173,6 +169,12 @@ module GitPusshuTen
173
169
  end
174
170
  end
175
171
 
172
+ ##
173
+ # Alias to perform_upload_configuration!
174
+ def perform_upload_config!
175
+ perform_upload_configuration!
176
+ end
177
+
176
178
  ##
177
179
  # Updates a local vhost
178
180
  def perform_upload_vhost!
@@ -283,7 +285,7 @@ module GitPusshuTen
283
285
 
284
286
  INFO
285
287
 
286
- message "NginX will now be configured to work with the above versions. Is this correct?"
288
+ message "NginX will now be configured to work with the above versions. Is that OK?"
287
289
  exit unless yes?
288
290
 
289
291
  ##
@@ -329,6 +331,16 @@ module GitPusshuTen
329
331
  update.sub! /passenger_ruby \/usr\/local\/rvm\/wrappers\/(.+)\/ruby\;/,
330
332
  "passenger_ruby /usr/local/rvm/wrappers/#{@ruby_version}/ruby;"
331
333
 
334
+ ##
335
+ # Uncomment any Phusion Passenger configuration if it is commented out
336
+ # since Phusion Passenger is enabled
337
+ update.sub!(/\#.+(passenger_ruby.+\;)/) { $1 }
338
+ update.sub!(/\#.+(passenger_root.+\;)/) { $1 }
339
+ update.sub!(/\#.+(passenger_spawn_method.+\;)/) { $1 }
340
+ update.sub!(/\#.+(passenger_min_instances.+\;)/) { $1 }
341
+ update.sub!(/\#.+(passenger_max_pool_size.+\;)/) { $1 }
342
+ update.sub!(/\#.+(passenger_pool_idle_time.+\;)/) { $1 }
343
+
332
344
  File.open(local_configuration_file, 'w') do |file|
333
345
  file << update
334
346
  end
@@ -356,7 +368,7 @@ module GitPusshuTen
356
368
  warning "then you should be able to just restart #{y('NginX')} right away since all application gems should still be in tact.\n\n"
357
369
 
358
370
  message "When ready, run the following command to restart #{y('NginX')} and have the applied updates take effect:"
359
- standard "\n\s\s#{y("heavenly nginx restart for #{e.name}")}"
371
+ standard "\n\s\s#{y("heavenly nginx restart for #{e.name}")}\n\n"
360
372
  end
361
373
 
362
374
  def perform_download_vhost!
@@ -436,6 +448,13 @@ module GitPusshuTen
436
448
  @nginx_conf_dir = '/etc/nginx'
437
449
  end
438
450
 
451
+ ##
452
+ # Determines whether the configuration file was found or not
453
+ if @nginx_conf.nil?
454
+ error "Could not find the NginX configuration file. Has NginX been installed?"
455
+ exit
456
+ end
457
+
439
458
  ##
440
459
  # Set additional configuration
441
460
  @nginx_conf_name = @nginx_conf.split('/').last
@@ -6,6 +6,7 @@ module GitPusshuTen
6
6
  usage "redis <command> for <enviroment>"
7
7
  example "heavenly redis install # Installs Redis (system wide) and downloads config template."
8
8
  example "heavenly redis upload-configuration # Uploads the Redis configuration template to the server, will install Redis if not already present."
9
+ example " upload-config # Alias."
9
10
 
10
11
  def initialize(*objects)
11
12
  super
@@ -65,7 +66,13 @@ module GitPusshuTen
65
66
  g('Done!')
66
67
  end
67
68
  end
68
-
69
+
70
+ ##
71
+ # Alias to perform_upload_configuration!
72
+ def perform_upload_config!
73
+ perform_upload_configuration!
74
+ end
75
+
69
76
  def download_redis_configuration_from_server!
70
77
  FileUtils.mkdir_p(@local_configuration_dir)
71
78
  Spinner.return :message => "Downloading redis configuration from the server.." do
@@ -0,0 +1,3 @@
1
+ module GitPusshuTen
2
+ VERSION = '0.0.3'
3
+ end
@@ -32,6 +32,7 @@ pusshuten 'My Application', :staging, :production do
32
32
  # m.add :nanoc
33
33
  # m.add :rvm
34
34
  # m.add :mysql
35
+ # m.add :redis
35
36
  end
36
37
 
37
38
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael van Rooijen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-21 00:00:00 +01:00
17
+ date: 2010-11-22 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -167,6 +167,7 @@ files:
167
167
  - lib/gitpusshuten/modules/passenger/hooks.rb
168
168
  - lib/gitpusshuten/modules/redis/command.rb
169
169
  - lib/gitpusshuten/modules/rvm/command.rb
170
+ - lib/gitpusshuten/version.rb
170
171
  - lib/templates/config.rb
171
172
  - lib/templates/hooks.rb
172
173
  - spec/cli_spec.rb