rhc 0.75.9 → 0.77.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ spec = Gem::Specification.new do |s|
18
18
  s.description = %q{The client tools for the OpenShift Express platform that allow for application management.}
19
19
  s.files = FileList['lib/**/*.rb', 'bin/*', 'conf/*'].to_a
20
20
  s.files += %w(LICENSE README Rakefile)
21
- s.executables = ['rhc-create-app', 'rhc-create-domain', 'rhc-ctl-app', 'rhc-snapshot', 'rhc-user-info', 'rhc-tail-files']
21
+ s.executables = ['rhc-chk', 'rhc-create-app', 'rhc-create-domain', 'rhc-ctl-app', 'rhc-snapshot', 'rhc-user-info', 'rhc-tail-files']
22
22
  begin
23
23
  # Use Ruby version to target F13, RHEL5, Windows and OSX (assume no Xcode)
24
24
  if ENV['JSON_PURE'] or (RUBY_VERSION == "1.8.6" or RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /darwin/)
data/bin/rhc-chk CHANGED
@@ -42,6 +42,7 @@ properly setup. Often run to troubleshoot connection issues.
42
42
  -p|--password password Red Hat password (for RHN or OpenShift)
43
43
  -d|--debug Print Debug info
44
44
  -h|--help Show Usage info
45
+ --config path Path of alternate config file
45
46
 
46
47
  USAGE
47
48
  exit 255
@@ -52,7 +53,8 @@ begin
52
53
  ["--debug", "-d", GetoptLong::NO_ARGUMENT],
53
54
  ["--help", "-h", GetoptLong::NO_ARGUMENT],
54
55
  ["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
55
- ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT]
56
+ ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
57
+ ["--config", GetoptLong::REQUIRED_ARGUMENT]
56
58
  )
57
59
  opt = {}
58
60
  opts.each do |o, a|
@@ -63,13 +65,13 @@ rescue Exception => e
63
65
  p_usage
64
66
  end
65
67
 
68
+ # If provided a config path, check it
69
+ check_cpath(opt)
70
+
66
71
  # Pull in configs from files
67
72
  @libra_server = get_var('libra_server')
68
73
  @debug = get_var('debug') == 'false' ? nil : get_var('debug')
69
74
 
70
- libra_kfile = "#{ENV['HOME']}/.ssh/libra_id_rsa"
71
- libra_kpfile = "#{ENV['HOME']}/.ssh/libra_id_rsa.pub"
72
-
73
75
  if opt["help"]
74
76
  p_usage
75
77
  end
@@ -170,33 +172,36 @@ end
170
172
  puts
171
173
  puts "TEST3: SSH Key check"
172
174
  remote_ssh_pubkey = @user_info["user_info"]["ssh_key"]
173
- if File.exists?("#{ENV['HOME']}/.ssh/libra_id_rsa")
174
- puts " OK: ~/.ssh/libra_id_rsa - Found"
175
- key_dump = `ssh-keygen -f ~/.ssh/libra_id_rsa -y`
175
+ libra_kfile = get_kfile(false)
176
+ libra_kpfile = get_kpfile(libra_kfile, false)
177
+
178
+ if File.exists?(libra_kfile)
179
+ puts " OK: #{libra_kfile} - Found"
180
+ key_dump = `ssh-keygen -f #{libra_kfile} -y`
176
181
  local_derived_ssh_pubkey = key_dump.to_s.strip.split(' ')[1]
177
182
  else
178
- puts " ERROR: ~/.ssh/libra_id_rsa - Not Found!"
183
+ puts " ERROR: #{libra_kfile} - Not Found!"
179
184
  end
180
185
 
181
- if File.exists?("#{ENV['HOME']}/.ssh/libra_id_rsa.pub")
182
- puts " OK: ~/.ssh/libra_id_rsa.pub Found"
183
- fp = File.open("#{ENV['HOME']}/.ssh/libra_id_rsa.pub")
186
+ if File.exists?(libra_kpfile)
187
+ puts " OK: #{libra_kpfile} Found"
188
+ fp = File.open(libra_kpfile)
184
189
  local_ssh_pubkey = fp.gets.split(' ')[1]
