yggdrasil 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,32 +6,69 @@ Yggdrasil is a subversion wrapper to manage server configurations and conditions
6
6
 
7
7
  $ gem install yggdrasil
8
8
 
9
- And you have to install subversion:
9
+ subversion needs to be installed:
10
10
 
11
11
  (e.g.)$ sudo yum install subversion
12
12
 
13
- ## Usage
13
+ ## Usage: private use(stand alone)
14
14
 
15
15
  Prepare subversion repository and initialize Yggdrasil:
16
16
 
17
- (e.g.)$ svnadmin create ~/svn-repo
18
- $ yggdrasil init --repo file://$HOME/svn-repo
17
+ $ ygg init --repo private
19
18
 
20
19
  You should use svn-server if you have.
21
20
  In that case, the configuration files of
22
21
  all the servers can be managed on the unification.
23
22
 
24
- Add configuration files:
23
+ Add configuration files to manage:
25
24
 
26
- $ yggdrasil add /etc/hosts /etc/fstab ..etc
25
+ $ ygg add /etc/hosts /etc/fstab ..etc
26
+ $ ygg check
27
+ $ ygg commit /
27
28
 
28
29
  Check modify and/or delete:
29
30
 
30
- $ yggdrasil status /
31
+ $ vi /etc/hosts ..etc
32
+ $ ygg check
33
+ $ ygg commit /etc/hosts ..etc
31
34
 
32
35
  Refer Help:
33
36
 
34
- $ yggdrasil help
37
+ $ ygg help
38
+
39
+ ## Usage: data center management (example)
40
+
41
+ Prepare subversion repository and launch server on host:$YGG_SERVER:
42
+
43
+ (e.g. $YGG_REPO is anywhere you want)
44
+ $ svnadmin create $YGG_REPO
45
+ $ vi $YGG_REPO/conf/svnserve.conf
46
+ $ svnserve -d
47
+
48
+ Prepare yggdrasil server on host:$YGG_SERVER:
49
+
50
+ $ yggserve init --repo svn://$YGG_SERVER/$YGG_REPO/{host} --port 4000
51
+ $ yggserve daemon
52
+
53
+ Prepare yggdrasil client to manage config files:
54
+
55
+ $ ygg init --server $YGG_SERVER:4000
56
+ $ ls -al ~/.yggdrasil/checker
57
+ and add/modify executable script in "checker"
58
+ $ ygg add /etc/hosts /etc/fstab ..etc
59
+ $ ygg check
60
+ $ ygg commit /
61
+
62
+ Prepare yggdrasil client to report check results to yggdrasil server, every day:
63
+
64
+ $ crontab -e
65
+ add following line(you should check path by 'which ygg')
66
+ 17 5 * * * $GEMPATH/ygg check
67
+
68
+ Check updates of configurations/conditions on host:$YGG_SERVER:
69
+
70
+ $ yggserve results --expire 1440
71
+ CI tool(e.g.Jenkins) may execute this command automatically to daily report/record.
35
72
 
36
73
  ## Environment
37
74
 
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
2
+ require 'bundler/gem_tasks'
3
3
 
4
4
  Bundler.setup
5
5
  require 'rspec/core/rake_task'
6
6
 
7
- desc "run spec"
7
+ desc 'run spec'
8
8
  RSpec::Core::RakeTask.new(:spec) do |t|
9
9
  t.rspec_opts = %w{-c -fs}
10
10
  end
data/bin/ygg ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yggdrasil'
4
+
5
+ Yggdrasil::command(ARGV)
data/bin/yggserve ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yggdrasil_server'
4
+
5
+ YggdrasilServer::command(ARGV)
@@ -13,11 +13,13 @@ class Yggdrasil
13
13
  # execute checker
14
14
  `rm -rf #@checker_result_dir`
15
15
  Dir.mkdir @checker_result_dir, 0755
