astroboa-cli 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/astroboa-cli.gemspec CHANGED
@@ -28,5 +28,6 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency 'rubyzip'
29
29
  s.add_runtime_dependency 'erubis'
30
30
  s.add_runtime_dependency 'nokogiri', '>= 1.5.5'
31
+ s.add_runtime_dependency 'colorize'
31
32
  s.executables = ["astroboa-cli"]
32
33
  end
@@ -161,7 +161,7 @@ class AstroboaCLI::Command::Model < AstroboaCLI::Command::Base
161
161
  #
162
162
  # -d, --models_dir MODELS_DIR # The directory (absolute path) where your models are stored. # The generated XML Schema file will be written inside '{MODELS_DIR}/xsd/' # If directory {MODELS_DIR}/xsd does not exist, it will be created.
163
163
  # -n, --namespace NAMESPACE # The namespace to be used for your new object type # (i.e. the corresponding entity tag will be namespaced with the provided namespace) # If not specified, the default namespace 'http://astroboa/schema/{NAME}' will be used (NAME is the name of your object type).
164
- # -l, --localized_labels OBJECT_TYPE_LABELS # Provide friendly object type names for different languages # By default the 'NAME' of the object type will be used as the english label # Example: -l en:Movie,fr:Film,es:Filme
164
+ # -l, --localized_labels OBJECT_TYPE_LABELS # Provide friendly object type names for different languages # The format is "locale1:localized_string1,locale2:localized_string2" # YOU SHOULD SURROUND THE LABELS WITH SINGLE OR DOUBLE QUOTES # By default the 'NAME' of the object type will be used as the english label # Example: -l "en:Movie,fr:Film,es:Filme"
165
165
  #
166
166
  def create_object_type
167
167
  if object_type = args.shift
@@ -221,7 +221,7 @@ class AstroboaCLI::Command::Model < AstroboaCLI::Command::Base
221
221
  # -x, --max_values MAX_NUM_OF_VALUES # The maximum number of values that are permitted for this property. # Specify '1' if you want to store only one value. # Specify 'unbounded' if you want to store a list of values without an upper limit in list size. # Default is '1'.
222
222
  # -n, --min_values MIN_NUM_VALUES # The minimum number of values that are permitted for this property. # Specify '0' to designate a non mandatory field. # Specify '1' to designate a mandatory field. # Default is '0'.
223
223
  # -p, --parent PROPERTY_NAME # The name of an EXISTING property that will contain this property. # The parent property should always be of type 'complex'. # Properties of type 'complex' act as a grouping container for their child properties. # Imagine them as named fieldsets of a form # E.g. The 'complex' property 'address' is the parent (container) of the properties 'street', 'city', 'zipcode', 'country'. # You may arbitrarily nest 'complex' properties inside other 'complex' properties to create property trees.
224
- # -l, --localized_labels PROPERTY_NAME_LABELS # Provide friendly names for the property in different languages # By default the 'PROPERTY_NAME' will be used as the english label # Example: -l en:First Name,fr:Prénom,es:Primer Nombre
224
+ # -l, --localized_labels PROPERTY_NAME_LABELS # Provide friendly names for the property in different languages # The format is "locale1:localized_string1,locale2:localized_string2" # YOU SHOULD SURROUND THE LABELS WITH SINGLE OR DOUBLE QUOTES # By default the 'PROPERTY_NAME' will be used as the english label # Example: -l "en:First Name,fr:Prénom,es:Primer Nombre"
225
225
  # -u, --update # Use this option to specify whether you want to update an EXISTING property. # If the property with 'PROPERTY_NAME' exists and you do not use this option then NO UPDATE will be performed. # The default values for property attributes are not used during a property update. # ONLY the property attributes that are expicitly specified with the options will be updated. # E.g. if you give 'astroboa-cli model:add_property age person -t integer --update' # and the property 'age' exists then only its 'type' will be changed. # The 'minValues', 'maxValues', 'localized_labels' will keep their existing values.
226
226
  #
227
227
  def add_property
@@ -19,7 +19,7 @@ class AstroboaCLI::Command::Repository < AstroboaCLI::Command::Base
19
19
  # A database will also be created to store repository data (except blobs).