185
190
  fp.close
186
191
  else
187
- puts " WARNING: ~/.ssh/libra_id_rsa.pub Not Found! (non fatal error)"
192
+ puts " WARNING: #{libra_kpfile} Not Found! (non fatal error)"
188
193
  end
189
194
 
190
195
  if local_ssh_pubkey.to_s.strip == remote_ssh_pubkey.to_s.strip
191
- puts " OK: Remote and ~/.ssh/libra_id_rsa.pub - match"
196
+ puts " OK: Remote and #{libra_kpfile} - match"
192
197
  else
193
- puts " WARNING: Remote and ~/.ssh/libra_id_rsa key do not match. (have you changed machines or ssh keys?)"
198
+ puts " WARNING: Remote and #{libra_kpfile} key do not match. (have you changed machines or ssh keys?)"
194
199
  end
195
200
 
196
201
  if local_derived_ssh_pubkey.to_s.strip == remote_ssh_pubkey.to_s.strip
197
- puts " OK: local ~/.ssh/libra_id_rsa should auth with openshift"
202
+ puts " OK: local #{libra_kfile} should auth with openshift"
198
203
  else
199
- puts " WARNING: local ~/.ssh/libra_id_rsa DOES NOT match remote pub key, ssh auth cannot continue"
204
+ puts " WARNING: local #{libra_kpfile} DOES NOT match remote pub key, ssh auth cannot continue"
200
205
  puts " FIX: Perhaps you should regenerate your public key, or run rhc-create-domain with -a to alter the remote key"
201
206
  end
202
207
 
data/bin/rhc-create-app CHANGED
@@ -40,6 +40,7 @@ Create an OpenShift Express app.
40
40
  -n|--nogit Only create remote space, don't pull it locally
41
41
  -d|--debug Print Debug info
42
42
  -h|--help Show Usage info
43
+ --config path Path of alternate config file
43
44
 
44
45
  USAGE
45
46
  exit 255
@@ -54,6 +55,7 @@ begin
54
55
  ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
55
56
  ["--app", "-a", GetoptLong::REQUIRED_ARGUMENT],
56
57
  ["--repo", "-r", GetoptLong::REQUIRED_ARGUMENT],
58
+ ["--config", GetoptLong::REQUIRED_ARGUMENT],
57
59
  ["--type", "-t", GetoptLong::REQUIRED_ARGUMENT]
58
60
  )
59
61
  opt = {}
@@ -65,6 +67,9 @@ rescue Exception => e
65
67
  p_usage
66
68
  end
67
69
 
70
+ # If provided a config path, check it
71
+ check_cpath(opt)
72
+
68
73
  # Pull in configs from files
69
74
  libra_server = get_var('libra_server')
70
75
  debug = get_var('debug') == 'false' ? nil : get_var('debug')
@@ -140,23 +145,6 @@ unless opt['nogit']
140
145
  end
141
146
  end
142
147
 
143
- #
144
- # Confirm libra_id_rsa exists
145
- #
146
- unless File.exists?("#{ssh_config_d}/libra_id_rsa")
147
- puts
148
- puts "Could not find #{ssh_config_d}/libra_id_rsa. Unable to continue."
149
- puts "Your SSH keys are created either by running ssh-keygen (password optional)"
150
- puts "or by having the rhc-create-domain command do it for you. If you created"
151
- puts "them on your own (or want to use an existing keypair), be sure to paste"
152
- puts "your public key into the dashboard page at http://www.openshift.com."
153
- puts "The client tools expect libra_id_rsa[.pub] so in the event that you are"
154
- puts "using existing keys, you can symlink libra_id_rsa -> id_rsa and"
155
- puts "libra_id_rsa.pub -> id_rsa.pub"
156
- puts "Also, make sure you never give out your secret key!"
157
- exit 212
158
- end
159
-
160
148
  #
161
149
  # Create remote application space
162
150
  #
@@ -214,66 +202,69 @@ puts "Checking ~/.ssh/config"
214
202
  user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, debug, false)
215
203
 
216
204
  fqdn = "#{opt['app']}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}"
217
-
218
- found = false
219
-
220
- begin
221
- File.open(ssh_config, "r") do |sline|
222
- while(line = sline.gets)
223
- if line.to_s.index("Host *.#{user_info['user_info']['rhc_domain']}") == 0
224
- found = true
225
- break
226
- end
227
- end
228
- end
229
- rescue Errno::EACCES
230
- puts "Could not read from #{ssh_config}"
231
- puts "Reason: " + $!
232
- puts
233
- puts "Please correct this first. Then run rerun."
234
- puts
235
- exit 213
236
- rescue Errno::ENOENT
237
- puts "Could not find #{ssh_config}. This is ok, continuing"
238
- end
239
- if found
240
- puts "Found #{user_info['user_info']['rhc_domain']} in ~/.ssh/config... No need to adjust"
241
- else
242
- puts " Adding #{user_info['user_info']['rhc_domain']} to ~/.ssh/config"
243
- begin
244
- f = File.open(ssh_config, "a")
245
- f.puts <<SSH
246
-
205
+
206
+ ssh_key_file_name = File.basename(get_kfile())
207
+ if (ssh_key_file_name != 'id_rsa')
208
+ found = false
209
+
210
+ begin
211
+ File.open(ssh_config, "r") do |sline|
212
+ while(line = sline.gets)
213
+ if line.to_s.index("Host *.#{user_info['user_info']['rhc_domain']}") == 0
214
+ found = true
215
+ break
216
+ end
217
+ end
218
+ end
219
+ rescue Errno::EACCES
220
+ puts "Could not read from #{ssh_config}"
221
+ puts "Reason: " + $!
222
+ puts
223
+ puts "Please correct this first. Then run rerun."
224
+ puts
225
+ exit 213
226
+ rescue Errno::ENOENT
227
+ puts "Could not find #{ssh_config}. This is ok, continuing"
228
+ end
229
+ if found
230
+ puts "Found #{user_info['user_info']['rhc_domain']} in ~/.ssh/config... No need to adjust"
231
+ else
232
+ puts " Adding #{user_info['user_info']['rhc_domain']} to ~/.ssh/config"
233
+ begin
234
+ f = File.open(ssh_config, "a")
235
+ f.puts <<SSH
236
+
247
237
  # Added by rhc-create-app on #{`date`}
248
238
  Host *.#{user_info['user_info']['rhc_domain']}
249
- IdentityFile ~/.ssh/libra_id_rsa
239
+ IdentityFile ~/.ssh/#{ssh_key_file_name}
250
240
  VerifyHostKeyDNS yes
251
241
  StrictHostKeyChecking no
252
242
  UserKnownHostsFile ~/.ssh/libra_known_hosts
253
243
 
254
244
  SSH
255
- f.close
256
- rescue Errno::EACCES
257
- puts "Could not write to #{ssh_config}"
258
- puts "Reason: " + $!
259
- puts
260
- puts "Please correct this first. Then run rerun."
261
- puts
262
- exit 214
263
- rescue Errno::ENOENT
264
- # Make directory and config if they do not exist
265
- puts "Could not find directory: " + $!
266
- puts "creating"
267
- FileUtils.mkdir_p ssh_config_d
268
- file = File.open(ssh_config, 'w')
269
- file.close
270
- retry
271
- end
245
+ f.close
246
+ rescue Errno::EACCES
247
+ puts "Could not write to #{ssh_config}"
248
+ puts "Reason: " + $!
249
+ puts
250
+ puts "Please correct this first. Then run rerun."
251
+ puts
252
+ exit 214
253
+ rescue Errno::ENOENT
254
+ # Make directory and config if they do not exist
255
+ puts "Could not find directory: " + $!
256
+ puts "creating"
257
+ FileUtils.mkdir_p ssh_config_d
258
+ file = File.open(ssh_config, 'w')
259
+ file.close
260
+ retry
261
+ end
262
+ end
263
+
264
+ File.chmod(0700, ssh_config_d)
265
+ File.chmod(0600, ssh_config)
272
266
  end
