astroboa-cli 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
- source :rubygems
2
+ source 'https://rubygems.org'
3
3
 
4
4
  gemspec
data/README.md CHANGED
@@ -8,7 +8,11 @@ It has easy to use commands for installing astroboa platform, creating new repos
8
8
  ## Prerequisites
9
9
  * Linux or MAC OS X operating system. Windows is not yet supported
10
10
 
11
- * OPTIONAL BUILD TOOLS: In MAC OS X is strongly recommended to install 'brew' package manager as well as XCODE and XCODE command line tools in order to be able to compile new packages and ruby native extensions.
11
+ * BUILD TOOLS:
12
+ * In MAC OS X is strongly recommended to install 'brew' package manager as well as XCODE
13
+ and XCODE command line tools in order to be able to compile new packages and ruby native extensions.
14
+ * If you're running Ubuntu, you must install the build-essential package (apt-get install build-essential)
15
+ because some required gems (nokogiri, pg) build native extensions and require the make utility.
12
16
 
13
17
  * Java 1.6.x is required for running astroboa server.
14
18
  * If you consider a production system use **Sun/Oracle JDK**. For testing/development **OpenJDK** can be ok but we have not exhaustively tested it.
data/astroboa-cli.gemspec CHANGED
@@ -1,13 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
+ require "date"
3
4
  require "astroboa-cli/version"
4
5
 
5
6
  Gem::Specification.new do |s|
6
7
  s.name = "astroboa-cli"
7
8
  s.version = AstroboaCLI::VERSION
8
9
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["BETACONCEPT","Gregory Chomatas"]
10
- s.email = ["support@betaconcept.com"]
10
+ s.authors = ["Gregory Chomatas"]
11
+ s.email = ["gchomatas@betaconcept.com"]
11
12
  s.homepage = "http://www.astroboa.org"
12
13
  s.date = Date.today.to_s
13
14
  s.summary = %q{Astroboa Command Line Interface for astroboa platform and astroboa apps management.}
@@ -22,12 +23,13 @@ Gem::Specification.new do |s|
22
23
  s.files = `git ls-files`.split("\n")
23
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
25
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
-
26
+
26
27
  s.require_paths = ["lib"]
27
28
  s.add_runtime_dependency 'progressbar'
28
29
  s.add_runtime_dependency 'rubyzip'
29
30
  s.add_runtime_dependency 'erubis'
30
31
  s.add_runtime_dependency 'nokogiri', '>= 1.5.5'
31
32
  s.add_runtime_dependency 'colorize'
33
+ s.add_runtime_dependency 'zip-zip'
32
34
  s.executables = ["astroboa-cli"]
33
35
  end
@@ -8,77 +8,77 @@ require 'progressbar'
8
8
  require 'net/http'
9
9
  require 'uri'
10
10
  require 'yaml'
11
-
11
+
12
12
  # install and setup astroboa server
13
13
  #
14
14
  class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
15
-
15
+
16
16
  # server:install
17
17
  #
18
18
  # Installs and setups astroboa server.
19
19
  # Use the install command only for the initial installation. If you want to upgrade see 'astroboa-cli help server:upgrade'
20
- # Before you run the install command check the following requirements:
21
- # + You should have already installed java 1.6 and ruby 1.9.x
20
+ # Before you run the install command check the following requirements:
21
+ # + You should have already installed java 1.7 and ruby 1.9.x or later
22
22
  # + You are running this command from ruby version 1.9.x or later
23
23
  # + You should have the unzip command. It is required for unzipping the downloaded packages
24
24
  # + If you choose a database other than derby then the database should be already installed and running and you should know the db admin user and password
25
25
  #
26
26
  # -i, --install_dir INSTALLATION_DIRECTORY # The full path to the directory into which to install astroboa # Default is '/opt/astroboa' in linux and '$HOME/astroboa' in mac os x and windows
27
27
  # -r, --repo_dir REPOSITORIES_DIRECTORY # The full path of the directory that will contain the repositories configuration and data # Default is $installation_dir/repositories
28
- # -d, --database DATABASE_VENDOR # Select which database to use for data persistense # Supported databases are: derby, postgres-8.2, postgres-8.3, postgres-8.4, postgres-9.0, postgres-9.1 # Default is derby
28
+ # -d, --database DATABASE_VENDOR # Select which database to use for data persistense # Supported databases are: derby, postgres-8.2, postgres-8.3, postgres-8.4, postgres-9.0, postgres-9.1, postgres-9.2, postgres-9.3 # Default is derby
29
29
  # -s, --database_server DATABASE_SERVER_IP # Specify the database server ip or FQDN (e.g 192.168.1.100 or postgres.localdomain.vpn) # Default is localhost # Not required if db is derby (it will be ignored)
30
- # -u, --database_admin DB_ADMIN_USER # The user name of the database administrator # If not specified it will default to 'postgres' for postgresql db # Not required if db is derby (it will be ignored)
30
+ # -u, --database_admin DB_ADMIN_USER # The user name of the database administrator # If not specified it will default to 'postgres' for postgresql db # Not required if db is derby (it will be ignored)
31
31
  #
32
- # For security reasons (to avoid leaving the password in command history) there is no command option
33
- # for specifing the password of the database administrator.
34
- # But do not worry, the password will be asked from you during the installation process
32
+ # For security reasons (to avoid leaving the password in command history) there is no command option
33
+ # for specifing the password of the database administrator.
34
+ # But do not worry, the password will be asked from you during the installation process
35
35
  # A db password is required only if you choose postgres as your database.
36
- # If you require to do an unattended, non-interactive installation (e.g. run astroboa-cli from chef or puppet)
36
+ # If you require to do an unattended, non-interactive installation (e.g. run astroboa-cli from chef or puppet)
37
37
  # then you can call astroboa-cli like this:
38
- # $ echo "postgres_admin_password" | astroboa-cli server:install -d postgres-9.1
39
- # Take care that the db password is saved for later use (repositories creation / deletion)
38
+ # $ echo "postgres_admin_password" | astroboa-cli server:install -d postgres-9.3
39
+ # Take care that the db password is saved for later use (repositories creation / deletion)
40
40
  # in astroboa server config (~/.astoboa-conf.yml in mac and /etc/astroboa/astroboa-conf.yml in linux).
41
- # This file is created to be readable / writable only by root in linux
41
+ # This file is created to be readable / writable only by root in linux
42
42
  # and only by the user that does the installation in mac os x.
43
43
  #
44
44
  def install
45
45
  @torquebox_download_url = 'http://www.astroboa.org/releases/astroboa/latest/torquebox-dist-2.0.3-bin.zip'
46
46
  @torquebox_package = @torquebox_download_url.split("/").last
47
-
47
+
48
48
  @torquebox_version_download_url = 'http://www.astroboa.org/releases/astroboa/latest/TORQUEBOX-VERSION'
49
49
  @torquebox_version_file = @torquebox_version_download_url.split("/").last
50
-
50
+
51
51
  @astroboa_ear_download_url = 'http://www.astroboa.org/releases/astroboa/latest/astroboa.ear'
52
52
  @astroboa_ear_package = @astroboa_ear_download_url.split("/").last
53
-
53
+
54
54
  @astroboa_setup_templates_download_url = 'http://www.astroboa.org/releases/astroboa/latest/astroboa-setup-templates.zip'
55
55
  @astroboa_setup_templates_package = @astroboa_setup_templates_download_url.split("/").last
56
-
56
+
57
57
  @schemas_download_url = 'http://www.astroboa.org/releases/astroboa/latest/schemas.zip'
58
58
  @schemas_package = @schemas_download_url.split("/").last
59
-
59
+
60
60
  @astroboa_version_download_url = 'http://www.astroboa.org/releases/astroboa/latest/ASTROBOA-VERSION'
61
61
  @astroboa_version_file = @astroboa_version_download_url.split("/").last
62
-
62
+
63
63
  @install_dir = options[:install_dir] ||= mac_os_x? || windows? ? File.join(Dir.home, 'astroboa') : '/opt/astroboa'
64
64
  @install_dir = File.expand_path @install_dir # if provided path was not absolute expand it
65
65
  @repo_dir = options[:repo_dir] ||= File.join(@install_dir, "repositories")
66
66
  @repo_dir = File.expand_path @repo_dir # if provided path was not absolute expand it
67
67
  display <<-MSG.gsub(/^ {4}/, '')
68
- Starting astroboa server installation
69
- Server will be installed in: #{@install_dir}
68
+ Starting astroboa server installation
69
+ Server will be installed in: #{@install_dir}
70
70
  Repository Data and config will be stored in: #{@repo_dir}
71
71
  MSG
72
-
72
+
73
73
  @database = options[:database] ||= 'derby'
74
-
74
+
75
75
  db_error_message =<<-MSG.gsub(/^ {4}/, '')
76
- The selected database '#{@database}' is not supported.
77
- Supported databases are: derby, postgres-8.2, postgres-8.3, postgres-8.4, postgres-9.0, postgres-9.1
76
+ The selected database '#{@database}' is not supported.
77
+ Supported databases are: derby, postgres-8.2, postgres-8.3, postgres-8.4, postgres-9.0, postgres-9.1, postgres-9.2, postgres-9.3
78
78
  MSG
79
-
80
- error db_error_message unless %W(derby postgres-8.2 postgres-8.3 postgres-8.4 postgres-9.0 postgres-9.1).include?(@database)
81
-
79
+
80
+ error db_error_message unless %W(derby postgres-8.2 postgres-8.3 postgres-8.4 postgres-9.0 postgres-9.1 postgres-9.2 postgres-9.3).include?(@database)
81
+
82
82
  if @database.split("-").first == "postgres"
83
83
  @database_admin = options[:database_admin] ||= "postgres"
84
84
  @database_admin_password = get_password("Please enter the password for postgresql admin user '#{@database_admin}': ")
@@ -89,7 +89,7 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
89
89
  @database_server = options[:database_server] ||= "localhost"
90
90
  display "repository database is '#{@database}' accessed with user: '#{@database_admin}'"
91
91
  display "Database server IP or FQDN is: #{@database_server}" if @database.split("-").first == "postgres"
92
- # check if all requirement are fulfilled before proceeding with the installation
92
+ # check if all requirement are fulfilled before proceeding with the installation
93
93
  check_installation_requirements
94
94
  download_server_components
95
95
  install_server_components
@@ -99,8 +99,8 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
99
99
  cleanup_installation
100
100
  # export_environment_variables
101
101
  end
102
-
103
-
102
+
103
+
104
104
  # server:start
105
105
  #
106
106
  # starts astroboa server in the foreground or as a background process.
@@ -117,42 +117,42 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
117
117
  # 'astroboa-cli help service:stop'
118
118
  #
119
119
  # -b, --background # Starts astroboa in the background. Use 'astroboa-cli server:stop' to gracefully stop it
120
- # -j, --jvm_options JVM_OPTIONS # java options for starting the astroboa jvm
120
+ # -j, --jvm_options JVM_OPTIONS # java options for starting the astroboa jvm
121
121
  #
122
122
  def start
123
123
  error 'astroboa is already running' if astroboa_running?
124
124
 
125
125
  astroboa_installed?
126
-
126
+
127
127
  server_config = get_server_configuration
128
-
128
+
129
129
  # Astroboa runs inside torquebox (a special version of JBOSS AS 7) which requires jruby
130
130
  # Torquebox comes with the required jruby installed.
131
131
  # If the env variable 'JRUBY_HOME' exists torquebox does not use ts own jruby but that pointed by the env variable
132
132
  # So we unset the variable (just in case it is set) to enforce torquebox to use its own jruby
133
133
  ENV.delete('JRUBY_HOME')
134
-
134
+
135
135
  # set jruby opts so that jruby runs in 1.9 mode
136
136
  ENV['JRUBY_OPTS'] = '--1.9'
137
-
137
+
138
138
  # don't send the gemfile from the current app
139
139
  ENV.delete('BUNDLE_GEMFILE')
140
-
140
+
141
141
  # append java options to the environment variable
142
142
  ENV['APPEND_JAVA_OPTS'] = options[:jvm_options]
143
-
143
+
144
144
  command = File.join(server_config['install_dir'], 'torquebox', 'jboss', 'bin', 'standalone.sh')
145
-
146
-
145
+
146
+
147
147
  jboss_log_file = File.join(server_config['install_dir'], 'torquebox', 'jboss', 'standalone', 'log', 'server.log')
148
-
148
+
149
149
  # We should always run astroboa as the user that owns the astroboa installation
150
150
  # otherwise problems with file permissions may be encountered.
151
- # If the current process owner is not the astroboa owner then we check if process owner
151
+ # If the current process owner is not the astroboa owner then we check if process owner
152
152
  # is the super user (i.e astroboa-cli is run with sudo).
153
- # If process owner is super user we change the process owner
153
+ # If process owner is super user we change the process owner
154
154
  # to be the astroboa user (we can do that since process run with sudo privileges) and we run astroboa.
155
- # If process owner is not super user we give a notice that astroboa-cli should be executed with sudo and exit.
155
+ # If process owner is not super user we give a notice that astroboa-cli should be executed with sudo and exit.
156
156
  user = ENV['USER'] if mac_os_x? || linux?
157
157
  user = ENV['USERNAME'] if windows?
158
158
  install_dir = server_config['install_dir']
@@ -160,7 +160,7 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
160
160
  astroboa_user = Etc.getpwuid(astroboa_uid).name
161
161
  process_uid = Process.uid
162
162
  process_user = Etc.getpwuid(process_uid).name
163
-
163
+
164
164
  if astroboa_uid != process_uid
165
165
  display "You are running astroboa-cli as user: #{process_user} and astroboa should run as user: #{astroboa_user}"
166
166
  display "We need sudo privileges in order to do this. Lets check..."
@@ -176,8 +176,11 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
176
176
  display "You are root: OK" if user == 'root'
177
177
  end
178
178
  end
179
-
179
+
180
180
  if options[:background]
181
+ ENV['JBOSS_PIDFILE'] = '/var/run/astroboa/astroboa.pid'
182
+ ENV['LAUNCH_JBOSS_IN_BACKGROUND'] = 'true'
183
+
181
184
  display "Astroboa is starting in the background..."
182
185
  display "You can check the log file with 'tail -f #{jboss_log_file}'"
183
186
  display "When server startup has finished access astroboa console at: http://localhost:8080/console"
@@ -188,9 +191,9 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
188
191
  display "When server startup has finished access astroboa console at: http://localhost:8080/console"