20
20
  # The database server, db user and db password that have been configured during astroboa server setup will be used.
21
21
  #
22
- # -l, --localized_labels REPO_LABELS # Provide friendly labels for different languages # By default the 'REPOSITORY_NAME' will be used as the english label # Example: -l en:Dali Paintings,fr:Dali Peintures,es:Dali Pinturas
22
+ # -l, --localized_labels REPO_LABELS # Provide friendly labels for different languages # The format is "locale1:localized_string1,locale2:localized_string2" # YOU SHOULD SURROUND THE LABELS WITH SINGLE OR DOUBLE QUOTES # By default the 'REPOSITORY_NAME' will be used as the english label # Example: -l "en:Dali Paintings,fr:Dali Peintures,es:Dali Pinturas"
23
23
  # -d, --domain_name REPO_DOMAIN_NAME # Specify the fully qualified domain name and port under which all the repository resources will be exposed by the REST API # The default is 'localhost:8080' # If you specify other than the default (e.g. www.mydomain.com) you need to appropriately setup a reverse proxy in front of astroboa
24
24
  # -p, --api_base_path REST_API_BASE_PATH # Specify the base_path of the REST API URLs # The default is '/resource-api' # If you provide other than the default you should appropriately setup a reverse proxy in front of astroboa
25
25
  # -n, --db_name DATABASE_NAME # Specify the name of the database to create # Default is REPOSITORY_NAME (i.e. the name of the new repository)
@@ -33,10 +33,9 @@ class AstroboaCLI::Command::Repository < AstroboaCLI::Command::Base
33
33
  #
34
34
  # Specify i18n labels for the repository name.
35
35
  # Expose the repo resources under http://www.art.com/art-api/dali_paintings
36
- # $ astroboa-cli repository:create dali_paintings -l en:Dali Paintings,fr:Dali Peintures,es:Dali Pinturas -d www.art.com -p art-api
36
+ # $ astroboa-cli repository:create dali_paintings -l "en:Dali Paintings,fr:Dali Peintures,es:Dali Pinturas" -d www.art.com -p art-api
37
37
  #
38
38
  def create
39
-
40
39
  if repository_name = args.shift
41
40
  repository_name = repository_name.strip
42
41
  else
@@ -65,11 +64,6 @@ class AstroboaCLI::Command::Repository < AstroboaCLI::Command::Base
65
64
  schema_dir = File.join(repo_dir, "astroboa_schemata")
66
65
  FileUtils.mkdir(schema_dir)
67
66
  display %(Create dir '#{schema_dir}': OK)
68
-
69
- # This is not required any more TO BE DELETED
70
- #internal_repo_dir = File.join(repo_dir, "repository")
71
- #FileUtils.mkdir(internal_repo_dir)
72
- #display %(Create dir '#{internal_repo_dir}': OK)
73
67
 
74
68
  # create postgres database
75
69
  unless server_configuration['database'] == 'derby'
@@ -89,6 +83,29 @@ class AstroboaCLI::Command::Repository < AstroboaCLI::Command::Base
89
83
 
90
84
  # save repo configuration into astroboa server config file
91
85
  add_repo_conf_to_server_conf(server_configuration, repository_name)
86
+
87
+ # change ownership of repo dir
88
+ # In mac os x astroboa is installed and run under the ownership of the user that runs the installation command.
89
+ # So if the same user that did the install runs the repo creation command ownership is ok.
90
+ # if however repo creation is done by another user (using sudo) then we need to change the ownership of repo dir
91
+ # to the user that installed and thus owns astroboa.
92
+ if mac_os_x?
93
+ astroboa_owner_uid = File.stat(astroboa_dir).uid
94
+ astroboa_owner = Etc.getpwuid(astroboa_owner_uid).name
95
+ process_uid = Process.uid
96
+ if astroboa_owner_uid != process_uid
97
+ FileUtils.chown_R(astroboa_owner, nil, repo_dir)
98
+ display "Change (recursively) user owner of #{repo_dir} to #{astroboa_owner}: OK"
99
+ end
100
+ end
101
+
102
+ # In linux a special user 'astroboa' and group 'astroboa' is created for owning a running astroboa.
103
+ # So we need to change the ownership of the installation dir and the repositories dir to
104
+ # belong to user 'astroboa' and group 'astroboa'
105
+ if linux?
106
+ FileUtils.chown_R('astroboa', 'astroboa', repo_dir)
107
+ display "Change (recursively) user and group owner of #{repo_dir} to 'astroboa': OK"
108
+ end
92
109
 