273
267
 
274
- File.chmod(0700, ssh_config_d)
275
- File.chmod(0600, ssh_config)
276
-
277
268
  #
278
269
  # Confirm that the host exists in DNS
279
270
  #
@@ -27,13 +27,14 @@ require 'rhc-common'
27
27
  # print help
28
28
  #
29
29
  def p_usage
30
+
30
31
  puts <<USAGE
31
32
 
32
33
  Usage: #{$0}
33
34
  Bind a registered rhcloud user to a domain in rhcloud.
34
35
 
35
- NOTE: to change ssh key, please alter your ~/.ssh/libra_id_rsa and
36
- ~/.ssh/libra_id_rsa.pub key, then re-run with --alter
36
+ NOTE: to change ssh key, alter your openshift <id_rsa> and
37
+ <id_rsa>.pub keys, then re-run with --alter
37
38
 
38
39
  -n|--namespace namespace Namespace for your application(s) (alphanumeric - max #{RHC::Maxdlen} chars) (required)
39
40
  -l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (required)
@@ -41,6 +42,7 @@ Bind a registered rhcloud user to a domain in rhcloud.
41
42
  -a|--alter Alter namespace (will change urls) and/or ssh key
42
43
  -d|--debug Print Debug info
43
44
  -h|--help Show Usage info
45
+ --config path Path of alternate config file
44
46
 
45
47
  USAGE
46
48
  exit 255
@@ -53,6 +55,7 @@ begin
53
55
  ["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
54
56
  ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
55
57
  ["--namespace", "-n", GetoptLong::REQUIRED_ARGUMENT],
58
+ ["--config", GetoptLong::REQUIRED_ARGUMENT],
56
59
  ["--alter", "-a", GetoptLong::NO_ARGUMENT]
57
60
  )
58
61
 
@@ -62,16 +65,19 @@ begin
62
65
  end
63
66
  rescue Exception => e
64
67
  #puts e.message
65
- p_usage
68
+ p_usage
66
69
  end
67
70
 
71
+ # If provided a config path, check it
72
+ check_cpath(opt)
73
+
68
74
  # Pull in configs from files
69
75
  libra_server = get_var('libra_server')
70
76
  debug = get_var('debug') == 'false' ? nil : get_var('debug')
71
77
 
72
78
 
73
- libra_kfile = "#{ENV['HOME']}/.ssh/libra_id_rsa"
74
- libra_kpfile = "#{ENV['HOME']}/.ssh/libra_id_rsa.pub"
79
+ libra_kfile = get_kfile(false)
80
+ libra_kpfile = get_kpfile(libra_kfile, opt['alter'])
75
81
 
76
82
  if opt["help"]
77
83
  p_usage
@@ -104,8 +110,8 @@ end
104
110
  #
105
111
 
106
112
  def add_rhlogin_config(rhlogin, uuid)
107
- f = open(File.expand_path(@local_config_path), 'a')
108
- unless @local_config.get_value('default_rhlogin')
113
+ f = open(File.expand_path(config_path), 'a')
114
+ unless config.get_value('default_rhlogin')
109
115
  f.puts("# Default rhlogin to use if none is specified")
110
116
  f.puts("default_rhlogin=#{rhlogin}")
111
117
  f.puts("")
@@ -115,7 +121,7 @@ end
115
121
 
116
122
 
117
123
  #
118
- # Check to see if a libra_id_rsa key exists, if not create it.
124
+ # Check to see if a libra_kfile exists, if not create it.
119
125
  #
120
126
 
121
127
  if File.readable?(libra_kfile)
@@ -157,8 +163,7 @@ if response.code == '200'
157
163
  puts <<EOF
158
164
  Creation successful
159
165
 
160
- You may now create an application. Please make note of your local config file
161
- in #{@local_config_path} which has been created and populated for you.
166
+ You may now create an application.
162
167
 
163
168
  EOF
164
169
  else
data/bin/rhc-ctl-app CHANGED
@@ -41,6 +41,7 @@ Control an OpenShift express app
41
41
  -b|--bypass Bypass warnings
42
42
  -d|--debug Print Debug info
43
43
  -h|--help Show Usage info
44
+ --config path Path of alternate config file
44
45
 
45
46
  USAGE
46
47
  exit 255
@@ -67,6 +68,7 @@ begin
67
68
  ["--embed", "-e", GetoptLong::REQUIRED_ARGUMENT],
68
69
  ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
69
70
  ["--app", "-a", GetoptLong::REQUIRED_ARGUMENT],
71
+ ["--config", GetoptLong::REQUIRED_ARGUMENT],
70
72
  ["--command", "-c", GetoptLong::REQUIRED_ARGUMENT]
71
73
  )