189
192
  exec %(#{command})
190
193
  end
191
-
194
+
192
195
  end
193
-
196
+
194
197
  # server:stop
195
198
  #
196
199
  # stops astroboa server if it is already running.
@@ -213,9 +216,9 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
213
216
  else
214
217
  error "Failed to shutdown Astroboa. Message is: #{output}"
215
218
  end
216
-
219
+
217
220
  end
218
-
221
+
219
222
  # server:check
220
223
  #
221
224
  # checks if astroboa server is properly installed and displays the installation paths
@@ -223,57 +226,57 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
223
226
  #
224
227
  def check
225
228
  astroboa_installed?
226
- display astroboa_running? ? 'astroboa is running' : 'astroboa is not running'
229
+ display astroboa_running? ? 'astroboa is running' : 'astroboa is not running'
227
230
  end
228
-
229
-
231
+
232
+
230
233
  private
231
-
234
+
232
235
  def check_installation_requirements
233
236
  display "Checking installation requirements"
234
-
235
- # if OS is linux or [OS is mac and install_dir / repo_dir is not writable by current user]
237
+
238
+ # if OS is linux or [OS is mac and install_dir / repo_dir is not writable by current user]
236
239
  # then astroboa-cli should run with sudo in order to have the required privileges to write files
237
240
  check_if_running_with_sudo if linux? || (mac_os_x? && !(dir_writable?(@install_dir) && dir_writable?(@repo_dir)))
238
-
241
+
239
242
  # do not proceed if astroboa is already installed
240
243
  check_if_astroboa_exists_in_install_dirs
241
-
244
+
242
245
  # installation is not currently supported on windows
243
246
  check_if_os_is_windows
244
-
247
+
245
248
  # check if the proper version of java is installed
246
249
  java_ok?
247
-
250
+
248
251
  # check if unzip command is available
249
252
  check_if_unzip_is_installed
250
-
253
+
251
254
  #if repositories will be backed by postgres
252
255
  if @database.split("-").first == "postgres"
253
-
254
- # check if 'pg' gem is installed
256
+
257
+ # check if 'pg' gem is installed
255
258
  if gem_available?('pg')
256
259
  display "Checking if 'pg' gem is installed (required for creating postgres db): OK"
257
260
  else
258
261
  error <<-MSG.gsub(/^ {4}/, '')
259
262
  You should manually install the 'pg' gem if you want to create repositories backed by postgres
260
- astroboa-cli gem does not automatically install 'pg' gem since in some environments (e.g. MAC OS X) this might require
263
+ astroboa-cli gem does not automatically install 'pg' gem since in some environments (e.g. MAC OS X) this might require
261
264
  to have a local postgres already installed, which in turn is too much if you do not care about postgres.
262
265
  In *Ubuntu Linux* run first 'sudo apt-get install libpq-dev' and then run 'gem install pg'.
263
266
  For MAC OS x read http://deveiate.org/code/pg/README-OS_X_rdoc.html to learn how to install the 'pg' gem.
264
267
  MSG
265
268
  end
266
-
269
+
267
270
  # check if we can connect to postgres with the specified db admin account
268
271
  if postgres_connectivity?(@database_server, @database_admin, @database_admin_password)
269
272
  display "Checking if we can connect to postgres with the specified db admin account: OK"
270
273
  else
271
274
  error <<-MSG.gsub(/^ {4}/, '')
272
- Could not connect to the postgres db server (@database_server)
275
+ Could not connect to the postgres db server (@database_server)
273
276
  with the db admin user (@database_admin) and the password you have specified.
274
277
  Please check that the db admin user and the password are correct.
275
- Also check that the postgres server ip or fqdn is correct and that postgres
276
- has been properly setup to accept connections from this machine (check where postgres listens in postgres.conf
278
+ Also check that the postgres server ip or fqdn is correct and that postgres
279
+ has been properly setup to accept connections from this machine (check where postgres listens in postgres.conf
277
280
  and also check ip/user restrictions in pg_hba.conf).
278
281
  Finally check that there are no firewall rules in this machine or in the machine
279
282
  that postgres runs that prevent the connection (postgres runs by default on port 5432)
@@ -281,15 +284,15 @@ private
281
284
  end
282
285
  end
283
286
  end
284
-
285
-
287
+
288
+
286
289
  def check_if_os_is_windows
287
290
  message = "astroboa server installation is currently supported for linux and mac os x"
288
291
  error message if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin/i
289
292
  display "Checking if operating system is supported: OK"
290
293
  end
291
-
292
-
294
+
295
+
293
296
  def check_if_astroboa_exists_in_install_dirs
294
297
  astroboa_error_message = "Astroboa seems to be already installed at #{@install_dir}. Delete the installation directory or specify another install path. Run 'astroboa-cli help server:upgrade' to find how to upgrade"
295
298
  repositories_error_message = "Repositories already exist at #{@repo_dir}. Specify another repository path or run 'astroboa-cli help server:upgrade' to find how to upgrade"
@@ -297,54 +300,54 @@ private
297
300
  error repositories_error_message if File.directory? File.join(@repo_dir, "identities")
298
301
  display "Verifing that Astroboa is not already installed in the specified directories: OK"
299
302
  end
300
-
301
-
303
+
304
+
302
305
  def astroboa_installed?
303
306
  server_config = get_server_configuration
304
-
307
+
305
308
  problem_message = "Astroboa is not properly installed."
306
-
309
+
307
310
  astroboa_ear = Dir[File.join server_config['install_dir'], "torquebox", "jboss", "standalone", "deployments", "astroboa*.ear"].pop
308
311
  error "#{problem_message} Astroboa ear package is not installed" unless astroboa_ear
309
312
  display "Check astroboa ear : OK"
310
-
313
+
311
314
  error "#{problem_message} Astroboa identities repository is not setup" unless File.directory? File.join(server_config['repos_dir'], "identities")
312
315
  display "Check Astroboa identities repository : OK"
313
-
316
+
314
317
  # since the astroboa user is the same as the astroboa-cli user we can also check the environment variables
315
318
  # if mac_os_x?
316
319
  # error "#{problem_message} Environment variable 'ASTROBOA_HOME' is not set. Check that your .bash_profile has run and it properly exports the 'ASTROBOA_HOME' environment variable" unless ENV['ASTROBOA_HOME']
317
- # error "#{problem_message} Environment variable 'ASTROBOA_REPOSITORIES_HOME' is not set. Check that your .bash_profile has run and it properly exports the 'ASTROBOA_REPOSITORIES_HOME' environment variable" unless ENV['ASTROBOA_REPOSITORIES_HOME']
320
+ # error "#{problem_message} Environment variable 'ASTROBOA_REPOSITORIES_HOME' is not set. Check that your .bash_profile has run and it properly exports the 'ASTROBOA_REPOSITORIES_HOME' environment variable" unless ENV['ASTROBOA_REPOSITORIES_HOME']
318
321
  # error "#{problem_message} Environment variable 'JBOSS_HOME' is not set. Check that your .bash_profile has run and it properly exports the 'JBOSS_HOME' environment variable" unless ENV['JBOSS_HOME']
319
322
  # display "Check existence of required environment variables : OK"
320
- #
323
+ #
321
324
  # display "Check consistency between environment variables and Astroboa Server Settings File #{get_server_conf_file} ", false
322
325
  # error "#{problem_message} Missmatch of Astroboa installation dir in environmet variable 'ASTROBOA_HOME' (#{ENV['ASTROBOA_HOME']}) and server settings (#{server_config['install_dir']})" unless server_config['install_dir'] == ENV['ASTROBOA_HOME']
323
326
  # error "#{problem_message} Missmatch of repositories dir in environmet variable 'ASTROBOA_REPOSITORIES_HOME' (#{ENV['ASTROBOA_REPOSITORIES_HOME']}) and server config settings (#{server_config['repos_dir']})" unless server_config['repos_dir'] == ENV['ASTROBOA_REPOSITORIES_HOME']
324
327
  # error "#{problem_message} The mandatory repository 'identities' is not configured in server settings. Use the command 'repository:create identities' to create it." unless repository_in_server_config?(server_config, 'identities')
325
328
  # display ": OK"
326
329
  # end
327
-
330
+
328
331
  ok_message = "Astroboa installaion is ok.\nInstallation Path: #{server_config['install_dir']}\nRepository configuration and data are stored in: #{server_config['repos_dir']}"
329
332
  display ok_message
330
333
  end
331
-
332
-
334
+
335
+
333
336
  def java_ok?
334
337
  error('Please install java 6 (version 1.6.x) or java 7 (version 1.7.x) to proceed with installation') unless has_executable_with_version("java", "1\\.6|7", '-version')
335
338
  end
336
-
337
-
339
+
340
+
338
341
  def check_if_wget_is_installed
339
342
  error('Some files need to be downloaded. Please install \'wget\' and run the installation again') unless has_executable("wget")
340
343
  end
341
-
342
-
344
+
345
+
343
346
  def check_if_unzip_is_installed
344
347
  error('Some archives need to be unzipped. Please install \'unzip\' and run the installation again') unless has_executable("unzip")
345
348
  end
346
-
347
-
349
+
350
+
348
351
  def download_server_components
349
352
  # create installation directory
350
353
  begin
@@ -352,29 +355,40 @@ private
352
355
  rescue SystemCallError => e
353
356
  error "Failed to create installation directory '#{@install_dir}' \n the Error is: #{e.message}"
354
357
  end
355
-
358
+
356
359
  display "Dowloading astroboa server components to #{@install_dir}"
357
-
358
- # download torquebox
359
- download_package(@torquebox_download_url, @install_dir) unless File.size?(File.join(@install_dir, @torquebox_package)) == 173153188
360
-
360
+
361
+ # download astroboa version file
362
+ download_package(@astroboa_version_download_url, @install_dir)
363
+
361
364
  # download torquebox version file
362
- download_package(@torquebox_version_download_url, @install_dir) unless File.size?(File.join(@install_dir, @torquebox_version_file)) == 6
363
-
365
+ download_package(@torquebox_version_download_url, @install_dir)
366
+
367
+ torquebox_file_size = getFileSizeFromVersionFile(@torquebox_version_download_url.split('/').last)
368
+ already_saved_torquebox_file_size = File.size?(File.join(@install_dir, @torquebox_package))
369
+ astroboa_file_size = getFileSizeFromVersionFile(@astroboa_version_download_url.split('/').last)
370
+ already_saved_astroboa_file_size = File.size?(File.join(@install_dir, @astroboa_ear_package))
371
+
372
+ # download torquebox
373
+ download_package(@torquebox_download_url, @install_dir) unless already_saved_torquebox_file_size == torquebox_file_size
374
+
364
375
  # download astroboa ear
365
- download_package(@astroboa_ear_download_url, @install_dir) unless File.size?(File.join(@install_dir, @astroboa_ear_package)) == 63783475
366
-
367
- # download astroboa version file
368
- download_package(@astroboa_version_download_url, @install_dir) unless File.size?(File.join(@install_dir, @astroboa_version_file)) == 15
369
-
376
+ download_package(@astroboa_ear_download_url, @install_dir) unless already_saved_astroboa_file_size == astroboa_file_size
377
+
370
378
  # download astroboa setup templates
371
- download_package(@astroboa_setup_templates_download_url, @install_dir) unless File.size?(File.join(@install_dir, @astroboa_setup_templates_package)) == 11030750
372
-
379
+ download_package(@astroboa_setup_templates_download_url, @install_dir)
380
+
373
381
  # download astroboa schemas
374
- download_package(@schemas_download_url, @install_dir) unless File.size?(File.join(@install_dir, @schemas_package)) == 28426
382
+ download_package(@schemas_download_url, @install_dir)
375
383
  end
376
-
377
-
384
+
385
+ def getFileSizeFromVersionFile(file_name)
386
+ File.open(File.join(@install_dir, file_name)).each do |line|
387
+ return line.split(",").last.to_i
388
+ end
389
+ end
390
+
391
+
378
392
  def download_package_with_wget(package_url, install_dir)
379
393
  command = %(bash -c 'wget -c --directory-prefix=#{install_dir} #{package_url} 2>>#{log_file}')
380
394
  package = package_url.split('/').last
@@ -382,14 +396,14 @@ private
382
396
  display "Downloading #{package}"
383
397
  error "Failed to download package '#{package}'. Check logfile #{log_file}" unless process_os_command command
384
398
  end
385
-
386
-
399
+
400
+
387
401
  def download_package(package_url, install_dir)
388
402
  package_uri = URI.parse package_url
389
403
  package = package_url.split('/').last
390
404
  file = File.join install_dir, package
391
405
  display "Downloading #{package} from #{package_uri.host} to #{file}"
392
-
406
+
393
407
  Net::HTTP.start package_uri.host, package_uri.port do |http|
394
408
  bytesDownloaded = 0
395
409
  http.request Net::HTTP::Get.new(package_uri.path) do |response|
@@ -408,19 +422,19 @@ private
408
422
  end
409
423
  end
410
424
  end
411
-
425
+
412
426
  log.info "#{package} downloaded successfully"
413
427
  end
414
-
415
-
428
+
429
+
416
430
  def install_server_components
417
431
  create_astroboa_user
418
432
  display "Installing server components to #{@install_dir}"
419
433
  install_torquebox
420
434
  install_astroboa
421
435
  end
422
-
423
-
436
+
437
+
424
438
  def create_astroboa_user
425
439
  # in mac os x we do not create a separate user
426
440
  user = 'astroboa'
@@ -432,26 +446,26 @@ private
432
446
  error "Failed to create user astroboa. Check logfile #{log_file}" unless process_os_command command
433
447
  end
434
448
  end
435
-
436
-
449
+
450
+
437
451
  def install_torquebox
438
452
  unzip_torquebox
439
453
  # we cannot use the ruby lib to unzip since it does not preserve file permissions
440
454
  #unzip_file(File.join(@install_dir, @torquebox_package), @install_dir)
441
455
  create_torquebox_symbolic_link
442
-
456
+
443
457
  # may be that we do not need this any more
444
458
  # add_torquebox_env_settings
445
459
  end
446
-
447
-
460
+
461
+
448
462
  def unzip_torquebox
449
463
  command = %(bash -c 'cd #{@install_dir} && #{extract_archive_command @torquebox_package} #{File.join(@install_dir, @torquebox_package)} 2>>#{log_file}')
450
464
  log.info "Installing torquebox with command: #{command}"
451
465
  error "Failed to install torquebox" unless process_os_command command
452
466
  end
453
-
454
-
467
+
468
+
455
469
  def create_torquebox_symbolic_link
456
470
  # create a symbolic link from the versioned directory to which torquebox was extracted (e.g. torquebox-2.0.cr1) to just 'torquebox'
457
471
  # we need this in order to create the required export paths once instead of recreating them each time torquebox is upgrated
@@ -463,13 +477,13 @@ private
463
477
  error %(Failed to create symbolic link from '#{File.join(@install_dir, torquebox_dir)}' to '#{File.join(@install_dir, "torquebox")}' \n the Error is: #{e.message})
464
478
  end
465
479
  end
466
-
467
-
480
+
481
+
468
482
  def add_torquebox_env_settings
469
483
  # add required environment settings to .bash_profile
470
484
  user_dir = File.expand_path("~astroboa") if linux?
471
485
  user_dir = ENV["HOME"] if mac_os_x?
472
-
486
+
473
487
  display "Adding required environment settings in #{user_dir}/.bash_profile"
474
488
  bash_profile_path = File.join(user_dir, ".bash_profile")
475
489
  settings_start_here_comment = '# ASTROBOA REQUIRED PATHS CONFIGURATION STARTS HERE'
@@ -477,7 +491,7 @@ private
477
491
  # remove any previous settings
478
492
  delete_file_content_between_regex(bash_profile_path, settings_start_here_comment, settings_end_here_comment) if File.exists? bash_profile_path
479
493
  # write the new settings
480
- File.open(bash_profile_path, 'a+') do |f|
494
+ File.open(bash_profile_path, 'a+') do |f|
481
495
  env_settings =<<SETTINGS
482
496
 
483
497
  #{settings_start_here_comment}
@@ -488,43 +502,43 @@ export JBOSS_HOME=$TORQUEBOX_HOME/jboss
488
502
  #{"export PATH=$JRUBY_HOME/bin:$PATH" if linux?}
489
503
  #{settings_end_here_comment}
490
504
  SETTINGS
491
-
505
+
492
506
  f.write env_settings
493
507
  end
494
508
  end
495
-
496
-
509
+
510
+
497
511
  def unzip_schemas
498
512
  unzip_file(File.join(@install_dir, @schemas_package), @install_dir)
499
513
  end
500
-
501
-
514
+
515
+
502
516
  def install_astroboa
503
517
  # unzip the templates first
504
518
  unzip_file(File.join(@install_dir, @astroboa_setup_templates_package), @install_dir)
505
-
519
+
506
520
  # unzip astroboa schemas that are used for user schema validation
507
521
  unzip_schemas
508
-
522
+
509
523
  jboss_dir = File.join(@install_dir, "torquebox", "jboss")
510
524
  jboss_modules_dir = File.join(jboss_dir, "modules")
511
525
  astroboa_setup_templates_dir = File.join(@install_dir, "astroboa-setup-templates")
512
-
526
+
513
527
  create_repo_dir
514
-
528
+
515
529
  install_astroboa_ear(jboss_dir)
516
-
530
+
517
531
  install_jdbc_modules(astroboa_setup_templates_dir, jboss_modules_dir)
518
532
 
519
533
  install_spring_modules(astroboa_setup_templates_dir, jboss_modules_dir)
520
-
534
+
521
535
  install_jboss_runtime_config(astroboa_setup_templates_dir, jboss_dir)
522
-
536
+
523
537
  install_jboss_config(astroboa_setup_templates_dir, jboss_dir)
524
-
538
+
525
539
  end
526
-
527
-
540
+
541
+
528
542
  def create_repo_dir
529
543
  # create directory for repository data and astroboa repositories configuration file
530
544
  begin
@@ -534,14 +548,14 @@ SETTINGS
534
548
  error "Failed to create repositories directory '#{@repo_dir}' \n the Error is: #{e.message}"
535
549
  end
536
550
  end
537
-
538
-
551
+
552
+
539
553
  def install_astroboa_ear(jboss_dir)
540
554
  FileUtils.cp File.join(@install_dir, @astroboa_ear_package), File.join(jboss_dir, "standalone", "deployments")
541
555
  display "Copying astroboa ear package into jboss deployments: OK"
542
556
  end
543
-
544
-
557
+
558
+
545
559
  def install_jdbc_modules(astroboa_setup_templates_dir, jboss_modules_dir)
546
560
  # copy both derby and postgres jdbc driver module
547
561
  # This is required since both derby and postgres modules have been specified as dependencies of astroboa.ear module
@@ -549,30 +563,30 @@ SETTINGS
549
563
  display "Copying derby jdbc driver module into jboss modules #{("(derby module is installed even if postgres has been selected)" unless @database == 'derby')}: OK"
550
564
  # copy postgres driver
551
565
  # if postgres has been specified in options then install the drivers for the specified version
552
- # else install drivers for postgres 9.1
566
+ # else install drivers for postgres 9.3
553
567
  postgres_db = @database
554
- postgres_db = 'postgres-9.1' if @database == 'derby'
568
+ postgres_db = 'postgres-9.3' if @database == 'derby'
555
569
  FileUtils.cp_r File.join(astroboa_setup_templates_dir, "jdbc-drivers", postgres_db, "org"), jboss_modules_dir
556
570
  display %(Copying #{postgres_db} jdbc driver module into jboss modules #{("(postgres drivers are copied even if derby has been selected)" if @database == 'derby')}: OK)
557
571
  end
558
-
559
-
572
+
573
+
560
574
  def install_spring_modules(astroboa_setup_templates_dir, jboss_modules_dir)
561
575
  # copy spring and snowdrop modules to jboss modules
562
576
  FileUtils.cp_r File.join(astroboa_setup_templates_dir, "jboss-modules", "org"), jboss_modules_dir
563
- display "Copying spring and snowdrop modules into jboss modules: OK"
577
+ display "Copying spring and snowdrop modules into jboss modules: OK"
564
578
  end
565
-
566
-
579
+
580
+
567
581
  def install_jboss_runtime_config(astroboa_setup_templates_dir, jboss_dir)
568
582
  # preserve original jboss runtime config and copy customized runtime config into jboss bin directory
569
583
  original_runtime_config = File.join(jboss_dir, "bin", "standalone.conf")
570
584
  FileUtils.cp original_runtime_config, "#{original_runtime_config}.original"
571
585
  FileUtils.cp File.join(astroboa_setup_templates_dir, "standalone.conf"), original_runtime_config
572
- display "Copying jboss runtime config into jboss bin: OK"
586
+ display "Copying jboss runtime config into jboss bin: OK"
573
587
  end
574
-
575
-
588
+
589
+
576
590
  def install_jboss_config(astroboa_setup_templates_dir, jboss_dir)
577
591
  # create jboss config from template and write it to jboss standalone configuration directory, preserving the original file
578
592
  original_jboss_config = File.join(jboss_dir, "standalone", "configuration", "standalone.xml")
@@ -582,24 +596,24 @@ SETTINGS
582
596
  render_template_to_file(jboss_config_template, context, original_jboss_config)
583
597
  display "Generating and copying jboss config into jboss standalone configuration directory: OK"
584
598
  end
585
-
586
-
599
+
600
+
587
601
  # currently not used - consider to remove
588
602
  def create_pgpass_file
589
603
  if @database.split("-").first == "postgres"
590
604
  pgpass_file = File.expand_path(File.join("~",".pgpass"))
591
605
  pgpass_file = File.expand_path(File.join("~astroboa",".pgpass")) unless RbConfig::CONFIG['host_os'] =~ /darwin/i
592
-
606
+
593
607
  pgpass_config = "localhost:5432:*:#{@database_admin}:#{@database_admin_password}"
594
-
608
+
595
609
  File.open(pgpass_file,"w") do |f|
596
610
  f.write(pgpass_config)
597
611
  end
598
612
  display "The file '#{pgpass_file}' has been created to give astroboa user permission to run postgres admin commands"
599
613
  end
600
614
  end
601
-
602
-
615
+
616
+
603
617
  def save_server_configuration
604
618
  config_file = File.expand_path(File.join('~', '.astroboa-conf.yml'))
605
619
  unless RbConfig::CONFIG['host_os'] =~ /darwin/i
@@ -614,18 +628,18 @@ SETTINGS
614
628
  server_config['database_admin'] = @database_admin
615
629
  server_config['database_admin_password'] = @database_admin_password
616
630
  server_config['database_server'] = @database_server
617
-
631
+
618
632
  File.open(config_file,"w") do |f|
619
633
  f.write(YAML.dump(server_config))
620
634
  end
621
635
  display "The server configuration have been added to configuration file '#{config_file}'"
622
-
636
+
623
637
  # config file has sensitive info like the db admin password
624
638
  # let's protect it from reading by others
625
639
  FileUtils.chmod 0600, config_file
626
640
  end
627
-
628
-
641
+
642
+
629
643
  def create_central_identity_repository
630
644
  repo_name = 'identities'
631
645
  repo_config = {
@@ -634,57 +648,57 @@ SETTINGS
634
648
  AstroboaCLI::Command::Repository.new([repo_name], repo_config).create
635
649
  display "Create Central 'Identities and Apps' Repository with name 'identities' : OK"
636
650
  end
637
-
651
+
638
652
  def set_astroboa_owner
639
- # In mac os x astroboa is installed and run under the ownership of the user that runs the installation command.
653
+ # In mac os x astroboa is installed and run under the ownership of the user that runs the installation command.
640
654
  # If installation is done with sudo (i.e. when installation dir is not in users home) then we need to change the ownership of astroboa installation to the current user.
641
655
  if mac_os_x? && running_with_sudo?
642
656
  user = ENV['USER']
643
657
  FileUtils.chown_R(user, nil, @install_dir)
644
658
  display "Change (recursively) user owner of #{@install_dir} to #{user}: OK"
645
-
659
+
646
660
  # if repositories dir is outside the main install dir then we should change the ownership there too
647
661
  unless File.join(@install_dir, 'repositories') == @repo_dir
648
662
  FileUtils.chown_R(user, nil, @repo_dir)
649
663
  display "Change (recursively) user owner of #{@repo_dir} to #{user}: OK"
650
664
  end
651
-
665
+
652
666
  end
653
-
667
+
654
668
  # In linux a special user 'astroboa' and group 'astroboa' is created for owning a running astroboa.
655
669
  # So we need to change the ownership of the installation dir and the repositories dir to belong to user 'astroboa' and group 'astroboa'
656
670
  if linux?
657
-
671
+
658
672
  FileUtils.chown_R('astroboa', 'astroboa', @install_dir)
659
673
  display "Change (recursively) user and group owner of #{@install_dir} to 'astroboa': OK"
660
-
674
+
661
675
  # if repositories dir is outside the main install dir then we should change the ownership there too
662
676
  unless File.join(@install_dir, 'repositories') == @repo_dir
663
677
  FileUtils.chown_R('astroboa', 'astroboa', @repo_dir)
664
678
  display "Change (recursively) user and group owner of #{@repo_dir} to 'astroboa': OK"
665
679
  end
666
-
680
+
667
681
  end
668
682
  end
669
-
683
+
670
684
  def cleanup_installation
671
685
  display "Cleaning not required Installation packages..."
672
686
  FileUtils.rm File.join(@install_dir, @torquebox_package)
673
687
  display "Removed torquebox package"
674
-
688
+
675
689
  FileUtils.rm File.join(@install_dir, @astroboa_ear_package)
676
690
  display "Removed astroboa ear package"
677
-
691
+
678
692
  FileUtils.rm File.join(@install_dir, @astroboa_setup_templates_package)
679
693
  display "Removed setup templates package"
680
-
694
+
681
695
  FileUtils.rm File.join(@install_dir, @schemas_package)
682
696
  display "Removed schemas package"
683
-
697
+
684
698
  display "Installation cleanup: OK"
685
699
  end
686
700
 
687
701
  end
688
-
689
-
690
-
702
+
703
+
704
+
@@ -353,7 +353,7 @@ module AstroboaCLI
353
353
 
354
354
  ruby_version_numbers = RUBY_VERSION.split(".")
355
355
 
356
- return false unless ruby_version_numbers[0].to_i == 1 && ruby_version_numbers[1].to_i >= 9
356
+ return false unless (ruby_version_numbers[0].to_i == 1 && ruby_version_numbers[1].to_i >= 9) || ruby_version_numbers[0].to_i == 2
357
357
  return true
358
358
  end
359
359
 
@@ -369,19 +369,19 @@ module AstroboaCLI
369
369
  $ brew install rbenv
370
370
  $ brew install ruby-build
371
371
 
372
- To install ruby version 1.9.3-p194 do:
373
- $ rbenv install 1.9.3-p194
372
+ To install ruby version 2.1.1 do:
373
+ $ rbenv install 2.1.1
374
374
 
375
375
  To set the global version of Ruby to be used in all your shells do:
376
- $ rbenv global 1.9.3-p194
376
+ $ rbenv global 2.1.1
377
377
 
378
- To set ruby 1.9.3-p194 as a local per-project ruby version by writing the version name to an .rbenv-version file in the current directory do:
378
+ To set ruby 2.1.1 as a local per-project ruby version by writing the version name to an .rbenv-version file in the current directory do:
379
379
 
380
- $ rbenv local 1.9.3-p194
380
+ $ rbenv local 2.1.1
381
381
 
382
- To set ruby 1.9.3-p194 as the version to be used only in the current shell (sets the RBENV_VERSION environment variable in your shell) do:
382
+ To set ruby 2.1.1 as the version to be used only in the current shell (sets the RBENV_VERSION environment variable in your shell) do:
383
383
 
384
- $ rbenv shell 1.9.3-p194
384
+ $ rbenv shell 2.1.1
385
385
 
386
386
  -------------------------------
387
387
  If you prefer to use 'rvm' as your ruby management utility use the following command to install it for a single user:
@@ -390,15 +390,15 @@ module AstroboaCLI
390
390
 
391
391
  For multi-user installation and detailed rvm installation instructions check: https://rvm.io/rvm/install/
392
392
 
393
- After 'rvm' has been installed run the following commands to install ruby 1.9.3-p194:
394
- rvm install 1.9.3-p194
395
- rvm use 1.9.3-p194
393
+ After 'rvm' has been installed run the following commands to install ruby 2.1.1:
394
+ rvm install 2.1.1
395
+ rvm use 2.1.1
396
396
  RUBY_INSTALL_MESSAGE
397
397
 
398
398
  ruby_wrong_version_message =<<-RUBY_VERSION_MESSAGE
399
- It seems that you are not running ruby 1.9.x.
399
+ It seems that you are not running ruby 1.9.x. or later
400
400
  Your current Ruby Version is: #{RUBY_VERSION}
401
- Astroboa CLI requires your ruby version to be 1.9.x (e.g. 1.9.2 or 1.9.3).
401
+ Astroboa CLI requires your ruby version to be 1.9.x or later (e.g. 1.9.2 or 1.9.3 or 2.1.1).
402
402
 
403
403
  #{ruby_installation_instructions_message}
404
404
  RUBY_VERSION_MESSAGE
@@ -1,3 +1,3 @@
1
1
  module AstroboaCLI
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -1,4 +1,4 @@
1
1
  Feature: Astroboa Command Line Interface
2
- Develop an command line interface to allow
2
+ Develop a command line interface to allow
3
3
  easy management of astroboa platform as well as
4
4
  easy deployment of ruby apps to astroboa platform.
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: astroboa-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - BETACONCEPT
9
8
  - Gregory Chomatas
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-11-10 00:00:00.000000000 Z
12
+ date: 2015-11-07 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: progressbar
@@ -92,10 +91,26 @@ dependencies:
92
91
  - - ! '>='
93
92
  - !ruby/object:Gem::Version
94
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: zip-zip
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
95
110
  description: astroboa-cli provides commands for installing astroboa platform, creating
96
111
  repositories, taking backups, deploying applications to astroboa, etc.
97
112
  email:
98
- - support@betaconcept.com
113
+ - gchomatas@betaconcept.com
99
114
  executables:
100
115
  - astroboa-cli
101
116
  extensions: []
@@ -139,12 +154,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
154
  - - ! '>='
140
155
  - !ruby/object:Gem::Version
141
156
  version: '0'
157
+ segments:
158
+ - 0
159
+ hash: -4227649006817969992
142
160
  required_rubygems_version: !ruby/object:Gem::Requirement
143
161
  none: false
144
162
  requirements:
145
163
  - - ! '>='
146
164
  - !ruby/object:Gem::Version
147
165
  version: '0'
166
+ segments:
167
+ - 0
168
+ hash: -4227649006817969992
148
169
  requirements: []
149
170
  rubyforge_project: astroboa-cli
150
171
  rubygems_version: 1.8.23