93
110
  rescue => e
94
111
  display %(An error has occured \n The error is: '#{e.to_s}' \n The error trace is: \n #{e.backtrace.join("\n")})
@@ -147,19 +164,31 @@ class AstroboaCLI::Command::Repository < AstroboaCLI::Command::Base
147
164
  FileUtils.rm_r repo_dir, :secure=>true
148
165
  display "Remove #{repo_dir} : OK"
149
166
 
167
+ # get the name of the repo database before we remove the server configuration
168
+ database_name = server_configuration['repositories'][repository_name]['database']
169
+
150
170
  # remove repo conf from astroboa server configuration
151
171
  delete_repo_conf_from_server_conf(server_configuration, repository_name)
152
172
 
153
173
  # remove the repo database, we leave it last so that everything else has been removed in the case something goes wrong
154
174
  # with db removal
155
- begin
156
- drop_postgresql_db(server_configuration, database_name) if server_configuration['database'] =~ /postgres/
157
- rescue
158
- display %(The repository has been disabled and all configuration and related directories have been removed except the database.)
159
- display %(It is safe to manually remove the database)
160
- end
175
+ if server_configuration['database'] =~ /postgres/
161
176
 
162
-
177
+ error <<-MSG.gsub(/^ {6}/, '') unless database_name
178
+ It is not possible to remove the database because the database name for this repository
179
+ was not found in the server configuration file.
180
+ However the repository has been disabled and all configuration and related directories have been removed except the database.
181
+ So it is safe to manually remove the database.
182
+ MSG
183
+
184
+ begin
185
+ drop_postgresql_db(server_configuration, database_name)
186
+ rescue => e
187
+ display %(An error has occured while deleting the database. The error is #{e.message}.)
188
+ display %(The repository has been disabled and all configuration and related directories have been removed except the database.)
189
+ display %(It is safe to manually remove the database)
190
+ end
191
+ end
163
192
  end
164
193
 
165
194
 
@@ -333,11 +362,11 @@ private
333
362
  if conf_exists
334
363
  current_date = DateTime.now().strftime('%Y-%m-%dT%H.%M')
335
364
  FileUtils.cp astroboa_repos_config, "#{astroboa_repos_config}.#{current_date}"
336
- display %(Save previous repositories configuration file to #{astroboa_repos_config}.#{current_date} : OK)
365
+ display %(Save previous repositories configuration file to '#{astroboa_repos_config}.#{current_date}' : OK)
337
366
  end
338
367
 
339
368
  FileUtils.mv new_astroboa_repos_config, astroboa_repos_config
340
- display %(Created new repositories configuration file #{astroboa_repos_config})
369
+ display %(Create new repositories configuration file '#{astroboa_repos_config}' : OK)
341
370
  end
342
371
 
343
372
 
@@ -380,6 +409,7 @@ private
380
409
  repo_domain_name = options[:domain_name] ||= 'localhost:8080'
381
410
  api_base_path = options[:api_base_path] ||= '/resource-api'
382
411
  localized_labels = options[:localized_labels] ||= "en:#{repository_name}"
412
+ database_name = options[:db_name] ||= repository_name
383
413
 
384
414
  server_configuration['repositories'] ||= {}
385
415
  repository = {}
@@ -388,6 +418,7 @@ private
388
418
  repository['serverAliasURL'] = "http://#{repo_domain_name}"
389
419
  repository['restfulApiBasePath'] = api_base_path
390
420
  repository['localized_labels'] = localized_labels
421
+ repository['database'] = database_name
391
422
  server_configuration['repositories'][repository_name] = repository
392
423
  save_server_configuration(server_configuration)
393
424
  display "Add repository configuration to server configuration file '#{get_server_conf_file}' : OK"
@@ -21,14 +21,25 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
21
21
  # + You should have already installed java 1.6 and ruby 1.9.x
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
- # + If you choose a database other than derby then the database should be already installed and running and you should know the db admin account password
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
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
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)
31
- # -p, --database_admin_password PASSWORD # The password of the database administrator # Defaults to empty string # Not required if database 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
+ #
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
+ # 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)
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)
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
42
+ # and only by the user that does the installation in mac os x.
32
43
  #
33
44
  def install
34
45
  @torquebox_download_url = 'http://www.astroboa.org/releases/astroboa/latest/torquebox-dist-2.0.3-bin.zip'
@@ -70,7 +81,7 @@ class AstroboaCLI::Command::Server < AstroboaCLI::Command::Base
70
81
 
71
82
  if @database.split("-").first == "postgres"
72
83
  @database_admin = options[:database_admin] ||= "postgres"
73
- @database_admin_password = options[:database_admin_password] ||= ""
84
+ @database_admin_password = get_password("Please enter the password for postgresql admin user '#{@database_admin}': ")
74
85
  else
75
86
  @database_admin = "sa"
76
87
  @database_admin_password = ""
@@ -237,14 +248,38 @@ private
237
248
  # check if unzip command is available
238
249
  check_if_unzip_is_installed
239
250
 
240
- # check if 'pg' gem is installed if repositories will be backed by postgres
241
- error <<-MSG.gsub(/^ {4}/, '') if @database.split("-").first == "postgres" && !gem_available?('pg')
242
- You should manually install the 'pg' gem if you want to create repositories backed by postgres
243
- astroboa-cli gem does not automatically install 'pg' gem since in some environments (e.g. MAC OS X) this might require
244
- to have a local postgres already installed, which in turn is too much if you do not care about postgres.
245
- In *Ubuntu Linux* run first 'sudo apt-get install libpq-dev' and then run 'gem install pg'.
246
- For MAC OS x read http://deveiate.org/code/pg/README-OS_X_rdoc.html to learn how to install the 'pg' gem.
247
- MSG
251
+ #if repositories will be backed by postgres
252
+ if @database.split("-").first == "postgres"
253
+
254
+ # check if 'pg' gem is installed
255
+ if gem_available?('pg')
256
+ display "Checking if 'pg' gem is installed (required for creating postgres db): OK"
257
+ else
258
+ error <<-MSG.gsub(/^ {4}/, '')
259
+ 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
261
+ to have a local postgres already installed, which in turn is too much if you do not care about postgres.
262
+ In *Ubuntu Linux* run first 'sudo apt-get install libpq-dev' and then run 'gem install pg'.
263
+ For MAC OS x read http://deveiate.org/code/pg/README-OS_X_rdoc.html to learn how to install the 'pg' gem.
264
+ MSG
265
+ end
266
+
267
+ # check if we can connect to postgres with the specified db admin account
268
+ if postgres_connectivity?(@database_server, @database_admin, @database_admin_password)
269
+ display "Checking if we can connect to postgres with the specified db admin account: OK"
270
+ else
271
+ error <<-MSG.gsub(/^ {4}/, '')
272
+ Could not connect to the postgres db server (@database_server)
273
+ with the db admin user (@database_admin) and the password you have specified.
274
+ 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
277
+ and also check ip/user restrictions in pg_hba.conf).
278
+ Finally check that there are no firewall rules in this machine or in the machine
279
+ that postgres runs that prevent the connection (postgres runs by default on port 5432)
280
+ MSG
281
+ end
282
+ end
248
283
  end
249
284
 
250
285
 
@@ -584,13 +619,17 @@ SETTINGS
584
619
  f.write(YAML.dump(server_config))
585
620
  end
586
621
  display "The server configuration have been added to configuration file '#{config_file}'"
622
+
623
+ # config file has sensitive info like the db admin password
624
+ # let's protect it from reading by others
625
+ FileUtils.chmod 0600, config_file
587
626
  end
588
627
 
589
628
 
590
629
  def create_central_identity_repository
591
630
  repo_name = 'identities'
592
631
  repo_config = {
593
- 'localized_labels' => 'en:User and App Identities,el:Ταυτότητες Χρηστών και Εφαρμογών'
632
+ localized_labels: 'en:User and App Identities,el:Ταυτότητες Χρηστών και Εφαρμογών'
594
633
  }
595
634
  AstroboaCLI::Command::Repository.new([repo_name], repo_config).create
596
635
  display "Create Central 'Identities and Apps' Repository with name 'identities' : OK"
@@ -598,7 +637,7 @@ SETTINGS
598
637
 
599
638
  def set_astroboa_owner
600
639
  # In mac os x astroboa is installed and run under the ownership of the user that runs the installation command.
601
- # If installation is done with sudo then we need to change the ownership of astroboa installation to the current user.
640
+ # 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.
602
641
  if mac_os_x? && running_with_sudo?
603
642
  user = ENV['USER']
604
643
  FileUtils.chown_R(user, nil, @install_dir)
@@ -3,6 +3,7 @@
3
3
  require 'yaml'
4
4
  require 'zip/zip'
5
5
  require 'nokogiri'
6
+ require 'colorize'
6
7
 
7
8
  module AstroboaCLI
8
9
  module Util
@@ -463,23 +464,43 @@ module AstroboaCLI
463
464
  end
464
465
 
465
466
 
466
- def load_pg_library(server_configuration)
467
+ def load_pg_library
467
468
  # try to load the 'pg' library if repository is backed by postgres
468
- unless server_configuration['database'] == 'derby'
469
- error <<-MSG unless gem_available?('pg')
470
- You should manually install the 'pg' gem if you want to create repositories backed by postgres
471
- astroboa-cli gem does not automatically install 'pg' gem since in some environments (e.g. MAC OS X) this might require
472
- to have a local postgres already installed, which in turn is too much if you do not care about postgres.
473
- In *Ubuntu Linux* run first 'sudo apt-get install libpq-dev' and then run 'gem install pg'.
474
- For MAC OS x read http://deveiate.org/code/pg/README-OS_X_rdoc.html to learn how to install the 'pg' gem.
475
- MSG
469
+ error <<-MSG unless gem_available?('pg')
470
+ You should manually install the 'pg' gem if you want to create repositories backed by postgres
471
+ astroboa-cli gem does not automatically install 'pg' gem since in some environments (e.g. MAC OS X) this might require
472
+ to have a local postgres already installed, which in turn is too much if you do not care about postgres.
473
+ In *Ubuntu Linux* run first 'sudo apt-get install libpq-dev' and then run 'gem install pg'.
474
+ For MAC OS x read http://deveiate.org/code/pg/README-OS_X_rdoc.html to learn how to install the 'pg' gem.
475
+ MSG
476
476
 
477
- require 'pg'
478
- end
477
+ require 'pg'
478
+ end
479
+
480
+
481
+ def postgres_connectivity?(database_server, database_user, database_user_password)
482
+ load_pg_library
483
+
484
+ begin
485
+ conn = PG.connect(
486
+ host: database_server,
487
+ port: '5432',
488
+ dbname: 'postgres',
489
+ user: database_user,
490
+ password: database_user_password)
491
+ conn != nil ? true : false
492
+ rescue PG::Error => e
493
+ display %(An error has occured while trying to establish a connection to postgres database)
494
+ display %(The error is: "#{e.message}")
495
+ false
496
+ ensure
497
+ conn.finish if conn && !conn.finished?
498
+ end
479
499
  end
480
500
 
501
+
481
502
  def create_postgresql_db(server_configuration, database_name)
482
- load_pg_library(server_configuration)
503
+ load_pg_library
483
504
 
484
505
  database_admin, database_admin_password, database_server = get_postgresql_config(server_configuration)
485
506
 
@@ -519,7 +540,7 @@ module AstroboaCLI
519
540
 
520
541
 
521
542
  def drop_postgresql_db(server_configuration, database_name)
522
- load_pg_library(server_configuration)
543
+ load_pg_library
523
544
 
524
545
  database_admin, database_admin_password, database_server = get_postgresql_config(server_configuration)
525
546
 
@@ -533,12 +554,12 @@ module AstroboaCLI
533
554
 
534
555
  # check if db exists
535
556
  res = conn.exec("SELECT COUNT(*) FROM pg_database WHERE datname=$1",[database_name])
536
- unless res.entries[0]['count'] == 0
557
+ if res.entries[0]['count'] == 0
537
558
  display "Cannot remove database #{database_name} because it does not exist"
538
559
  raise
539
560
  end
540
561
 
541
- res = conn.exec("DROP DATABASE $1", [database_name])
562
+ res = conn.exec("DROP DATABASE #{database_name}")
542
563
  if res.result_status == PG::Result::PGRES_COMMAND_OK
543
564
  display %(Delete Postges database "#{database_name}" : OK)
544
565
  else
@@ -578,55 +599,18 @@ module AstroboaCLI
578
599
  end
579
600
 
580
601
 
581
- # Not used because only works in jruby, TO BE REMOVED
582
- def create_postgresql_db_with_jdbc(server_configuration, database_name, repo_dir)
583
- database_admin, database_admin_password, database_server = get_postgresql_config(server_configuration)
602
+ def get_password(msg)
603
+ password = ""
604
+ print msg.blue.underline
584
605
  begin
585
- ActiveRecord::Base.establish_connection(
586
- :adapter => 'jdbcpostgresql',
587
- :database => "postgres",
588
- :username => database_admin,
589
- :password => database_admin_password,
590
- :host => database_server,
591
- :port => 5432)
592
- ActiveRecord::Base.connection.create_database database_name, :encoding => 'unicode'
593
- ActiveRecord::Base.connection.disconnect!
594
- ActiveRecord::Base.remove_connection
595
-
596
- display %(Create Postges database "#{database_name}" : OK)
597
- rescue ActiveRecord::StatementInvalid => e
598
- if e.message =~ /database "#{database_name}" already exists/
599
- display "Database #{database_name} exists. You may run the command with --db_name repo_db_name to specify a different database name"
600
- else
601
- display %(An error has occured during the creation of postgres database "#{database_name}")
602
- display %(The error trace is \n #{e.backtrace.join("\n")})
603
- end
604
-
605
- raise
606
- end
607
- end
608
-
609
-
610
- # Not used because only works in jruby, TO BE REMOVED
611
- def drop_postgresql_db_with_jdbc(server_configuration, database_name)
612
- database_admin, database_admin_password, database_server = get_postgresql_config(server_configuration)
613
- begin
614
- ActiveRecord::Base.establish_connection(
615
- :adapter => 'jdbcpostgresql',
616
- :database => "postgres",
617
- :username => database_admin,
618
- :password => database_admin_password,
619
- :host => database_server,
620
- :port => 5432)
621
- ActiveRecord::Base.connection.drop_database database_name
622
- ActiveRecord::Base.connection.disconnect!
623
- ActiveRecord::Base.remove_connection
624
-
625
- display %(Delete Postges database "#{database_name}" : OK)
626
- rescue ActiveRecord::StatementInvalid => e
627
- display %(An error has occured during the deletion of postgres database "#{database_name}")
628
- display %(The error trace is \n #{e.backtrace.join("\n")})
629
- raise
606
+ system "stty -echo 2>/dev/null"
607
+ password = STDIN.gets.chomp
608
+ system "stty echo 2>/dev/null"
609
+ puts
610
+ password
611
+ rescue => e
612
+ system "stty echo"
613
+ error "An error occurred. The error is: #{e.message}"
630
614
  end
631
615
  end
632
616
 
@@ -1,3 +1,3 @@
1
1
  module AstroboaCLI
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: astroboa-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-07 00:00:00.000000000 Z
13
+ date: 2012-11-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: progressbar
@@ -76,6 +76,22 @@ dependencies:
76
76
  - - ! '>='
77
77
  - !ruby/object:Gem::Version
78
78
  version: 1.5.5
79
+ - !ruby/object:Gem::Dependency
80
+ name: colorize
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
79
95
  description: astroboa-cli provides commands for installing astroboa platform, creating
80
96
  repositories, taking backups, deploying applications to astroboa, etc.
81
97
  email: