summaryrefslogtreecommitdiff
path: root/cli/lib/leap_cli/init.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-10-09 00:05:44 -0700
committerelijah <elijah@riseup.net>2012-10-09 00:05:44 -0700
commit73b126976ad7843eb47a84944cf191bf05b14216 (patch)
tree918656f8d7c637e8c7a8f0c010eff55bfd98ae1b /cli/lib/leap_cli/init.rb
parent578ac2f5dc7432317d7a022bed9d869ab89ee45c (diff)
fixed paths
Diffstat (limited to 'cli/lib/leap_cli/init.rb')
-rw-r--r--cli/lib/leap_cli/init.rb74
1 files changed, 0 insertions, 74 deletions
diff --git a/cli/lib/leap_cli/init.rb b/cli/lib/leap_cli/init.rb
deleted file mode 100644
index bebede7..0000000
--- a/cli/lib/leap_cli/init.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require 'fileutils'
-
-module LeapCli
- #
- # creates new provider directory
- #
- def self.init(directory)
- dirs = [directory]
- mkdirs(dirs, false, false)
-
- Dir.chdir(directory) do
- dirs = ["nodes", "services", "keys", "tags"]
- mkdirs(dirs, false, false)
-
- #puts "Creating .provider"
- #FileUtils.touch('.provider')
-
- mkfile("provider.json", PROVIDER_CONTENT)
- mkfile("common.json", COMMON_CONTENT)
- end
- end
-
- def self.mkfile(filename, content)
- puts "Creating #{filename}"
- File.open(filename, 'w') do |f|
- f.write content
- end
- end
-
- def self.mkdirs(dirs,force,dry_run)
- exists = false
- if !force
- dirs.each do |dir|
- if File.exist? dir
- raise "#{dir} exists; use --force to override"
- exists = true
- end
- end
- end
- if !exists
- dirs.each do |dir|
- puts "Creating #{dir}/"
- if dry_run
- puts "dry-run; #{dir} not created"
- else
- FileUtils.mkdir_p dir
- end
- end
- else
- puts "Exiting..."
- return false
- end
- true
- end
-
- PROVIDER_CONTENT = <<EOS
-#
-# Global provider definition file.
-#
-{
- "domain": "example.org"
-}
-EOS
-
- COMMON_CONTENT = <<EOS
-#
-# Options put here are inherited by all nodes.
-#
-{
- "domain": "example.org"
-}
-EOS
-
-end