72
74
  opt = {}
@@ -78,6 +80,9 @@ rescue Exception => e
78
80
  p_usage
79
81
  end
80
82
 
83
+ # If provided a config path, check it
84
+ check_cpath(opt)
85
+
81
86
  # Pull in configs from files
82
87
  libra_server = get_var('libra_server')
83
88
  debug = get_var('debug') == 'false' ? nil : get_var('debug')
data/bin/rhc-snapshot CHANGED
@@ -40,6 +40,7 @@ Pull down application snapshot for a user
40
40
  -p|--password password RHLogin password (optional, will prompt)
41
41
  -d|--debug Print Debug info
42
42
  -h|--help Show Usage info
43
+ --config path Path of alternate config file
43
44
 
44
45
  USAGE
45
46
  exit 255
@@ -53,6 +54,7 @@ begin
53
54
  ["--save", "-s", GetoptLong::REQUIRED_ARGUMENT],
54
55
  ["--restore", "-r", GetoptLong::REQUIRED_ARGUMENT],
55
56
  ["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
57
+ ["--config", GetoptLong::REQUIRED_ARGUMENT],
56
58
  ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT]
57
59
  )
58
60
  opt = {}
@@ -64,13 +66,13 @@ rescue Exception => e
64
66
  p_usage
65
67
  end
66
68
 
69
+ # If provided a config path, check it
70
+ check_cpath(opt)
71
+
67
72
  # Pull in configs from files
68
73
  libra_server = get_var('libra_server')
69
74
  debug = get_var('debug') == 'false' ? nil : get_var('debug')
70
75
 
71
- libra_kfile = "#{ENV['HOME']}/.ssh/libra_id_rsa"
72
- libra_kpfile = "#{ENV['HOME']}/.ssh/libra_id_rsa.pub"
73
-
74
76
  if opt["help"] || !opt['app']
75
77
  p_usage
76
78
  end
data/bin/rhc-tail-files CHANGED
@@ -41,6 +41,7 @@ Tail the logs of an application
41
41
  -p|--password password RHLogin password (optional, will prompt)
42
42
  -d|--debug Print Debug info
43
43
  -h|--help Show Usage info
44
+ --config path Path of alternate config file
44
45
 
45
46
  USAGE
46
47
  exit 255
@@ -54,6 +55,7 @@ begin
54
55
  ["--opts", "-o", GetoptLong::REQUIRED_ARGUMENT],
55
56
  ["--files", "-f", GetoptLong::REQUIRED_ARGUMENT],
56
57
  ["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
58
+ ["--config", GetoptLong::REQUIRED_ARGUMENT],
57
59
  ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT]
58
60
  )
59
61
  opt = {}
