diff options
author | Azul <azul@riseup.net> | 2013-12-22 15:58:21 +0100 |
---|---|---|
committer | Azul <azul@riseup.net> | 2013-12-22 15:58:21 +0100 |
commit | 8c83e7a78385da8d15d274ee86f126a27f4763c7 (patch) | |
tree | c0a2e322b8f1bff68ba439e80e770f5fd3a2a15e | |
parent | 12dbeefe693e5432416ec8019368e591c526736b (diff) |
Version 0.3.1 with new flags --run-once, --rerun and --overwrite-security0.3.1
--run-once will exit once all current changes have been processed
--rerun will process all users again even those that were processed before
--overwrite-security will overwrite security for user databases even
if it has been set before.
-rw-r--r-- | Gemfile.lock | 10 | ||||
-rw-r--r-- | Readme.md | 31 | ||||
-rwxr-xr-x | bin/tapicero | 17 | ||||
-rw-r--r-- | lib/tapicero.rb | 4 | ||||
-rw-r--r-- | lib/tapicero/user_database.rb | 2 | ||||
-rw-r--r-- | lib/tapicero/version.rb | 3 | ||||
-rw-r--r-- | tapicero.gemspec | 2 |
7 files changed, 47 insertions, 22 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index c428bd7..b1434de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ PATH remote: . specs: - tapicero (0.2.0) + tapicero (0.3.1) couchrest (~> 1.1.3) - couchrest_changes (~> 0.0.1) + couchrest_changes (~> 0.0.2) daemons syslog_logger (~> 2.0.0) yajl-ruby @@ -15,18 +15,18 @@ GEM mime-types (~> 1.15) multi_json (~> 1.0) rest-client (~> 1.6.1) - couchrest_changes (0.0.1) + couchrest_changes (0.0.2) couchrest (~> 1.1.3) syslog_logger (~> 2.0.0) yajl-ruby daemons (1.1.9) highline (1.6.19) metaclass (0.0.1) - mime-types (1.25) + mime-types (1.25.1) minitest (3.2.0) mocha (0.14.0) metaclass (~> 0.0.1) - multi_json (1.8.0) + multi_json (1.8.2) rake (10.1.0) rest-client (1.6.7) mime-types (>= 1.16) @@ -34,23 +34,36 @@ From gem: Running -------------------- -Run once: - - tapicero --run-once - This will create per user databases for all users created since - the last run. - Run in foreground to see if it works: tapicero run -- test/config/config.yaml - browse to http://localhost:5984/_utils + create a new record in the users database + observe /var/log/syslog or the logfile you specified -How you would run normally in production mode: +Run as a deamon: tapicero start tapicero stop -See ``tapicero --help`` for more options. +Run once and then exit: + + tapicero --run-once + This will create per user databases for all users created since + the last run and then exit. + +Flags +--------------------- + +--run-once: + process the existing users and then exit + +--rerun: + also work on users that have been processed before + +--overwrite-security: + write the security settings even if the user database already has some + +Combining these flags you can migrate the security settings of all existing per user databases. Configuration diff --git a/bin/tapicero b/bin/tapicero index b8b88f1..ddd71c6 100755 --- a/bin/tapicero +++ b/bin/tapicero @@ -41,11 +41,18 @@ if ARGV.grep(/--version/).any? exit(0) end -# --run-once will create databases for new users and then exit -if ARGV.grep(/--once/).any? or ARGV.grep(/--run-once/).any? - require 'tapicero' - # TODO: implement me. - exit(0) +# --run-once create databases for new users and then exit +# --rerun also act upon users that have already been processed +# --overwrite-security overwrite existing couch security settings +# TODO: not implemented yet: +# --overwrite-designs overwrite existing design documents +Tapicero::FLAGS.concat ARGV.grep(/--.*/) + +# if flags have been set but an action is missing we assume +# tapicero should run in foreground. +if ARGV.first.start_with?('--') + ARGV.unshift '--' + ARGV.unshift 'run' end # diff --git a/lib/tapicero.rb b/lib/tapicero.rb index 3923c65..e2a8f38 100644 --- a/lib/tapicero.rb +++ b/lib/tapicero.rb @@ -22,6 +22,10 @@ module Tapicero self.config = CouchRest::Changes::Config.load(BASE_DIR, *configs) self.logger = CouchRest::Changes::Config.logger + # hand flags over to CouchRest::Changes + config.flags = FLAGS + puts "flags: #{FLAGS}" if FLAGS.any? + # # Load Tapicero Parts # diff --git a/lib/tapicero/user_database.rb b/lib/tapicero/user_database.rb index efd723a..50694b7 100644 --- a/lib/tapicero/user_database.rb +++ b/lib/tapicero/user_database.rb @@ -17,7 +17,7 @@ module Tapicero def secure(security) # let's not overwrite if we have a security doc already - return if secured? + return if secured? && !Tapicero::FLAGS.include?('--overwrite-security') Tapicero.logger.info "Writing Security to #{security_url}" Tapicero.logger.debug security.to_json CouchRest.put security_url, security diff --git a/lib/tapicero/version.rb b/lib/tapicero/version.rb index 2c4bc00..18ee238 100644 --- a/lib/tapicero/version.rb +++ b/lib/tapicero/version.rb @@ -1,4 +1,5 @@ module Tapicero - VERSION = "0.3.0" + VERSION = "0.3.1" REQUIRE_PATHS = ['lib'] + FLAGS = [] end diff --git a/tapicero.gemspec b/tapicero.gemspec index 73582bc..b3adbb8 100644 --- a/tapicero.gemspec +++ b/tapicero.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.executables << 'tapicero' s.add_dependency "couchrest", "~> 1.1.3" - s.add_dependency "couchrest_changes", "~> 0.0.1" + s.add_dependency "couchrest_changes", "~> 0.0.2" s.add_dependency "daemons" s.add_dependency "yajl-ruby" s.add_dependency "syslog_logger", "~> 2.0.0" |