summaryrefslogtreecommitdiff
path: root/lib/leap_cli
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-05-20 14:18:20 -0700
committerelijah <elijah@riseup.net>2014-05-20 14:18:20 -0700
commitd99379c0e885b2ae26f3cd6a9631a51b431adc7a (patch)
treebe075dac431d25fbb717f3cb7620d390d46ce6b7 /lib/leap_cli
parent8beaa3bd0a7c8b38ef7f97c245ddc7f021c16dd9 (diff)
added a scary `leap db destroy` command
Diffstat (limited to 'lib/leap_cli')
-rw-r--r--lib/leap_cli/commands/db.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/leap_cli/commands/db.rb b/lib/leap_cli/commands/db.rb
new file mode 100644
index 0000000..e3d6b55
--- /dev/null
+++ b/lib/leap_cli/commands/db.rb
@@ -0,0 +1,20 @@
+module LeapCli; module Commands
+
+ desc 'Database commands.'
+ command :db do |db|
+ db.desc 'Destroy all the databases.'
+ db.command :destroy do |destroy|
+ destroy.action do |global_options,options,args|
+ say 'You are about to permanently destroy all database data.'
+ return unless agree("Continue? ")
+ nodes = manager.nodes[:services => 'couchdb']
+ ssh_connect(nodes, connect_options(options)) do |ssh|
+ ssh.run('/etc/init.d/bigcouch stop && test ! -z "$(ls /opt/bigcouch/var/lib/ 2> /dev/null)" && rm -r /opt/bigcouch/var/lib/* && echo "db destroyed" || echo "db already destroyed"')
+ end
+ end
+ end
+ end
+
+ private
+
+end; end