@@ -65,13 +67,13 @@ rescue Exception => e
65
67
  p_usage
66
68
  end
67
69
 
70
+ # If provided a config path, check it
71
+ check_cpath(opt)
72
+
68
73
  # Pull in configs from files
69
74
  libra_server = get_var('libra_server')
70
75
  debug = get_var('debug') == 'false' ? nil : get_var('debug')
71
76
 
72
- libra_kfile = "#{ENV['HOME']}/.ssh/libra_id_rsa"
73
- libra_kpfile = "#{ENV['HOME']}/.ssh/libra_id_rsa.pub"
74
-
75
77
  if opt['help'] || !opt['app']
76
78
  p_usage
77
79
  end
@@ -108,19 +110,26 @@ file_glob = "#{opt['files']}"
108
110
  app_uuid = user_info['app_info'][app]['uuid']
109
111
  namespace = user_info['user_info']['namespace']
110
112
  rhc_domain = user_info['user_info']['rhc_domain']
111
- ssh_cmd = "ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'tail#{opt['opts'] ? ' --opts ' + Base64::encode64(opt['opts']).chomp : ''} #{file_glob}'"
113
+
114
+ # -t to force PTY and avoid daemons
115
+ # Red Hat Openshift: https://bugzilla.redhat.com/show_bug.cgi?id=726646
116
+ # OpenSSH https://bugzilla.mindrot.org/show_bug.cgi?id=396
117
+
118
+ ssh_cmd = "ssh -t #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'tail#{opt['opts'] ? ' --opts ' + Base64::encode64(opt['opts']).chomp : ''} #{file_glob}'"
112
119
 
113
120
  puts "Attempting to tail files: #{file_glob}"
114
121
  puts "Use ctl + c to stop"
115
122
  puts
116
123
  puts ssh_cmd if debug
117
- system(ssh_cmd)
118
- if $?.exitstatus != 0 and $?.exitstatus != 255
119
- puts
120
- puts "Error in trying to tail files. You can tail manually by running:"
121
- puts
122
- puts ssh_cmd
123
- puts
124
- exit 254
124
+ begin
125
+ exec ssh_cmd
126
+ rescue SystemCallError
127
+ puts
128
+ puts "Error in trying to tail files. You can tail manually by running:"
129
+ puts
130
+ puts ssh_cmd
131
+ puts
132
+ exit 254
125
133
  end
126
- exit 0
134
+ # this should never happen
135
+ exit 1
data/bin/rhc-user-info CHANGED
@@ -39,6 +39,7 @@ Display information about a user
39
39
  -i|--info Show user info
40
40
  -d|--debug Print Debug info
41
41
  -h|--help Show Usage info
42
+ --config path Path of alternate config file
42
43
 
43
44
  USAGE
44
45
  exit 255
@@ -51,6 +52,7 @@ begin
51
52
  ["--apps", "-a", GetoptLong::NO_ARGUMENT],
52
53
  ["--info", "-i", GetoptLong::NO_ARGUMENT],
53
54
  ["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
55
+ ["--config", GetoptLong::REQUIRED_ARGUMENT],
54
56
  ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT]
55
57
  )
56
58
  opt = {}
@@ -62,13 +64,13 @@ rescue Exception => e
62
64
  p_usage
63
65
  end
64
66
 
67
+ # If provided a config path, check it
68
+ check_cpath(opt)
69
+
65
70
  # Pull in configs from files
66
71
  libra_server = get_var('libra_server')
67
72
  debug = get_var('debug') == 'false' ? nil : get_var('debug')
68
73
 
69
- libra_kfile = "#{ENV['HOME']}/.ssh/libra_id_rsa"
70
- libra_kpfile = "#{ENV['HOME']}/.ssh/libra_id_rsa.pub"
71
-
72
74
  if opt["help"]
73
75
  p_usage
74
76
  end
data/conf/express.conf CHANGED
@@ -2,4 +2,4 @@
2
2
  libra_server = 'openshift.redhat.com'
