psadmin_plus 2.0.5 → 2.0.6
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.
- checksums.yaml +4 -4
- data/bin/psa +156 -156
- data/lib/psadmin_plus.rb +642 -636
- metadata +6 -6
data/lib/psadmin_plus.rb
CHANGED
@@ -1,636 +1,642 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rbconfig'
|
4
|
-
require 'etc'
|
5
|
-
require 'open3'
|
6
|
-
|
7
|
-
def do_help
|
8
|
-
puts "Usage: psa [command] <type> <domain>"
|
9
|
-
puts " "
|
10
|
-
puts "Commands:"
|
11
|
-
puts " "
|
12
|
-
puts " help display this help message"
|
13
|
-
puts " list list domains"
|
14
|
-
#puts " admin launch psadmin"
|
15
|
-
puts " summary PS_CFG_HOME summary, no type or domain needed"
|
16
|
-
puts " status status of the domain"
|
17
|
-
puts " start hookstart, if enabled, then start the domain"
|
18
|
-
puts " stop hookstop, if enabled, stop the domain"
|
19
|
-
puts " restart stop and start the domain"
|
20
|
-
puts " purge clear domain cache"
|
21
|
-
puts " reconfigure stop, configure, and start the domain"
|
22
|
-
puts " bounce stop, flush, purge, configure and start the domain"
|
23
|
-
puts " kill force stop the domain"
|
24
|
-
puts " configure configure the domain"
|
25
|
-
puts " flush clear domain IPC"
|
26
|
-
puts " "
|
27
|
-
puts "Types:"
|
28
|
-
puts " "
|
29
|
-
puts " app act on application domains"
|
30
|
-
#puts " pubsub act on PUBSUB group of application domains"
|
31
|
-
puts " prcs act on process scheduler domains"
|
32
|
-
puts " web act on web domains"
|
33
|
-
puts " all,<blank> act on web, app, and prcs domains"
|
34
|
-
puts " "
|
35
|
-
puts "Domains:"
|
36
|
-
puts " "
|
37
|
-
puts " dom act on specific domains"
|
38
|
-
puts " all,<blank> act on all domains"
|
39
|
-
puts " "
|
40
|
-
puts "Each parameter type can be enter in a comma separated list "
|
41
|
-
puts " "
|
42
|
-
end
|
43
|
-
|
44
|
-
def do_is_runtime_user_nix
|
45
|
-
result = ENV['USER'] == PS_RUNTIME_USER ? true : false
|
46
|
-
end
|
47
|
-
|
48
|
-
def do_is_runtime_user_win
|
49
|
-
result = ENV['USERNAME'] == PS_RUNTIME_USER ? true : false
|
50
|
-
end
|
51
|
-
|
52
|
-
def env(var)
|
53
|
-
result = "#{OS_CONST}" == "linux" ? "${#{var}}" : "%#{var}%"
|
54
|
-
end
|
55
|
-
|
56
|
-
def do_cmd(cmd, print = true, powershell = true)
|
57
|
-
case "#{OS_CONST}"
|
58
|
-
when "linux"
|
59
|
-
if do_is_runtime_user_nix
|
60
|
-
case "#{PS_PSA_DEBUG}"
|
61
|
-
when "true"
|
62
|
-
p "Command: #{cmd}"
|
63
|
-
end
|
64
|
-
out = `#{cmd}`
|
65
|
-
else
|
66
|
-
if "#{PS_PSA_SUDO}" == "on"
|
67
|
-
case "#{PS_PSA_DEBUG}"
|
68
|
-
when "true"
|
69
|
-
p "Command: sudo su - #{PS_RUNTIME_USER} -c '#{cmd}'"
|
70
|
-
end
|
71
|
-
out = `sudo su - #{PS_RUNTIME_USER} -c '#{cmd}'`
|
72
|
-
else
|
73
|
-
print "#{PS_RUNTIME_USER} "
|
74
|
-
case "#{PS_PSA_DEBUG}"
|
75
|
-
when "true"
|
76
|
-
p "Command: su - #{PS_RUNTIME_USER} -c '#{cmd}'"
|
77
|
-
end
|
78
|
-
out = `su - #{PS_RUNTIME_USER} -c '#{cmd}'`
|
79
|
-
end
|
80
|
-
end
|
81
|
-
when "windows"
|
82
|
-
case powershell
|
83
|
-
when true
|
84
|
-
case "#{PS_PSA_DEBUG}"
|
85
|
-
when "true"
|
86
|
-
p "Command: powershell -NoProfile -Command \"#{cmd}\""
|
87
|
-
end
|
88
|
-
out = `powershell -NoProfile -Command "#{cmd}"`
|
89
|
-
else
|
90
|
-
case "#{PS_PSA_DEBUG}"
|
91
|
-
when "true"
|
92
|
-
p "Command: #{cmd}"
|
93
|
-
end
|
94
|
-
out = `#{cmd}`
|
95
|
-
end
|
96
|
-
else
|
97
|
-
out = "Invalid OS"
|
98
|
-
end
|
99
|
-
print ? (puts out) : result = out
|
100
|
-
out
|
101
|
-
end
|
102
|
-
|
103
|
-
def do_cmd_banner(c,t,d)
|
104
|
-
puts ""
|
105
|
-
puts "===[ #{c} . #{t} . #{d} ]==="
|
106
|
-
puts ""
|
107
|
-
end
|
108
|
-
|
109
|
-
def do_set_cfg_home(d)
|
110
|
-
if "#{PS_MULTI_HOME}" != "false"
|
111
|
-
if PS_MULTI_PREFIX > 0
|
112
|
-
h = d.slice(0..PS_MULTI_PREFIX)
|
113
|
-
else
|
114
|
-
h = d
|
115
|
-
end
|
116
|
-
ENV['PS_CFG_HOME'] = "#{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}#{h}"
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def find_apps_nix
|
121
|
-
case "#{PS_MULTI_HOME}"
|
122
|
-
when "false"
|
123
|
-
apps = do_cmd("find #{env('PS_CFG_HOME')}/appserv/*/psappsrv.ubx 2>/dev/null",false).split(/\n+/)
|
124
|
-
else
|
125
|
-
apps = do_cmd("find #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/appserv/*/psappsrv.ubx 2>/dev/null",false).split(/\n+/)
|
126
|
-
end
|
127
|
-
apps.map! {|app| app.split("/")[-2]}
|
128
|
-
end
|
129
|
-
|
130
|
-
def find_prcss_nix
|
131
|
-
case "#{PS_MULTI_HOME}"
|
132
|
-
when "false"
|
133
|
-
prcss = do_cmd("find #{env('PS_CFG_HOME')}/appserv/prcs/*/psprcsrv.ubx 2>/dev/null",false).split(/\n+/)
|
134
|
-
else
|
135
|
-
prcss = do_cmd("find #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/appserv/prcs/*/psprcsrv.ubx 2>/dev/null",false).split(/\n+/)
|
136
|
-
end
|
137
|
-
prcss.map! {|prcs| prcs.split("/")[-2]}
|
138
|
-
end
|
139
|
-
|
140
|
-
def find_webs_nix
|
141
|
-
case "#{PS_MULTI_HOME}"
|
142
|
-
when "false"
|
143
|
-
webs = do_cmd("find #{env('PS_CFG_HOME')}/webserv/*/piaconfig -maxdepth 0",false).split(/\n+/)
|
144
|
-
else
|
145
|
-
webs = do_cmd("find #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/webserv/*/piaconfig -maxdepth 0",false).split(/\n+/)
|
146
|
-
end
|
147
|
-
webs.map! {|web| web.split("/")[-2]}
|
148
|
-
end
|
149
|
-
|
150
|
-
def find_sites_nix(domain)
|
151
|
-
webs = do_cmd("find ${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/WEB-INF/psftdocs/* -maxdepth 0",false).split(/\n+/)
|
152
|
-
webs.map! {|site| site.split("/")[-1]}
|
153
|
-
end
|
154
|
-
|
155
|
-
def find_apps_win
|
156
|
-
case "#{PS_MULTI_HOME}"
|
157
|
-
when "false"
|
158
|
-
apps = do_cmd("(get-childitem #{env('PS_CFG_HOME')}/appserv/*/psappsrv.ubx | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
159
|
-
else
|
160
|
-
apps = do_cmd("(get-childitem #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/appserv/*/psappsrv.ubx | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
161
|
-
end
|
162
|
-
apps.map! {|app| app.split('\\')[-2]}
|
163
|
-
end
|
164
|
-
|
165
|
-
def find_prcss_win
|
166
|
-
case "#{PS_MULTI_HOME}"
|
167
|
-
when "false"
|
168
|
-
prcss = do_cmd("(get-childitem #{env('PS_CFG_HOME')}/appserv/prcs/*/psprcsrv.ubx | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
169
|
-
else
|
170
|
-
prcss = do_cmd("(get-childitem #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/appserv/prcs/*/psprcsrv.ubx | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
171
|
-
end
|
172
|
-
prcss.map! {|prcs| prcs.split("\\")[-2]}
|
173
|
-
end
|
174
|
-
|
175
|
-
def find_webs_win
|
176
|
-
case "#{PS_MULTI_HOME}"
|
177
|
-
when "false"
|
178
|
-
webs = do_cmd("(get-childitem #{env('PS_CFG_HOME')}/webserv/*/piaconfig | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
179
|
-
else
|
180
|
-
webs = do_cmd("(get-childitem #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/webserv/*/piaconfig | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
181
|
-
end
|
182
|
-
webs.map! {|web| web.split("\\")[-2]}
|
183
|
-
end
|
184
|
-
|
185
|
-
def find_sites_win(domain)
|
186
|
-
#TODO
|
187
|
-
#sites = do_cmd("(get-childitem #{env('PS_CFG_HOME')}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/WEB-INF/psftdocs | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
188
|
-
#sites.map! {|site| site.split("\\")[-2]}
|
189
|
-
end
|
190
|
-
|
191
|
-
def find_apps
|
192
|
-
apps = "#{OS_CONST}" == "linux" ? find_apps_nix : find_apps_win
|
193
|
-
end
|
194
|
-
|
195
|
-
def find_prcss
|
196
|
-
prcss = "#{OS_CONST}" == "linux" ? find_prcss_nix : find_prcss_win
|
197
|
-
end
|
198
|
-
|
199
|
-
def find_webs
|
200
|
-
webs = "#{OS_CONST}" == "linux" ? find_webs_nix : find_webs_win
|
201
|
-
end
|
202
|
-
|
203
|
-
def find_sites(domain)
|
204
|
-
sites = "#{OS_CONST}" == "linux" ? find_sites_nix(domain) : find_sites_win(domain)
|
205
|
-
end
|
206
|
-
|
207
|
-
def do_util
|
208
|
-
puts "TODO: util"
|
209
|
-
end
|
210
|
-
|
211
|
-
def do_admin
|
212
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin")
|
213
|
-
end
|
214
|
-
|
215
|
-
def do_list
|
216
|
-
puts "---"
|
217
|
-
print "hostname: " ; do_cmd('hostname')
|
218
|
-
print "ps-home: " ; do_cmd('echo ' + env('PS_HOME'))
|
219
|
-
if PS_MULTI_HOME == "false"
|
220
|
-
print "ps-cfg-home: " ; do_cmd('echo ' + env('PS_CFG_HOME'))
|
221
|
-
else
|
222
|
-
puts "ps-cfg-home base: #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*"
|
223
|
-
end
|
224
|
-
puts ""
|
225
|
-
puts "PS_RUNTIME_USER: #{PS_RUNTIME_USER}"
|
226
|
-
puts "PS_PSA_SUDO: #{PS_PSA_SUDO}"
|
227
|
-
puts "PS_HOOK_INTERP: #{PS_HOOK_INTERP}"
|
228
|
-
puts "PS_HOOK_PRE: #{PS_HOOK_PRE}"
|
229
|
-
puts "PS_HOOK_POST: #{PS_HOOK_POST}"
|
230
|
-
puts "PS_HOOK_START: #{PS_HOOK_START}"
|
231
|
-
puts "PS_HOOK_STOP: #{PS_HOOK_STOP}"
|
232
|
-
puts "PS_WIN_SERVICES: #{PS_WIN_SERVICES}"
|
233
|
-
puts "PS_MULTI_HOME: #{PS_MULTI_HOME}"
|
234
|
-
puts "PS_PARALLEL_BOOT: #{PS_PARALLEL_BOOT}"
|
235
|
-
puts "PS_PSA_DEBUG: #{PS_PSA_DEBUG}"
|
236
|
-
puts ""
|
237
|
-
puts "app:"
|
238
|
-
find_apps.each do |a|
|
239
|
-
puts " - #{a}"
|
240
|
-
end
|
241
|
-
puts ""
|
242
|
-
puts "prcs:"
|
243
|
-
find_prcss.each do |p|
|
244
|
-
puts " - #{p}"
|
245
|
-
end
|
246
|
-
puts ""
|
247
|
-
puts "web:"
|
248
|
-
find_webs.each do |w|
|
249
|
-
puts " - #{w}"
|
250
|
-
end
|
251
|
-
puts ""
|
252
|
-
end
|
253
|
-
|
254
|
-
def do_psadmin_check
|
255
|
-
# Check to see if psadmin loads correctly
|
256
|
-
# This will help when used on web servers that don't have Tuxedo
|
257
|
-
case "#{PS_PSA_DEBUG}"
|
258
|
-
when "true"
|
259
|
-
puts "Checking psadmin version to validate configuration:"
|
260
|
-
check = do_cmd("#{PS_PSADMIN_PATH}/psadmin -v 2>&1",true)
|
261
|
-
else
|
262
|
-
check = do_cmd("#{PS_PSADMIN_PATH}/psadmin -v 2>&1",false)
|
263
|
-
end
|
264
|
-
if check.include? "error"
|
265
|
-
# psadmin config is NOT valid
|
266
|
-
puts "ERROR: psadmin is not configured correctly for this environment!"
|
267
|
-
puts " Some psadmin-plus actions only work when Tuxedo and psadmin are configured"
|
268
|
-
false
|
269
|
-
else
|
270
|
-
# psadmin config is valid
|
271
|
-
true
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
def do_summary
|
276
|
-
if "#{PS_MULTI_HOME}" != "false"
|
277
|
-
ENV['PS_CFG_HOME'] = "#{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}#{domain}"
|
278
|
-
end
|
279
|
-
|
280
|
-
do_psadmin_check ? nil : exit
|
281
|
-
|
282
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -envsummary")
|
283
|
-
#do_status("web","all")
|
284
|
-
end
|
285
|
-
|
286
|
-
def do_status(type, domain)
|
287
|
-
case type
|
288
|
-
when "app"
|
289
|
-
do_psadmin_check ? nil : return
|
290
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c sstatus -d #{domain}")
|
291
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c cstatus -d #{domain}")
|
292
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c qstatus -d #{domain}")
|
293
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c pslist -d #{domain}")
|
294
|
-
when "pubsub"
|
295
|
-
ENV['TUXCONFIG'] = "#{ENV['PS_CFG_HOME']}/appserv/#{domain}/PSTUXCFG"
|
296
|
-
do_cmd("echo 'printserver -g PUBSUB' | #{ENV['TUXDIR']}/bin/tmadmin")
|
297
|
-
when "prcs"
|
298
|
-
do_psadmin_check ? nil : return
|
299
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -p status -d #{domain}")
|
300
|
-
when "web"
|
301
|
-
# TODO - PIA script status? 1. psadmin, 2. script, 3. lock file, 4. service
|
302
|
-
#do_psadmin_check ? nil : return
|
303
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -w status -d #{domain}")
|
304
|
-
#do_cmd("${PS_CFG_HOME?}/webserv/#{domain}/bin/singleserverStatus.sh")
|
305
|
-
#if File.exist?("#{ENV['PS_CFG_HOME']}/webserv/#{domain}/servers/PIA/tmp/PIA.lok")
|
306
|
-
else
|
307
|
-
puts "Invalid type, see psa help"
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
def do_start(type, domain)
|
312
|
-
web_service_name = ENV['WEB_SERVICE_NAME'] || "Psft*Pia*#{domain}*"
|
313
|
-
app_service_name = ENV['APP_SERVICE_NAME'] || "Psft*App*#{domain}*"
|
314
|
-
prcs_service_name = ENV['PRCS_SERVICE_NAME'] || "Psft*Prcs*#{domain}*"
|
315
|
-
|
316
|
-
case "#{PS_PARALLEL_BOOT}"
|
317
|
-
when "false"
|
318
|
-
start_app_cmd = "#{PS_PSADMIN_PATH}/psadmin -c boot -d #{domain}"
|
319
|
-
when "true"
|
320
|
-
start_app_cmd = "#{PS_PSADMIN_PATH}/psadmin -c parallelboot -d #{domain}"
|
321
|
-
end
|
322
|
-
start_app_service_cmd = "start-service #{app_service_name}"
|
323
|
-
start_prcs_cmd = "#{PS_PSADMIN_PATH}/psadmin -p start -d #{domain}"
|
324
|
-
start_prcs_service_cmd = "start-service #{prcs_service_name}"
|
325
|
-
start_web_cmd_lnx = "${PS_CFG_HOME?}/webserv/#{domain}/bin/startPIA.sh"
|
326
|
-
start_web_cmd_win = "#{PS_PSADMIN_PATH}/psadmin -w start -d #{domain}"
|
327
|
-
start_web_service_cmd = "start-service #{web_service_name}"
|
328
|
-
|
329
|
-
case type
|
330
|
-
when "app"
|
331
|
-
case "#{PS_WIN_SERVICES}"
|
332
|
-
when "true", "tux", "app", "all"
|
333
|
-
do_cmd(start_app_service_cmd)
|
334
|
-
else
|
335
|
-
do_cmd(start_app_cmd)
|
336
|
-
case "#{PS_TRAIL_SERVICE}"
|
337
|
-
when "true"
|
338
|
-
do_cmd(start_app_service_cmd)
|
339
|
-
end
|
340
|
-
end
|
341
|
-
do_hookstart("start",type,domain)
|
342
|
-
when "pubsub"
|
343
|
-
ENV['TUXCONFIG'] = "#{ENV['PS_CFG_HOME']}/appserv/#{domain}/PSTUXCFG"
|
344
|
-
do_cmd("echo 'boot -g PUBSUB' | #{ENV['TUXDIR']}/bin/tmadmin")
|
345
|
-
# do_hookstart("start",type,domain) - TODO skip hook for PUBSUB?
|
346
|
-
when "prcs"
|
347
|
-
case "#{PS_WIN_SERVICES}"
|
348
|
-
when "true", "tux", "prcs", "all"
|
349
|
-
do_cmd(start_prcs_service_cmd)
|
350
|
-
else
|
351
|
-
do_cmd(start_prcs_cmd)
|
352
|
-
case "#{PS_TRAIL_SERVICE}"
|
353
|
-
when "true"
|
354
|
-
do_cmd(start_prcs_service_cmd)
|
355
|
-
end
|
356
|
-
end
|
357
|
-
do_hookstart("start",type,domain)
|
358
|
-
when "web"
|
359
|
-
case "#{OS_CONST}"
|
360
|
-
when "linux"
|
361
|
-
if File.exist?("#{ENV['PS_CFG_HOME']}/webserv/#{domain}/servers/PIA/tmp/PIA.lok")
|
362
|
-
puts "Domain #{domain} already started"
|
363
|
-
else
|
364
|
-
do_cmd(start_web_cmd_lnx)
|
365
|
-
sleep 5.0
|
366
|
-
end
|
367
|
-
when "windows"
|
368
|
-
case "#{PS_WIN_SERVICES}"
|
369
|
-
when "true", "web", "all"
|
370
|
-
do_cmd(start_web_service_cmd)
|
371
|
-
else
|
372
|
-
# Run command outside of powershell with 'false' parameter
|
373
|
-
do_cmd(start_web_cmd_win, true, false)
|
374
|
-
case "#{PS_TRAIL_SERVICE}"
|
375
|
-
when "true", "web", "all"
|
376
|
-
do_cmd(start_web_service_cmd)
|
377
|
-
end
|
378
|
-
end
|
379
|
-
end
|
380
|
-
do_hookstart("start",type,domain)
|
381
|
-
else
|
382
|
-
puts "Invalid type, see psa help"
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
def do_stop(type, domain)
|
387
|
-
web_service_name = ENV['WEB_SERVICE_NAME'] || "Psft*Pia*#{domain}*"
|
388
|
-
app_service_name = ENV['APP_SERVICE_NAME'] || "Psft*App*#{domain}*"
|
389
|
-
prcs_service_name = ENV['PRCS_SERVICE_NAME'] || "Psft*Prcs*#{domain}*"
|
390
|
-
|
391
|
-
stop_app_cmd = "#{PS_PSADMIN_PATH}/psadmin -c shutdown -d #{domain}"
|
392
|
-
stop_app_service_cmd = "stop-service #{app_service_name}"
|
393
|
-
stop_prcs_cmd = "#{PS_PSADMIN_PATH}/psadmin -p stop -d #{domain}"
|
394
|
-
stop_prcs_service_cmd = "stop-service #{prcs_service_name}"
|
395
|
-
stop_web_cmd_lnx = "${PS_CFG_HOME?}/webserv/#{domain}/bin/stopPIA.sh"
|
396
|
-
stop_web_cmd_win = "#{PS_PSADMIN_PATH}/psadmin -w shutdown -d #{domain}"
|
397
|
-
stop_web_service_cmd = "stop-service #{web_service_name}"
|
398
|
-
|
399
|
-
case type
|
400
|
-
when "app"
|
401
|
-
do_hookstop("stop",type,domain)
|
402
|
-
case "#{PS_WIN_SERVICES}"
|
403
|
-
when "true"
|
404
|
-
do_cmd(stop_app_service_cmd)
|
405
|
-
else
|
406
|
-
do_cmd(stop_app_cmd)
|
407
|
-
case "#{PS_TRAIL_SERVICE}"
|
408
|
-
when "true"
|
409
|
-
do_cmd(stop_app_service_cmd)
|
410
|
-
end
|
411
|
-
end
|
412
|
-
when "pubsub"
|
413
|
-
# do_hookstop("stop",type,domain) - TODO skip hook for PUBSUB?
|
414
|
-
ENV['TUXCONFIG'] = "#{ENV['PS_CFG_HOME']}/appserv/#{domain}/PSTUXCFG"
|
415
|
-
do_cmd("echo 'shutdown -g PUBSUB' | #{ENV['TUXDIR']}/bin/tmadmin")
|
416
|
-
when "prcs"
|
417
|
-
do_hookstop("stop",type,domain)
|
418
|
-
case "#{PS_WIN_SERVICES}"
|
419
|
-
when "true"
|
420
|
-
do_cmd(stop_prcs_service_cmd)
|
421
|
-
else
|
422
|
-
do_cmd(stop_prcs_cmd)
|
423
|
-
case "#{PS_TRAIL_SERVICE}"
|
424
|
-
when "true"
|
425
|
-
do_cmd(stop_prcs_service_cmd)
|
426
|
-
end
|
427
|
-
end
|
428
|
-
when "web"
|
429
|
-
do_hookstop("stop",type,domain)
|
430
|
-
case "#{OS_CONST}"
|
431
|
-
when "linux"
|
432
|
-
do_cmd(stop_web_cmd_lnx)
|
433
|
-
when "windows"
|
434
|
-
case "#{PS_WIN_SERVICES}"
|
435
|
-
when "true"
|
436
|
-
do_cmd(stop_web_service_cmd)
|
437
|
-
else
|
438
|
-
do_cmd(stop_web_cmd_win, true, false)
|
439
|
-
case "#{PS_TRAIL_SERVICE}"
|
440
|
-
when "true"
|
441
|
-
do_cmd(stop_web_service_cmd)
|
442
|
-
end
|
443
|
-
end
|
444
|
-
end
|
445
|
-
else
|
446
|
-
puts "Invalid type, see psa help"
|
447
|
-
end
|
448
|
-
end
|
449
|
-
|
450
|
-
def do_kill(type, domain)
|
451
|
-
case type
|
452
|
-
when "app"
|
453
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c shutdown! -d #{domain}")
|
454
|
-
when "prcs"
|
455
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -p kill -d #{domain}")
|
456
|
-
when "web"
|
457
|
-
case "#{OS_CONST}"
|
458
|
-
when "windows"
|
459
|
-
do_cmd("(gwmi win32_process | where {$_.Name -eq 'Java.exe'} | where {$_.CommandLine -match '#{domain}'}).ProcessId -ErrorAction SilentlyContinue | % { stop-process $_ -force } -ErrorAction SilentlyContinue")
|
460
|
-
when "linux"
|
461
|
-
do_cmd("kill $(ps aux|grep java|grep ${PS_CFG_HOME?}/webserv/#{domain}/piaconfig|awk ' {print $2}')")
|
462
|
-
end
|
463
|
-
else
|
464
|
-
puts "Invalid type, see psa help"
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
|
-
def do_configure(type, domain)
|
469
|
-
case type
|
470
|
-
when "app"
|
471
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c configure -d #{domain}")
|
472
|
-
when "prcs"
|
473
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -p configure -d #{domain}")
|
474
|
-
when "web"
|
475
|
-
do_webprof_reload("#{domain}")
|
476
|
-
else
|
477
|
-
puts "Invalid type, see psa help"
|
478
|
-
end
|
479
|
-
end
|
480
|
-
|
481
|
-
def do_purge(type, domain)
|
482
|
-
case type
|
483
|
-
when "app"
|
484
|
-
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c purge -d #{domain}")
|
485
|
-
when "prcs"
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
when "
|
490
|
-
do_cmd("
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
end
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
do_start(type, domain)
|
522
|
-
end
|
523
|
-
|
524
|
-
def
|
525
|
-
do_stop(type, domain)
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
"#{PS_PSA_DEBUG}" == "true" ? (puts "
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
"#{PS_PSA_DEBUG}" == "true" ? (puts "
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
"#{PS_PSA_DEBUG}" == "true" ? (puts "
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
#
|
592
|
-
do_cmd("sed -i 's/ReloadWebProfileWithoutRestart=.*/ReloadWebProfileWithoutRestart=
|
593
|
-
|
594
|
-
#
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
#
|
606
|
-
|
607
|
-
#
|
608
|
-
|
609
|
-
#
|
610
|
-
#
|
611
|
-
# #
|
612
|
-
#
|
613
|
-
#
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
when /
|
631
|
-
:
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
require 'etc'
|
5
|
+
require 'open3'
|
6
|
+
|
7
|
+
def do_help
|
8
|
+
puts "Usage: psa [command] <type> <domain>"
|
9
|
+
puts " "
|
10
|
+
puts "Commands:"
|
11
|
+
puts " "
|
12
|
+
puts " help display this help message"
|
13
|
+
puts " list list domains"
|
14
|
+
#puts " admin launch psadmin"
|
15
|
+
puts " summary PS_CFG_HOME summary, no type or domain needed"
|
16
|
+
puts " status status of the domain"
|
17
|
+
puts " start hookstart, if enabled, then start the domain"
|
18
|
+
puts " stop hookstop, if enabled, stop the domain"
|
19
|
+
puts " restart stop and start the domain"
|
20
|
+
puts " purge clear domain cache"
|
21
|
+
puts " reconfigure stop, configure, and start the domain"
|
22
|
+
puts " bounce stop, flush, purge, configure and start the domain"
|
23
|
+
puts " kill force stop the domain"
|
24
|
+
puts " configure configure the domain"
|
25
|
+
puts " flush clear domain IPC"
|
26
|
+
puts " "
|
27
|
+
puts "Types:"
|
28
|
+
puts " "
|
29
|
+
puts " app act on application domains"
|
30
|
+
#puts " pubsub act on PUBSUB group of application domains"
|
31
|
+
puts " prcs act on process scheduler domains"
|
32
|
+
puts " web act on web domains"
|
33
|
+
puts " all,<blank> act on web, app, and prcs domains"
|
34
|
+
puts " "
|
35
|
+
puts "Domains:"
|
36
|
+
puts " "
|
37
|
+
puts " dom act on specific domains"
|
38
|
+
puts " all,<blank> act on all domains"
|
39
|
+
puts " "
|
40
|
+
puts "Each parameter type can be enter in a comma separated list "
|
41
|
+
puts " "
|
42
|
+
end
|
43
|
+
|
44
|
+
def do_is_runtime_user_nix
|
45
|
+
result = ENV['USER'] == PS_RUNTIME_USER ? true : false
|
46
|
+
end
|
47
|
+
|
48
|
+
def do_is_runtime_user_win
|
49
|
+
result = ENV['USERNAME'] == PS_RUNTIME_USER ? true : false
|
50
|
+
end
|
51
|
+
|
52
|
+
def env(var)
|
53
|
+
result = "#{OS_CONST}" == "linux" ? "${#{var}}" : "%#{var}%"
|
54
|
+
end
|
55
|
+
|
56
|
+
def do_cmd(cmd, print = true, powershell = true)
|
57
|
+
case "#{OS_CONST}"
|
58
|
+
when "linux"
|
59
|
+
if do_is_runtime_user_nix
|
60
|
+
case "#{PS_PSA_DEBUG}"
|
61
|
+
when "true"
|
62
|
+
p "Command: #{cmd}"
|
63
|
+
end
|
64
|
+
out = `#{cmd}`
|
65
|
+
else
|
66
|
+
if "#{PS_PSA_SUDO}" == "on"
|
67
|
+
case "#{PS_PSA_DEBUG}"
|
68
|
+
when "true"
|
69
|
+
p "Command: sudo su - #{PS_RUNTIME_USER} -c '#{cmd}'"
|
70
|
+
end
|
71
|
+
out = `sudo su - #{PS_RUNTIME_USER} -c '#{cmd}'`
|
72
|
+
else
|
73
|
+
print "#{PS_RUNTIME_USER} "
|
74
|
+
case "#{PS_PSA_DEBUG}"
|
75
|
+
when "true"
|
76
|
+
p "Command: su - #{PS_RUNTIME_USER} -c '#{cmd}'"
|
77
|
+
end
|
78
|
+
out = `su - #{PS_RUNTIME_USER} -c '#{cmd}'`
|
79
|
+
end
|
80
|
+
end
|
81
|
+
when "windows"
|
82
|
+
case powershell
|
83
|
+
when true
|
84
|
+
case "#{PS_PSA_DEBUG}"
|
85
|
+
when "true"
|
86
|
+
p "Command: powershell -NoProfile -Command \"#{cmd}\""
|
87
|
+
end
|
88
|
+
out = `powershell -NoProfile -Command "#{cmd}"`
|
89
|
+
else
|
90
|
+
case "#{PS_PSA_DEBUG}"
|
91
|
+
when "true"
|
92
|
+
p "Command: #{cmd}"
|
93
|
+
end
|
94
|
+
out = `#{cmd}`
|
95
|
+
end
|
96
|
+
else
|
97
|
+
out = "Invalid OS"
|
98
|
+
end
|
99
|
+
print ? (puts out) : result = out
|
100
|
+
out
|
101
|
+
end
|
102
|
+
|
103
|
+
def do_cmd_banner(c,t,d)
|
104
|
+
puts ""
|
105
|
+
puts "===[ #{c} . #{t} . #{d} ]==="
|
106
|
+
puts ""
|
107
|
+
end
|
108
|
+
|
109
|
+
def do_set_cfg_home(d)
|
110
|
+
if "#{PS_MULTI_HOME}" != "false"
|
111
|
+
if PS_MULTI_PREFIX > 0
|
112
|
+
h = d.slice(0..PS_MULTI_PREFIX)
|
113
|
+
else
|
114
|
+
h = d
|
115
|
+
end
|
116
|
+
ENV['PS_CFG_HOME'] = "#{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}#{h}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def find_apps_nix
|
121
|
+
case "#{PS_MULTI_HOME}"
|
122
|
+
when "false"
|
123
|
+
apps = do_cmd("find #{env('PS_CFG_HOME')}/appserv/*/psappsrv.ubx 2>/dev/null",false).split(/\n+/)
|
124
|
+
else
|
125
|
+
apps = do_cmd("find #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/appserv/*/psappsrv.ubx 2>/dev/null",false).split(/\n+/)
|
126
|
+
end
|
127
|
+
apps.map! {|app| app.split("/")[-2]}
|
128
|
+
end
|
129
|
+
|
130
|
+
def find_prcss_nix
|
131
|
+
case "#{PS_MULTI_HOME}"
|
132
|
+
when "false"
|
133
|
+
prcss = do_cmd("find #{env('PS_CFG_HOME')}/appserv/prcs/*/psprcsrv.ubx 2>/dev/null",false).split(/\n+/)
|
134
|
+
else
|
135
|
+
prcss = do_cmd("find #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/appserv/prcs/*/psprcsrv.ubx 2>/dev/null",false).split(/\n+/)
|
136
|
+
end
|
137
|
+
prcss.map! {|prcs| prcs.split("/")[-2]}
|
138
|
+
end
|
139
|
+
|
140
|
+
def find_webs_nix
|
141
|
+
case "#{PS_MULTI_HOME}"
|
142
|
+
when "false"
|
143
|
+
webs = do_cmd("find #{env('PS_CFG_HOME')}/webserv/*/piaconfig -maxdepth 0",false).split(/\n+/)
|
144
|
+
else
|
145
|
+
webs = do_cmd("find #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/webserv/*/piaconfig -maxdepth 0",false).split(/\n+/)
|
146
|
+
end
|
147
|
+
webs.map! {|web| web.split("/")[-2]}
|
148
|
+
end
|
149
|
+
|
150
|
+
def find_sites_nix(domain)
|
151
|
+
webs = do_cmd("find ${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/WEB-INF/psftdocs/* -maxdepth 0",false).split(/\n+/)
|
152
|
+
webs.map! {|site| site.split("/")[-1]}
|
153
|
+
end
|
154
|
+
|
155
|
+
def find_apps_win
|
156
|
+
case "#{PS_MULTI_HOME}"
|
157
|
+
when "false"
|
158
|
+
apps = do_cmd("(get-childitem #{env('PS_CFG_HOME')}/appserv/*/psappsrv.ubx | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
159
|
+
else
|
160
|
+
apps = do_cmd("(get-childitem #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/appserv/*/psappsrv.ubx | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
161
|
+
end
|
162
|
+
apps.map! {|app| app.split('\\')[-2]}
|
163
|
+
end
|
164
|
+
|
165
|
+
def find_prcss_win
|
166
|
+
case "#{PS_MULTI_HOME}"
|
167
|
+
when "false"
|
168
|
+
prcss = do_cmd("(get-childitem #{env('PS_CFG_HOME')}/appserv/prcs/*/psprcsrv.ubx | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
169
|
+
else
|
170
|
+
prcss = do_cmd("(get-childitem #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/appserv/prcs/*/psprcsrv.ubx | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
171
|
+
end
|
172
|
+
prcss.map! {|prcs| prcs.split("\\")[-2]}
|
173
|
+
end
|
174
|
+
|
175
|
+
def find_webs_win
|
176
|
+
case "#{PS_MULTI_HOME}"
|
177
|
+
when "false"
|
178
|
+
webs = do_cmd("(get-childitem #{env('PS_CFG_HOME')}/webserv/*/piaconfig | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
179
|
+
else
|
180
|
+
webs = do_cmd("(get-childitem #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*/webserv/*/piaconfig | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
181
|
+
end
|
182
|
+
webs.map! {|web| web.split("\\")[-2]}
|
183
|
+
end
|
184
|
+
|
185
|
+
def find_sites_win(domain)
|
186
|
+
#TODO
|
187
|
+
#sites = do_cmd("(get-childitem #{env('PS_CFG_HOME')}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/WEB-INF/psftdocs | Format-Table -property FullName -HideTableHeaders | Out-String).Trim()",false).split(/\n+/)
|
188
|
+
#sites.map! {|site| site.split("\\")[-2]}
|
189
|
+
end
|
190
|
+
|
191
|
+
def find_apps
|
192
|
+
apps = "#{OS_CONST}" == "linux" ? find_apps_nix : find_apps_win
|
193
|
+
end
|
194
|
+
|
195
|
+
def find_prcss
|
196
|
+
prcss = "#{OS_CONST}" == "linux" ? find_prcss_nix : find_prcss_win
|
197
|
+
end
|
198
|
+
|
199
|
+
def find_webs
|
200
|
+
webs = "#{OS_CONST}" == "linux" ? find_webs_nix : find_webs_win
|
201
|
+
end
|
202
|
+
|
203
|
+
def find_sites(domain)
|
204
|
+
sites = "#{OS_CONST}" == "linux" ? find_sites_nix(domain) : find_sites_win(domain)
|
205
|
+
end
|
206
|
+
|
207
|
+
def do_util
|
208
|
+
puts "TODO: util"
|
209
|
+
end
|
210
|
+
|
211
|
+
def do_admin
|
212
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin")
|
213
|
+
end
|
214
|
+
|
215
|
+
def do_list
|
216
|
+
puts "---"
|
217
|
+
print "hostname: " ; do_cmd('hostname')
|
218
|
+
print "ps-home: " ; do_cmd('echo ' + env('PS_HOME'))
|
219
|
+
if PS_MULTI_HOME == "false"
|
220
|
+
print "ps-cfg-home: " ; do_cmd('echo ' + env('PS_CFG_HOME'))
|
221
|
+
else
|
222
|
+
puts "ps-cfg-home base: #{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}*"
|
223
|
+
end
|
224
|
+
puts ""
|
225
|
+
puts "PS_RUNTIME_USER: #{PS_RUNTIME_USER}"
|
226
|
+
puts "PS_PSA_SUDO: #{PS_PSA_SUDO}"
|
227
|
+
puts "PS_HOOK_INTERP: #{PS_HOOK_INTERP}"
|
228
|
+
puts "PS_HOOK_PRE: #{PS_HOOK_PRE}"
|
229
|
+
puts "PS_HOOK_POST: #{PS_HOOK_POST}"
|
230
|
+
puts "PS_HOOK_START: #{PS_HOOK_START}"
|
231
|
+
puts "PS_HOOK_STOP: #{PS_HOOK_STOP}"
|
232
|
+
puts "PS_WIN_SERVICES: #{PS_WIN_SERVICES}"
|
233
|
+
puts "PS_MULTI_HOME: #{PS_MULTI_HOME}"
|
234
|
+
puts "PS_PARALLEL_BOOT: #{PS_PARALLEL_BOOT}"
|
235
|
+
puts "PS_PSA_DEBUG: #{PS_PSA_DEBUG}"
|
236
|
+
puts ""
|
237
|
+
puts "app:"
|
238
|
+
find_apps.each do |a|
|
239
|
+
puts " - #{a}"
|
240
|
+
end
|
241
|
+
puts ""
|
242
|
+
puts "prcs:"
|
243
|
+
find_prcss.each do |p|
|
244
|
+
puts " - #{p}"
|
245
|
+
end
|
246
|
+
puts ""
|
247
|
+
puts "web:"
|
248
|
+
find_webs.each do |w|
|
249
|
+
puts " - #{w}"
|
250
|
+
end
|
251
|
+
puts ""
|
252
|
+
end
|
253
|
+
|
254
|
+
def do_psadmin_check
|
255
|
+
# Check to see if psadmin loads correctly
|
256
|
+
# This will help when used on web servers that don't have Tuxedo
|
257
|
+
case "#{PS_PSA_DEBUG}"
|
258
|
+
when "true"
|
259
|
+
puts "Checking psadmin version to validate configuration:"
|
260
|
+
check = do_cmd("#{PS_PSADMIN_PATH}/psadmin -v 2>&1",true)
|
261
|
+
else
|
262
|
+
check = do_cmd("#{PS_PSADMIN_PATH}/psadmin -v 2>&1",false)
|
263
|
+
end
|
264
|
+
if check.include? "error"
|
265
|
+
# psadmin config is NOT valid
|
266
|
+
puts "ERROR: psadmin is not configured correctly for this environment!"
|
267
|
+
puts " Some psadmin-plus actions only work when Tuxedo and psadmin are configured"
|
268
|
+
false
|
269
|
+
else
|
270
|
+
# psadmin config is valid
|
271
|
+
true
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def do_summary
|
276
|
+
if "#{PS_MULTI_HOME}" != "false"
|
277
|
+
ENV['PS_CFG_HOME'] = "#{PS_MULTI_HOME}#{PS_MULTI_DELIMIT}#{domain}"
|
278
|
+
end
|
279
|
+
|
280
|
+
do_psadmin_check ? nil : exit
|
281
|
+
|
282
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -envsummary")
|
283
|
+
#do_status("web","all")
|
284
|
+
end
|
285
|
+
|
286
|
+
def do_status(type, domain)
|
287
|
+
case type
|
288
|
+
when "app"
|
289
|
+
do_psadmin_check ? nil : return
|
290
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c sstatus -d #{domain}")
|
291
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c cstatus -d #{domain}")
|
292
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c qstatus -d #{domain}")
|
293
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c pslist -d #{domain}")
|
294
|
+
when "pubsub"
|
295
|
+
ENV['TUXCONFIG'] = "#{ENV['PS_CFG_HOME']}/appserv/#{domain}/PSTUXCFG"
|
296
|
+
do_cmd("echo 'printserver -g PUBSUB' | #{ENV['TUXDIR']}/bin/tmadmin")
|
297
|
+
when "prcs"
|
298
|
+
do_psadmin_check ? nil : return
|
299
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -p status -d #{domain}")
|
300
|
+
when "web"
|
301
|
+
# TODO - PIA script status? 1. psadmin, 2. script, 3. lock file, 4. service
|
302
|
+
#do_psadmin_check ? nil : return
|
303
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -w status -d #{domain}")
|
304
|
+
#do_cmd("${PS_CFG_HOME?}/webserv/#{domain}/bin/singleserverStatus.sh")
|
305
|
+
#if File.exist?("#{ENV['PS_CFG_HOME']}/webserv/#{domain}/servers/PIA/tmp/PIA.lok")
|
306
|
+
else
|
307
|
+
puts "Invalid type, see psa help"
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def do_start(type, domain)
|
312
|
+
web_service_name = ENV['WEB_SERVICE_NAME'] || "Psft*Pia*#{domain}*"
|
313
|
+
app_service_name = ENV['APP_SERVICE_NAME'] || "Psft*App*#{domain}*"
|
314
|
+
prcs_service_name = ENV['PRCS_SERVICE_NAME'] || "Psft*Prcs*#{domain}*"
|
315
|
+
|
316
|
+
case "#{PS_PARALLEL_BOOT}"
|
317
|
+
when "false"
|
318
|
+
start_app_cmd = "#{PS_PSADMIN_PATH}/psadmin -c boot -d #{domain}"
|
319
|
+
when "true"
|
320
|
+
start_app_cmd = "#{PS_PSADMIN_PATH}/psadmin -c parallelboot -d #{domain}"
|
321
|
+
end
|
322
|
+
start_app_service_cmd = "start-service #{app_service_name}"
|
323
|
+
start_prcs_cmd = "#{PS_PSADMIN_PATH}/psadmin -p start -d #{domain}"
|
324
|
+
start_prcs_service_cmd = "start-service #{prcs_service_name}"
|
325
|
+
start_web_cmd_lnx = "${PS_CFG_HOME?}/webserv/#{domain}/bin/startPIA.sh"
|
326
|
+
start_web_cmd_win = "#{PS_PSADMIN_PATH}/psadmin -w start -d #{domain}"
|
327
|
+
start_web_service_cmd = "start-service #{web_service_name}"
|
328
|
+
|
329
|
+
case type
|
330
|
+
when "app"
|
331
|
+
case "#{PS_WIN_SERVICES}"
|
332
|
+
when "true", "tux", "app", "all"
|
333
|
+
do_cmd(start_app_service_cmd)
|
334
|
+
else
|
335
|
+
do_cmd(start_app_cmd)
|
336
|
+
case "#{PS_TRAIL_SERVICE}"
|
337
|
+
when "true"
|
338
|
+
do_cmd(start_app_service_cmd)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
do_hookstart("start",type,domain)
|
342
|
+
when "pubsub"
|
343
|
+
ENV['TUXCONFIG'] = "#{ENV['PS_CFG_HOME']}/appserv/#{domain}/PSTUXCFG"
|
344
|
+
do_cmd("echo 'boot -g PUBSUB' | #{ENV['TUXDIR']}/bin/tmadmin")
|
345
|
+
# do_hookstart("start",type,domain) - TODO skip hook for PUBSUB?
|
346
|
+
when "prcs"
|
347
|
+
case "#{PS_WIN_SERVICES}"
|
348
|
+
when "true", "tux", "prcs", "all"
|
349
|
+
do_cmd(start_prcs_service_cmd)
|
350
|
+
else
|
351
|
+
do_cmd(start_prcs_cmd)
|
352
|
+
case "#{PS_TRAIL_SERVICE}"
|
353
|
+
when "true"
|
354
|
+
do_cmd(start_prcs_service_cmd)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
do_hookstart("start",type,domain)
|
358
|
+
when "web"
|
359
|
+
case "#{OS_CONST}"
|
360
|
+
when "linux"
|
361
|
+
if File.exist?("#{ENV['PS_CFG_HOME']}/webserv/#{domain}/servers/PIA/tmp/PIA.lok")
|
362
|
+
puts "Domain #{domain} already started"
|
363
|
+
else
|
364
|
+
do_cmd(start_web_cmd_lnx)
|
365
|
+
sleep 5.0
|
366
|
+
end
|
367
|
+
when "windows"
|
368
|
+
case "#{PS_WIN_SERVICES}"
|
369
|
+
when "true", "web", "all"
|
370
|
+
do_cmd(start_web_service_cmd)
|
371
|
+
else
|
372
|
+
# Run command outside of powershell with 'false' parameter
|
373
|
+
do_cmd(start_web_cmd_win, true, false)
|
374
|
+
case "#{PS_TRAIL_SERVICE}"
|
375
|
+
when "true", "web", "all"
|
376
|
+
do_cmd(start_web_service_cmd)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
do_hookstart("start",type,domain)
|
381
|
+
else
|
382
|
+
puts "Invalid type, see psa help"
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
def do_stop(type, domain)
|
387
|
+
web_service_name = ENV['WEB_SERVICE_NAME'] || "Psft*Pia*#{domain}*"
|
388
|
+
app_service_name = ENV['APP_SERVICE_NAME'] || "Psft*App*#{domain}*"
|
389
|
+
prcs_service_name = ENV['PRCS_SERVICE_NAME'] || "Psft*Prcs*#{domain}*"
|
390
|
+
|
391
|
+
stop_app_cmd = "#{PS_PSADMIN_PATH}/psadmin -c shutdown -d #{domain}"
|
392
|
+
stop_app_service_cmd = "stop-service #{app_service_name}"
|
393
|
+
stop_prcs_cmd = "#{PS_PSADMIN_PATH}/psadmin -p stop -d #{domain}"
|
394
|
+
stop_prcs_service_cmd = "stop-service #{prcs_service_name}"
|
395
|
+
stop_web_cmd_lnx = "${PS_CFG_HOME?}/webserv/#{domain}/bin/stopPIA.sh"
|
396
|
+
stop_web_cmd_win = "#{PS_PSADMIN_PATH}/psadmin -w shutdown -d #{domain}"
|
397
|
+
stop_web_service_cmd = "stop-service #{web_service_name}"
|
398
|
+
|
399
|
+
case type
|
400
|
+
when "app"
|
401
|
+
do_hookstop("stop",type,domain)
|
402
|
+
case "#{PS_WIN_SERVICES}"
|
403
|
+
when "true"
|
404
|
+
do_cmd(stop_app_service_cmd)
|
405
|
+
else
|
406
|
+
do_cmd(stop_app_cmd)
|
407
|
+
case "#{PS_TRAIL_SERVICE}"
|
408
|
+
when "true"
|
409
|
+
do_cmd(stop_app_service_cmd)
|
410
|
+
end
|
411
|
+
end
|
412
|
+
when "pubsub"
|
413
|
+
# do_hookstop("stop",type,domain) - TODO skip hook for PUBSUB?
|
414
|
+
ENV['TUXCONFIG'] = "#{ENV['PS_CFG_HOME']}/appserv/#{domain}/PSTUXCFG"
|
415
|
+
do_cmd("echo 'shutdown -g PUBSUB' | #{ENV['TUXDIR']}/bin/tmadmin")
|
416
|
+
when "prcs"
|
417
|
+
do_hookstop("stop",type,domain)
|
418
|
+
case "#{PS_WIN_SERVICES}"
|
419
|
+
when "true"
|
420
|
+
do_cmd(stop_prcs_service_cmd)
|
421
|
+
else
|
422
|
+
do_cmd(stop_prcs_cmd)
|
423
|
+
case "#{PS_TRAIL_SERVICE}"
|
424
|
+
when "true"
|
425
|
+
do_cmd(stop_prcs_service_cmd)
|
426
|
+
end
|
427
|
+
end
|
428
|
+
when "web"
|
429
|
+
do_hookstop("stop",type,domain)
|
430
|
+
case "#{OS_CONST}"
|
431
|
+
when "linux"
|
432
|
+
do_cmd(stop_web_cmd_lnx)
|
433
|
+
when "windows"
|
434
|
+
case "#{PS_WIN_SERVICES}"
|
435
|
+
when "true"
|
436
|
+
do_cmd(stop_web_service_cmd)
|
437
|
+
else
|
438
|
+
do_cmd(stop_web_cmd_win, true, false)
|
439
|
+
case "#{PS_TRAIL_SERVICE}"
|
440
|
+
when "true"
|
441
|
+
do_cmd(stop_web_service_cmd)
|
442
|
+
end
|
443
|
+
end
|
444
|
+
end
|
445
|
+
else
|
446
|
+
puts "Invalid type, see psa help"
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
def do_kill(type, domain)
|
451
|
+
case type
|
452
|
+
when "app"
|
453
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c shutdown! -d #{domain}")
|
454
|
+
when "prcs"
|
455
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -p kill -d #{domain}")
|
456
|
+
when "web"
|
457
|
+
case "#{OS_CONST}"
|
458
|
+
when "windows"
|
459
|
+
do_cmd("(gwmi win32_process | where {$_.Name -eq 'Java.exe'} | where {$_.CommandLine -match '#{domain}'}).ProcessId -ErrorAction SilentlyContinue | % { stop-process $_ -force } -ErrorAction SilentlyContinue")
|
460
|
+
when "linux"
|
461
|
+
do_cmd("kill $(ps aux|grep java|grep ${PS_CFG_HOME?}/webserv/#{domain}/piaconfig|awk ' {print $2}')")
|
462
|
+
end
|
463
|
+
else
|
464
|
+
puts "Invalid type, see psa help"
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
def do_configure(type, domain)
|
469
|
+
case type
|
470
|
+
when "app"
|
471
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c configure -d #{domain}")
|
472
|
+
when "prcs"
|
473
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -p configure -d #{domain}")
|
474
|
+
when "web"
|
475
|
+
do_webprof_reload("#{domain}")
|
476
|
+
else
|
477
|
+
puts "Invalid type, see psa help"
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
def do_purge(type, domain)
|
482
|
+
case type
|
483
|
+
when "app"
|
484
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c purge -d #{domain}")
|
485
|
+
when "prcs"
|
486
|
+
case "#{OS_CONST}"
|
487
|
+
when "linux"
|
488
|
+
do_cmd("rm -rf ${PS_CFG_HOME?}/appserv/prcs/#{domain}/CACHE/*")
|
489
|
+
when "windows"
|
490
|
+
do_cmd("Remove-Item $(Get-ChildItem ${env:PS_CFG_HOME}/appserv/prcs/#{domain}/CACHE/* | ?{ $_.PSIsContainer}) -recurse -force -ErrorAction SilentlyContinue".gsub('/','\\'))
|
491
|
+
end
|
492
|
+
puts "prcs cache purged"
|
493
|
+
when "web"
|
494
|
+
case "#{OS_CONST}"
|
495
|
+
when "linux"
|
496
|
+
do_cmd("rm -rf ${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL*/*/cache*/")
|
497
|
+
puts "web cache purged"
|
498
|
+
when "windows"
|
499
|
+
do_cmd("Remove-Item $(Get-ChildItem ${env:PS_CFG_HOME}/webserv/#{domain}/applications/peoplesoft/PORTAL*/*/cache*/ | ?{ $_.PSIsContainer}) -recurse -force -ErrorAction SilentlyContinue".gsub('/','\\'))
|
500
|
+
end
|
501
|
+
else
|
502
|
+
puts "Invalid type, see psa help"
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
def do_flush(type, domain)
|
507
|
+
case type
|
508
|
+
when "app"
|
509
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -c cleanipc -d #{domain}")
|
510
|
+
when "prcs"
|
511
|
+
do_cmd("#{PS_PSADMIN_PATH}/psadmin -p cleanipc -d #{domain}")
|
512
|
+
when "web"
|
513
|
+
return # web flush n/a
|
514
|
+
else
|
515
|
+
puts "Invalid type, see psa help"
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
def do_restart(type, domain)
|
520
|
+
do_stop(type, domain)
|
521
|
+
do_start(type, domain)
|
522
|
+
end
|
523
|
+
|
524
|
+
def do_reconfigure(type, domain)
|
525
|
+
do_stop(type, domain)
|
526
|
+
do_configure(type, domain)
|
527
|
+
do_start(type, domain)
|
528
|
+
end
|
529
|
+
|
530
|
+
def do_bounce(type, domain)
|
531
|
+
do_stop(type, domain)
|
532
|
+
do_purge(type, domain)
|
533
|
+
do_flush(type, domain)
|
534
|
+
do_configure(type, domain)
|
535
|
+
do_start(type, domain)
|
536
|
+
end
|
537
|
+
|
538
|
+
def do_hook(command, type, domain, script)
|
539
|
+
ENV['PSA_CMD'] = command
|
540
|
+
ENV['PSA_TYPE'] = type
|
541
|
+
ENV['PSA_DOMAIN'] = domain
|
542
|
+
out = `#{PS_HOOK_INTERP} #{script}`
|
543
|
+
puts out
|
544
|
+
end
|
545
|
+
|
546
|
+
def do_hookpre(command, type, domain)
|
547
|
+
if "#{PS_HOOK_PRE}" != "false"
|
548
|
+
"#{PS_PSA_DEBUG}" == "true" ? (puts "Executing domain pre command hook...\n\n") : nil
|
549
|
+
do_hook(command, type, domain, PS_HOOK_PRE)
|
550
|
+
"#{PS_PSA_DEBUG}" == "true" ? (puts "\n...hook done") : nil
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
def do_hookpost(command, type, domain)
|
555
|
+
if "#{PS_HOOK_POST}" != "false"
|
556
|
+
"#{PS_PSA_DEBUG}" == "true" ? (puts "Executing domain post command hook...\n\n") : nil
|
557
|
+
do_hook(command, type, domain, PS_HOOK_POST)
|
558
|
+
"#{PS_PSA_DEBUG}" == "true" ? (puts "\n...hook done") : nil
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
def do_hookstart(command, type, domain)
|
563
|
+
if "#{PS_HOOK_START}" != "false"
|
564
|
+
"#{PS_PSA_DEBUG}" == "true" ? (puts "Executing domain start hook...\n\n") : nil
|
565
|
+
do_hook(command, type, domain, PS_HOOK_START)
|
566
|
+
"#{PS_PSA_DEBUG}" == "true" ? (puts "\n...hook done") : nil
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
def do_hookstop(command, type, domain)
|
571
|
+
if "#{PS_HOOK_STOP}" != "false"
|
572
|
+
"#{PS_PSA_DEBUG}" == "true" ? (puts "Executing domain stop hook...\n\n") : nil
|
573
|
+
do_hook(command, type, domain, PS_HOOK_STOP)
|
574
|
+
"#{PS_PSA_DEBUG}" == "true" ? (puts "\n...hook done") : nil
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
def do_webprof_reload(domain)
|
579
|
+
puts "Reloading Web Profiles"
|
580
|
+
|
581
|
+
case "#{OS_CONST}"
|
582
|
+
when "linux"
|
583
|
+
"#{PS_PSA_DEBUG}" == "true" ? show_debug = true : show_debug = false
|
584
|
+
|
585
|
+
find_sites(domain).each do |s|
|
586
|
+
# set vars
|
587
|
+
url = "${ADMINSERVER_PROTOCOL?}://${ADMINSERVER_HOSTNAME?}:${ADMINSERVER_PORT?}/psp/#{s}/?cmd=login&"
|
588
|
+
src_env = ". ${PS_CFG_HOME?}/webserv/#{domain}/bin/setEnv.sh"
|
589
|
+
prop_file = "${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/WEB-INF/psftdocs/#{s}/configuration.properties"
|
590
|
+
|
591
|
+
# set reload in config.props
|
592
|
+
do_cmd("sed -i 's/ReloadWebProfileWithoutRestart=.*/ReloadWebProfileWithoutRestart=1/g' #{prop_file}",show_debug)
|
593
|
+
|
594
|
+
# source setEnv and ping site
|
595
|
+
show_debug ? do_cmd("#{src_env} ; curl -s #{url}",show_debug) : do_cmd("#{src_env} ; curl -s -o /dev/null #{url}",show_debug)
|
596
|
+
|
597
|
+
# unset reload in config.props
|
598
|
+
do_cmd("sed -i 's/ReloadWebProfileWithoutRestart=.*/ReloadWebProfileWithoutRestart=0/g' #{prop_file}",show_debug)
|
599
|
+
|
600
|
+
# done
|
601
|
+
puts " - #{s}"
|
602
|
+
end
|
603
|
+
when "windows"
|
604
|
+
puts "Windows support coming soon."
|
605
|
+
#do_cmd(". #{env('PS_CFG_HOME')}/webserv/#{domain}/bin/setEnv.sh")
|
606
|
+
|
607
|
+
#find_sites.each do |s|
|
608
|
+
# # set vars
|
609
|
+
# prop_file = "#{env('PS_CFG_HOME')}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/WEB-INF/psftdocs/#{s}}/configuration.properties"
|
610
|
+
# url = "http://#{PS_PIA_HOST}.#{PS_PIA_DOMAIN}:#{PS_PIA_PORT}/psp/#{s}/?cmd=login&"
|
611
|
+
# # set reload in config.props
|
612
|
+
# do_cmd("sed -i 's/ReloadWebProfileWithoutRestart=.*/ReloadWebProfileWithoutRestart=1/g' #{prop_file}")
|
613
|
+
# # ping site
|
614
|
+
# do_cmd("curl -s -o /dev/null '#{url}'")
|
615
|
+
# # unset reload in config.props
|
616
|
+
# do_cmd("sed -i 's/ReloadWebProfileWithoutRestart=.*/ReloadWebProfileWithoutRestart=0/g' #{prop_file}")
|
617
|
+
# # done
|
618
|
+
# puts " - #{s}"
|
619
|
+
#end
|
620
|
+
else
|
621
|
+
puts " badOS - #{OS_CONST}"
|
622
|
+
end
|
623
|
+
puts ""
|
624
|
+
end
|
625
|
+
|
626
|
+
def os
|
627
|
+
@os ||= (
|
628
|
+
host_os = RbConfig::CONFIG['host_os']
|
629
|
+
case host_os
|
630
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
631
|
+
:windows
|
632
|
+
when /darwin|mac os/
|
633
|
+
:macosx
|
634
|
+
when /linux/
|
635
|
+
:linux
|
636
|
+
when /solaris|bsd/
|
637
|
+
:unix
|
638
|
+
else
|
639
|
+
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
|
640
|
+
end
|
641
|
+
)
|
642
|
+
end
|