16
- Find.find(@checker_dir).each do |file|
17
- if File.file?(file) && File.executable?(file)
18
- if file =~ %r{^#@checker_dir(.*)$}
19
- file_body = $1
20
- system3("#{file} > #@checker_result_dir#{file_body}")
16
+ if File.exist?(@checker_dir)
17
+ Find.find(@checker_dir).each do |file|
18
+ if File.file?(file) && File.executable?(file)
19
+ if file =~ %r{^#@checker_dir(.*)$}
20
+ file_body = $1
21
+ system3("#{file} > #@checker_result_dir#{file_body}")
22
+ end
21
23
  end
22
24
  end
23
25
  end
@@ -41,15 +43,17 @@ class Yggdrasil
41
43
  end
42
44
  check_result.gsub!(/^Status against revision:.*\n/, '')
43
45
  check_result.chomp!
44
- if check_result != ""
46
+ if check_result == ''
47
+ puts 'yggdrasil check: OK!'
48
+ else
45
49
  check_result << "\n\n"
46
50
  cmd_arg = "#@svn diff --no-auth-cache --non-interactive -r HEAD"
47
51
  cmd_arg += username_password_options_to_read_repo
48
52
  FileUtils.cd @mirror_dir do
49
53
  check_result << system3(cmd_arg)
50
54
  end
55
+ puts check_result
51
56
  end
52
- puts check_result
53
57
 
54
58
  if /^(.+):(\d+)$/ =~ @options[:server]
55
59
  host = $1
@@ -26,10 +26,10 @@ class Yggdrasil
26
26
 
27
27
  message = ''
28
28
  unless @options.has_key?(:message)
29
- print "Input log message: "
29
+ print 'Input log message: '
30
30
  loop do
31
31
  input = $stdin.gets
32
- error "can not input log message" unless input
32
+ error 'can not input log message' unless input
33
33
  input.chomp!
34
34
  if input =~ /^(.*)\\$/
35
35
  message += $1+"\n"
@@ -44,7 +44,7 @@ class Yggdrasil
44
44
  input_user_pass
45
45
  FileUtils.cd @mirror_dir do
46
46
  puts system3 "#@svn commit -m '#{@options[:message]}'"\
47
- " --no-auth-cache --non-interactive"\
47
+ ' --no-auth-cache --non-interactive'\
48
48
  " --username '#{@options[:username]}' --password '#{@options[:password]}'"\
49
49
  " #{confirmed_updates.join(' ')}"
50
50
  end
@@ -1,6 +1,5 @@
1
1
  class Yggdrasil
2
2
 
3
-
4
3
  # @param [Array] args
5
4
  def help(args)
6
5
  if args.size == 0
@@ -17,22 +16,19 @@ Available subcommands:
17
16
  diff (di)
18
17
  help (?, h)
19
18
  init
20
- init-server
21
19
  list (ls)
22
20
  log
23
- results
24
21
  revert
25
- server
26
22
  status (stat, st)
27
23
  update
28
24
  version
29
25
 
30
26
  Yggdrasil is a subversion wrapper to manage server configurations and conditions.
31
- You should type 'yggdrasil init' at first.
27
+ At first, you should type '#@base_cmd init' to create config file.
32
28
 
33
29
  EOS
34
30
  elsif args.size != 1 then
35
- error "too many arguments."
31
+ error 'too many arguments.'
36
32
  else
37
33
  case args[0]
38
34
  when 'add'
@@ -51,7 +47,10 @@ usage: #@base_cmd check [OPTIONS...]
51
47
  For example, mount status, number of specific process and etc. can be checked
52
48
  by setting up executable files in ~/.yggdrasil/checker/
53
49
 
54
- if the server is registered, the yggdrasil server receive and record the results.
50
+ If the yggdrasil server is registered,
51
+ this subcommand send the result to yggdrasil server
52
+ and yggdrasil server record the results for all managed servers.
53
+ Type 'yggserve help', if you need to know about yggdrasil server.
55
54
 
56
55
  Valid options:
57
56
  --username ARG : specify a username ARG
@@ -122,22 +121,6 @@ Valid options:
122
121
  --server ARG : specify a server address and port
123
122
  e.g. 192.168.1.35:4000
124
123
 
125
- EOS
126
- when 'init-server'
127
- puts <<"EOS"
128
- init-server: setup server configuration.
129
- usage: #@base_cmd init-server [OPTIONS...]
130
-
131
- Valid options:
132
- --port ARG : specify a TCP port number ARG
133
- --repo ARG : URL of subversion repository
134
- ARG can contain {HOST} or a {host}
135
- {HOST} is replaced by client hostname with domain
136
- {host} is replaced by client hostname without domain
137
- e.g. svn://192.168.3.5/servers/{host}/ygg
138
- --ro-username ARG : specify a username ARG for read only
139
- --ro-password ARG : specify a password ARG for read only
140
-
141
124
  EOS
142
125
  when 'list', 'ls'
143
126
  puts <<"EOS"
@@ -175,15 +158,6 @@ Valid options:
175
158
  'COMMITTED' last commit at or before BASE
176
159
  'PREV' revision just before COMMITTED
177
160
 
178
- EOS
179
- when 'results'
180
- puts <<"EOS"
181
- results: display the result of yggdrasil check command.
182
- usage: #@base_cmd results [OPTIONS...]
183
-
184
- Valid options:
185
- --limit ARG : minutes from the final report, to judge the host not be alive
186
-
187
161
  EOS
188
162
  when 'revert'
189
163
  puts <<"EOS"
@@ -241,7 +215,7 @@ usage: #@base_cmd version
241
215
 
242
216
  EOS
243
217
  else
244
- error "Unknown subcommand: '#{subcommand}'"
218
+ error "Unknown subcommand: '#{args[0]}'"
245
219
  end
246
220
  end
247
221
  end
@@ -1,3 +1,5 @@
1
+ require 'socket'
2
+
1
3
  class Yggdrasil
2
4
 
3
5
  # @param [Array] args
@@ -19,7 +21,7 @@ class Yggdrasil
19
21
  svn = out.chomp
20
22
 
21
23
  out = system3 'svn --version'
22
- error "can not find version string: svn --version" unless /version (\d+\.\d+\.\d+) / =~ out
24
+ error 'can not find version string: svn --version' unless /version (\d+\.\d+\.\d+) / =~ out
23
25
  svn_version=$1
24
26
 
25
27
  error "already exist config file: #@config_file" if File.exist?(@config_file)
@@ -32,14 +34,14 @@ class Yggdrasil
32
34
  @options[:repo].chomp!('/')
33
35
  @options[:repo].gsub!(/\{HOST\}/, Socket.gethostname)
34
36
  @options[:repo].gsub!(/\{host\}/, Socket.gethostname.split('.')[0])
35
- if @options[:repo] == "private"
37
+ if @options[:repo] == 'private'
36
38
  Dir.mkdir @config_dir, 0755 unless File.exist?(@config_dir)
37
39
  repo_dir = "#@config_dir/private_repo"
38
40
  system3 "svnadmin create #{repo_dir}"
39
41
  @options[:repo] = "file://#{repo_dir}"
40
42
  end
41
43
 
42
- puts "check SVN access..."
44
+ puts 'check SVN access...'
43
45
  if @options.has_key?(:ro_username)
44
46
  anon_access = false
45
47
  else
@@ -79,9 +81,9 @@ class Yggdrasil
79
81
  msg = "not exist directory(s): #{url_parts[url_parts_num...url_parts.size].join('/')}"
80
82
  error msg if @options[:non_interactive?]
81
83
  puts msg
82
- print "make directory(s)? [Yn]: "
84
+ print 'make directory(s)? [Yn]: '
83
85
  input = $stdin.gets
84
- error "can not gets $stdin" if input.nil?
86
+ error 'can not gets $stdin' if input.nil?
85
87
  input.chomp!
86
88
  return if input == 'n'
87
89
  break if input == 'Y'
@@ -107,7 +109,7 @@ class Yggdrasil
107
109
  end
108
110
 
109
111
  # make config file
110
- File.open(@config_file, "w") do |f|
112
+ File.open(@config_file, 'w') do |f|
111
113
  f.puts "path=#{ENV['PATH']}\n"\
112
114
  "svn=#{svn}\n"\
113
115
  "svn_version=#{svn_version}\n"\
@@ -133,16 +135,16 @@ class Yggdrasil
133
135
 
134
136
  def init_get_repo_interactive
135
137
  loop do
136
- print "Input svn repo URL: "
138
+ print 'Input svn repo URL: '
137
139
  input = $stdin.gets
138
- error "can not input svn repo URL" unless input
140
+ error 'can not input svn repo URL' unless input
139
141
 
140
142
  if %r{^(http://|https://|file://|svn://|private)} =~ input
141
143
  @options[:repo] = input
142
144
  break
143
145
  end
144
146
 
145
- puts "ERROR: Invalid URL."
147
+ puts 'ERROR: Invalid URL.'
146
148
  end
147
149
  end
148
150
  end
@@ -23,7 +23,7 @@ class Yggdrasil
23
23
  cmd_arg = "#@svn list --no-auth-cache --non-interactive"
24
24
  cmd_arg += username_password_options_to_read_repo
25
25
  cmd_arg += " -r #{@options[:revision]}" if @options.has_key?(:revision)
26
- cmd_arg += " -R" if @options.has_key?(:recursive?)
26
+ cmd_arg += ' -R' if @options.has_key?(:recursive?)
27
27
  cmd_arg += ' ' + repos.join(' ')
28
28
  FileUtils.cd @mirror_dir do
29
29
  puts system3(cmd_arg)
data/lib/yggdrasil/log.rb CHANGED
@@ -9,7 +9,7 @@ class Yggdrasil
9
9
 
10
10
  if args.size == 0
11
11
  dir = @mirror_dir + @current_dir
12
- error "current directory is not managed." unless File.exist?(dir)
12
+ error 'current directory is not managed.' unless File.exist?(dir)
13
13
  args << dir
14
14
  else
15
15
  args.collect! do |arg|
@@ -26,7 +26,7 @@ class Yggdrasil
26
26
  if @options.has_key?(:revision)
27
27
  cmd_arg += " -r #{@options[:revision]}"
28
28
  else
29
- cmd_arg += " -r HEAD:1"
29
+ cmd_arg += ' -r HEAD:1'
30
30
  end
31
31
  cmd_arg += ' ' + args.join(' ')
32
32
  puts system3(cmd_arg)
@@ -30,7 +30,7 @@ class Yggdrasil
30
30
  confirmed_updates = confirm_updates(matched_updates) do |relative_path|
31
31
  FileUtils.cd @mirror_dir do
32
32
  cmd = "#@svn diff"
33
- cmd += " --no-auth-cache --non-interactive"
33
+ cmd += ' --no-auth-cache --non-interactive'
34
34
  cmd += username_password_options_to_read_repo
35
35
  if @options.has_key?(:revision)
36
36
  cmd += " --old=#{relative_path} --new=#{relative_path}@#{@options[:revision]}"
@@ -50,7 +50,7 @@ class Yggdrasil
50
50
  if @options.has_key?(:revision)
51
51
  cmd_arg += " -r #{@options[:revision]}"
52
52
  else
53
- cmd_arg += " -r HEAD"
53
+ cmd_arg += ' -r HEAD'
54
54
  end
55
55
  cmd_arg += ' ' + confirmed_updates.join(' ')
56
56
  FileUtils.cd @mirror_dir do
@@ -1,5 +1,5 @@
1
1
  class Yggdrasil
2
- VERSION = "0.0.7"
2
+ VERSION = '0.0.8'
3
3
 
4
4
  def version
5
5
  puts <<"EOS"
data/lib/yggdrasil.rb CHANGED
@@ -1,21 +1,20 @@
1
1
  require 'fileutils'
2
2
 
3
- require "yggdrasil_common"
4
- require "yggdrasil_server"
5
-
6
- require "yggdrasil/version"
7
- require "yggdrasil/help"
8
- require "yggdrasil/init"
9
- require "yggdrasil/add"
10
- require "yggdrasil/commit"
11
- require "yggdrasil/cleanup"
12
- require "yggdrasil/diff"
13
- require "yggdrasil/list"
14
- require "yggdrasil/log"
15
- require "yggdrasil/status"
16
- require "yggdrasil/update"
17
- require "yggdrasil/revert"
18
- require "yggdrasil/check"
3
+ require 'yggdrasil_common'
4
+
5
+ require 'yggdrasil/version'
6
+ require 'yggdrasil/help'
7
+ require 'yggdrasil/init'
8
+ require 'yggdrasil/add'
9
+ require 'yggdrasil/commit'
10
+ require 'yggdrasil/cleanup'
11
+ require 'yggdrasil/diff'
12
+ require 'yggdrasil/list'
13
+ require 'yggdrasil/log'
14
+ require 'yggdrasil/status'
15
+ require 'yggdrasil/update'
16
+ require 'yggdrasil/revert'
17
+ require 'yggdrasil/check'
19
18
 
20
19
  class Yggdrasil
21
20
 
@@ -38,22 +37,16 @@ class Yggdrasil
38
37
  new.commit(args[1..-1])
39
38
  when 'diff', 'di'
40
39
  new.diff(args[1..-1])
41
- when 'help', 'h', '?'
40
+ when 'help', '--help', 'h', '?'
42
41
  new(false).help(args[1..-1])
43
42
  when 'init'
44
43
  new(false).init(args[1..-1])
45
- when 'init-server'
46
- YggdrasilServer.new(false).init_server(args[1..-1])
47
44
  when 'list', 'ls'
48
45
  new.list(args[1..-1])
49
46
  when 'log'
50
47
  new.log(args[1..-1])
51
- when 'results'
52
- YggdrasilServer.new.results(args[1..-1])
53
48
  when 'revert'
54
49
  new.revert(args[1..-1])
55
- when 'server'
56
- YggdrasilServer.new.server(args[1..-1])
57
50
  when 'status', 'stat', 'st'
58
51
  new.status(args[1..-1])
59
52
  when 'update'
@@ -69,7 +62,7 @@ class Yggdrasil
69
62
  def initialize(exist_config = true)
70
63
  @base_cmd = File::basename($0)
71
64
  @current_dir = `readlink -f .`.chomp
72
- @config_dir = "#{ENV["HOME"]}/.yggdrasil"
65
+ @config_dir = "#{ENV['HOME']}/.yggdrasil"
73
66
  @config_file = "#@config_dir/config"
74
67
  @mirror_dir = "#@config_dir/mirror"
75
68
  @checker_dir = "#@config_dir/checker"
@@ -77,9 +70,9 @@ class Yggdrasil
77
70
 
78
71
  return unless exist_config
79
72
  configs = read_config(@config_file)
80
- error "need 'path' in config file" unless (ENV["PATH"] = configs[:path])
81
- error "need 'svn' in config file" unless (@svn = configs[:svn])
82
- error "need 'repo' in config file" unless (@repo = configs[:repo])
73
+ error 'need "path" in config file' unless (ENV['PATH'] = configs[:path])
74
+ error 'need "svn" in config file' unless (@svn = configs[:svn])
75
+ error 'need "repo" in config file' unless (@repo = configs[:repo])
83
76
  @anon_access = (configs[:anon_access] == 'read')
84
77
  @options ||= Hash.new
85
78
  @options[:server] = configs[:server] if configs.has_key?(:server)
@@ -106,7 +99,7 @@ class Yggdrasil
106
99
  files.each do |file|
107
100
  if !File.exist?("/#{file}")
108
101
  system3 "#@svn delete #{file} --force" +
109
- " --no-auth-cache --non-interactive"
102
+ ' --no-auth-cache --non-interactive'
110
103
  elsif File.file?("/#{file}")
111
104
  if !File.exist?("#@mirror_dir/#{file}")
112
105
  cmd = "#@svn revert #{file}"
@@ -168,7 +161,7 @@ class Yggdrasil
168
161
  (0...updates.size).each do |i|
169
162
  puts "#{i}:#{updates[i][0]} #{updates[i][1]}"
170
163
  end
171
- print "OK? [Y|n|<num to diff>]:"
164
+ print 'OK? [Y|n|<num to diff>]:'
172
165
  res = $stdin.gets
173
166
  return nil unless res
174
167
  res.chomp!
@@ -191,7 +184,7 @@ class Yggdrasil
191
184
  if @options.has_key?(:ro_password)
192
185
  " --username #{@options[:ro_username]} --password #{@options[:ro_password]}"
193
186
  else
194
- ""
187
+ ''
195
188
  end
196
189
  end
197
190
 
@@ -213,9 +206,9 @@ class Yggdrasil
213
206
  # get repo
214
207
  sock = TCPSocket.open(host, port)
215
208
  error "can not connect to server: #{host}:#{port}" if sock.nil?
216
- sock.puts "get_repo"
209
+ sock.puts 'get_repo'
217
210
  rcv = sock.gets
218
- error "can not get repo from server" if rcv.nil?
211
+ error 'can not get repo from server' if rcv.nil?
219
212
  @options[:repo] = rcv.chomp
220
213
  sock.close
221
214
  end
@@ -223,12 +216,12 @@ class Yggdrasil
223
216
  #get read-only username/password
224
217
  sock = TCPSocket.open(host, port)
225
218
  error "can not connect to server: #{host}:#{port}" if sock.nil?
226
- sock.puts("get_ro_id_pw")
219
+ sock.puts('get_ro_id_pw')
227
220
  username = sock.gets
228
221
  unless username.nil?
229
222
  @options[:ro_username] = username.chomp
230
223
  password = sock.gets
231
- error "can not get ro_password" if password.nil?
224
+ error 'can not get ro_password' if password.nil?
232
225
  @options[:ro_password] = password.chomp
233
226
  end
234
227
  sock.close
@@ -56,23 +56,23 @@ module YggdrasilCommon
56
56
 
57
57
  def input_user_pass
58
58
  until @options.has_key?(:username) do
59
- error "Can't get username or password" if @options.has_key?(:non_interactive?)
60
- print "Input svn username: "
59
+ error 'Can\'t get username or password' if @options.has_key?(:non_interactive?)
60
+ print 'Input svn username: '
61
61
  input = $stdin.gets
62
- error "can not input username" unless input
62
+ error 'can not input username' unless input
63
63
  input.chomp!
64
64
  return if input.size == 0
65
65
  @options[:username] = @options[:ro_username] = input
66
66
  end
67
67
  until @options.has_key?(:password) do
68
- error "Can't get username or password" if @options.has_key?(:non_interactive?)
69
- print "Input svn password: "
68
+ error 'Can\'t get username or password' if @options.has_key?(:non_interactive?)
69
+ print 'Input svn password: '
70
70
  #input = `sh -c 'read -s hoge;echo $hoge'`
71
71
  system3 'stty -echo', false
72
72
  input = $stdin.gets
73
73
  system3 'stty echo', false
74
74
  puts
75
- error "can not input password" unless input
75
+ error 'can not input password' unless input
76
76
  input.chomp!
77
77
  @options[:password] = @options[:ro_password] = input
78
78
  end
@@ -85,8 +85,13 @@ module YggdrasilCommon
85
85
 
86
86
  unless stat.success?
87
87
  return nil unless err_exit
88
- $stderr.puts "#@base_cmd error: command failure: #{cmd}"
89
- $stderr.puts "command output:"
88
+ if @options[:debug?]
89
+ cmd_disp = cmd
90
+ else
91
+ cmd_disp = (cmd.split)[0]+' ...'
92
+ end
93
+ $stderr.puts "#@base_cmd error: command failure: #{cmd_disp}"
94
+ $stderr.puts 'command output:'
90
95
  $stderr.puts out
91
96
  exit stat.exitstatus
92
97
  end
@@ -0,0 +1,85 @@
1
+ require 'yggdrasil_server'
2
+
3
+ class YggdrasilServer
4
+
5
+ # @param [Array] args
6
+ def help(args)
7
+ if args.size == 0
8
+ puts <<EOS
9
+ usage: #@base_cmd <subcommand> [options] [args]
10
+ Yggdrasil version #{Yggdrasil::VERSION}
11
+ Type '#@base_cmd help <subcommand>' for help on a specific subcommand.
12
+
13
+ Available subcommands:
14
+ daemon
15
+ debug
16
+ help (?, h)
17
+ init
18
+ results
19
+ version
20
+
21
+ Yggdrasil server is a TCP server
22
+ to receive/record the yggdrasil check result of all managed servers.
23
+
24
+ At first, you should type '#@base_cmd init' to create config file.
25
+
26
+ EOS
27
+ elsif args.size != 1 then
28
+ error 'too many arguments.'
29
+ else
30
+ case args[0]
31
+ when 'daemon'
32
+ puts <<"EOS"
33
+ daemon: launch TCP server by daemon mode.
34
+ usage: #{File.basename($0)} daemon
35
+
36
+ EOS
37
+ when 'debug'
38
+ puts <<"EOS"
39
+ debug: launch TCP server by debug mode.
40
+ usage: #{File.basename($0)} debug
41
+
42
+ EOS
43
+ when 'help', '?', 'h'
44
+ puts <<"EOS"
45
+ help (?,h): Describe the usage of this program or its subcommands.
46
+ usage: #@base_cmd help [SUBCOMMAND]
47
+
48
+ EOS
49
+ when 'init'
50
+ puts <<"EOS"
51
+ init: setup yggdrasil server configuration.
52
+ usage: #@base_cmd init [OPTIONS...]
53
+
54
+ Valid options:
55
+ --port ARG : specify a TCP port number ARG
56
+ --repo ARG : URL of subversion repository
57
+ ARG can contain {HOST} or a {host}
58
+ {HOST} is replaced by client hostname with domain
59
+ {host} is replaced by client hostname without domain
60
+ e.g. svn://192.168.3.5/servers/{host}/ygg
61
+ --ro-username ARG : specify a username ARG for read only
62
+ --ro-password ARG : specify a password ARG for read only
63
+
64
+ EOS
65
+ when 'results'
66
+ puts <<"EOS"
67
+ results: display the result of yggdrasil check command.
68
+ usage: #@base_cmd results [OPTIONS...]
69
+
70
+ Valid options:
71
+ --expire ARG : minutes from the final report, to judge the host not be alive
72
+
73
+ EOS
74
+ when 'version', '--version'
75
+ puts <<"EOS"
76
+ version: See the program version
77
+ usage: #@base_cmd version
78
+
79
+ EOS
80
+ else
81
+ error "Unknown subcommand: '#{subcommand}'"
82
+ end
83
+ end
84
+ end
85
+ end