3
3
 
4
4
  # Logging
5
- debug = false
5
+ debug = false
data/lib/rhc-common.rb CHANGED
@@ -102,10 +102,7 @@ module RHC
102
102
  # Invalid chars (") ($) (^) (<) (>) (|) (%) (/) (;) (:) (,) (\) (*) (=) (~)
103
103
  def self.check_rhlogin(rhlogin)
104
104
  if rhlogin
105
- if rhlogin.length < 6
106
- puts 'RHLogin must be at least 6 characters'
107
- return false
108
- elsif rhlogin =~ /["\$\^<>\|%\/;:,\\\*=~]/
105
+ if rhlogin =~ /["\$\^<>\|%\/;:,\\\*=~]/
109
106
  puts 'RHLogin may not contain any of these characters: (\") ($) (^) (<) (>) (|) (%) (/) (;) (:) (,) (\) (*) (=) (~)'
110
107
  return false
111
108
  end
@@ -334,6 +331,7 @@ end
334
331
  # Config paths... /etc/openshift/express.conf or $GEM/conf/express.conf -> ~/.openshift/express.conf
335
332
  #
336
333
  # semi-private: Just in case we rename again :)
334
+ @opts_config_path = nil
337
335
  @conf_name = 'express.conf'
338
336
  _linux_cfg = '/etc/openshift/' + @conf_name
339
337
  _gem_cfg = File.join(File.expand_path(File.dirname(__FILE__) + "/../conf"), @conf_name)
@@ -344,7 +342,16 @@ _home_conf = File.expand_path('~/.openshift')
344
342
  FileUtils.mkdir_p _home_conf unless File.directory?(_home_conf)
345
343
  local_config_path = File.expand_path(@local_config_path)
346
344
  if !File.exists? local_config_path
347
- FileUtils.touch local_config_path
345
+ file = File.open(local_config_path, 'w')
346
+ begin
347
+ file.puts <<EOF
348
+ # SSH key file
349
+ #ssh_key_file = 'libra_id_rsa'
350
+ EOF
351
+
352
+ ensure
353
+ file.close
354
+ end
348
355
  puts ""
349
356
  puts "Created local config file: " + local_config_path
350
357
  puts "express.conf contains user configuration and can be transferred across clients."
@@ -369,12 +376,97 @@ else
369
376
  @http = Net::HTTP
370
377
  end
371
378
 
379
+
380
+ #
381
+ # Support funcs
382
+ #
383
+ def check_cpath(opts)
384
+ if !opts["config"].nil?
385
+ @opts_config_path = opts["config"]
386
+ if !File.readable?(File.expand_path(@opts_config_path))
387
+ puts "Could not open config file: #{@opts_config_path}"
388
+ exit 253
389
+ else
390
+ begin
391
+ @opts_config = ParseConfig.new(File.expand_path(@opts_config_path))
392
+ rescue Errno::EACCES => e
393
+ puts "Could not open config file (#{@opts_config_path}): #{e.message}"
394
+ exit 253
395
+ end
396
+ end
397
+ end
398
+ end
399
+
400
+ def config_path
401
+ return @opts_config_path ? @opts_config_path : @local_config_path
402
+ end
403
+
404
+ def config
405
+ return @opts_config ? @opts_config : @local_config
406
+ end
407
+
372
408
  #
373
409
  # Check for local var in
410
+ # 0) --config path file
374
411
  # 1) ~/.openshift/express.conf
375
412
  # 2) /etc/openshift/express.conf
376
413
  # 3) $GEM/../conf/express.conf
377
414
  #
378
415
  def get_var(var)
379
- @local_config.get_value(var) ? @local_config.get_value(var) : @global_config.get_value(var)
416
+ v = nil
417
+ if !@opts_config.nil? && @opts_config.get_value(var)
418
+ v = @opts_config.get_value(var)
419
+ else
420
+ v = @local_config.get_value(var) ? @local_config.get_value(var) : @global_config.get_value(var)
421
+ end
422
+ v
423
+ end
424
+
425
+ def kfile_not_found
426
+ puts <<KFILE_NOT_FOUND
427
+ Your SSH keys are created either by running ssh-keygen (password optional)
428
+ or by having the rhc-create-domain command do it for you. If you created
429
+ them on your own (or want to use an existing keypair), be sure to paste
430
+ your public key into the express console at http://www.openshift.com.
431
+ The client tools use the value of 'ssh_key_file' in express.conf to find
432
+ your key followed by the defaults of libra_id_rsa[.pub] and then
433
+ id_rsa[.pub].
434
+ KFILE_NOT_FOUND
435
+
436
+ #exit 212
380
437
  end
438
+
439
+ def get_kfile(check_exists=true)
440
+ ssh_key_file = get_var('ssh_key_file')
441
+ if ssh_key_file
442
+ if (File.basename(ssh_key_file) == ssh_key_file)
443
+ kfile = "#{ENV['HOME']}/.ssh/#{ssh_key_file}"
444
+ else
445
+ kfile = File.expand_path(ssh_key_file)
446
+ end
447
+ else
448
+ kfile = "#{ENV['HOME']}/.ssh/libra_id_rsa"
449
+ end
450
+ if check_exists && !File.exists?(kfile)
451
+ if ssh_key_file
452
+ puts "WARNING: Unable to find '#{kfile}' referenced in express.conf."
453
+ kfile_not_found
454
+ else
455
+ kfile = "#{ENV['HOME']}/.ssh/id_rsa"
456
+ if !File.exists?(kfile)
457
+ puts "WARNING: Unable to find ssh key file."
458
+ kfile_not_found
459
+ end
460
+ end
461
+ end
462
+ return kfile
463
+ end
464
+
465
+ def get_kpfile(kfile, check_exists=true)
466
+ kpfile = kfile + '.pub'
467
+ if check_exists && !File.exists?(kpfile)
468
+ puts "WARNING: Unable to find '#{kpfile}'"
469
+ kfile_not_found
470
+ end
471
+ return kpfile
472
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 289
5
- prerelease: false
4
+ hash: 315
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 75
9
- - 9
10
- version: 0.75.9
8
+ - 77
9
+ - 8
10
+ version: 0.77.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Red Hat
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-22 00:00:00 -05:00
19
- default_executable:
18
+ date: 2011-09-28 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: json_pure
@@ -49,6 +48,7 @@ dependencies:
49
48
  description: The client tools for the OpenShift Express platform that allow for application management.
50
49
  email: openshift@redhat.com
51
50
  executables:
51
+ - rhc-chk
52
52
  - rhc-create-app
53
53
  - rhc-create-domain
54
54
  - rhc-ctl-app
@@ -61,18 +61,17 @@ extra_rdoc_files: []
61
61
 
62
62
  files:
63
63
  - lib/rhc-common.rb
64
- - bin/rhc-chk
65
- - bin/rhc-create-domain
64
+ - bin/rhc-ctl-app
66
65
  - bin/rhc-tail-files
67
66
  - bin/rhc-create-app
68
- - bin/rhc-ctl-app
69
- - bin/rhc-user-info
67
+ - bin/rhc-chk
70
68
  - bin/rhc-snapshot
69
+ - bin/rhc-create-domain
70
+ - bin/rhc-user-info
71
71
  - conf/express.conf
72
72
  - LICENSE
73
73
  - README
74
74
  - Rakefile
75
- has_rdoc: true
76
75
  homepage: https://openshift.redhat.com/app/express
77
76
  licenses: []
78
77
 
@@ -102,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
101
  requirements: []
103
102
 
104
103
  rubyforge_project:
105
- rubygems_version: 1.3.7
104
+ rubygems_version: 1.7.2
106
105
  signing_key:
107
106
  specification_version: 3
108
107
  summary: OpenShift Express Client Tools