psadmin_plus 0.0.3 → 0.0.5

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/psa +1 -0
  3. data/lib/psadmin_plus.rb +69 -39
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94a23ba6cfdca3623387063ce62cde0e70ce170b
4
- data.tar.gz: eb8d08c06c86e126b8ddd7d0c360cf516f83e312
3
+ metadata.gz: 8f578164acadfe6f58fdf06b7c7f0e8648cd46bc
4
+ data.tar.gz: 3e8bf500b195186d4494ec1ed228d524b4066828
5
5
  SHA512:
6
- metadata.gz: 69d77322c757cda49389ea64f3bf3ac0500b9231aa38d7adb73fc52aa689aa31c937335e5e0778f7fc0b8e9a1df75620e03471a24f4f91dcf28ce70146fc5186
7
- data.tar.gz: a80337c4eac6e8bdf16b39c97fa81b4d75b726bb3cbcc996ff7e3c6103d50a7f433fe3a7601cb8a47bb2edec506c8b124621692c7b8acfe28114bd97f959eb46
6
+ metadata.gz: 9ae2d5e6bcad971ee900bcae76a0caa3bb4228b78517b80cc9373fc8417280629bd9bb661ad771c4f6ac8e2d5746f58a33ecdbeb0e4af278b813a99edffee129
7
+ data.tar.gz: 5b49479ca1e65765fbfa566367ae06b66f3eaf38d6d213b1ecc0e41248e789573e07454833a44f55185a789a580939ae7de1595a798a2b5635c744b5b6a222b9
data/bin/psa CHANGED
@@ -35,6 +35,7 @@ PS_POOL_MGMT = ENV['PS_POOL_MGMT'] || "on"
35
35
  PS_HEALTH_FILE = ENV['PS_HEALTH_FILE'] || "health.html"
36
36
  PS_HEALTH_TIME = ENV['PS_HEALTH_TIME'] || "60"
37
37
  PS_PSA_SUDO = ENV['PS_PSA_SUDO'] || "on"
38
+ PS_PSADMIN_PATH = "#{OS_CONST}" == "linux" ? "#{env('PS_HOME')}/bin" : "#{env('PS_HOME')}/appserv"
38
39
 
39
40
  # process
40
41
  commands.each do |c|
data/lib/psadmin_plus.rb CHANGED
@@ -48,25 +48,29 @@ def do_is_runtime_user_win
48
48
  result = ENV['USERNAME'] == PS_RUNTIME_USER ? true : false
49
49
  end
50
50
 
51
- def do_cmd(cmd)
51
+ def env(var)
52
+ result = "#{OS_CONST}" == "linux" ? "${#{var}}" : "$env:#{var}"
53
+ end
54
+
55
+ def do_cmd(cmd, print = true)
52
56
  case "#{OS_CONST}"
53
57
  when "linux"
54
58
  if do_is_runtime_user_nix
55
59
  out = `#{cmd}`
56
60
  else
57
61
  if "#{PS_PSA_SUDO}" == "on"
58
- out = `sudo su - #{PS_RUNTIME_USER} -c "#{cmd}"`
62
+ out = `sudo su - #{PS_RUNTIME_USER} -c '#{cmd}'`
59
63
  else
60
64
  print "#{PS_RUNTIME_USER} "
61
- out = `su - #{PS_RUNTIME_USER} -c "#{cmd}"`
65
+ out = `su - #{PS_RUNTIME_USER} -c '#{cmd}'`
62
66
  end
63
67
  end
64
68
  when "windows"
65
- out = `"#{cmd}"`
69
+ out = `powershell -command "#{cmd}"`
66
70
  else
67
71
  out = "Invalid OS"
68
72
  end
69
- puts out
73
+ print ? (puts out) : result = out
70
74
  end
71
75
 
72
76
  def do_cmd_banner(c,t,d)
@@ -74,30 +78,57 @@ def do_cmd_banner(c,t,d)
74
78
  puts "### #{c} - #{t} - #{d} ###"
75
79
  end
76
80
 
77
- def find_apps
78
- apps = Dir.glob("#{ENV['PS_CFG_HOME']}/appserv/*/psappsrv.ubx")
81
+ def find_apps_nix
82
+ apps = do_cmd("find #{env('PS_CFG_HOME')}/appserv/*/psappsrv.ubx",false).split(/\n+/)
79
83
  apps.map! {|app| app.split("/")[-2]}
80
84
  end
81
85
 
82
- def find_prcss
83
- prcss = Dir.glob("#{ENV['PS_CFG_HOME']}/appserv/prcs/*/psprcsrv.ubx")
86
+ def find_prcss_nix
87
+ prcss = do_cmd("find #{env('PS_CFG_HOME')}/appserv/prcs/*/psprcsrv.ubx",false).split(/\n+/)
84
88
  prcss.map! {|prcs| prcs.split("/")[-2]}
85
89
  end
86
90
 
87
- def find_webs
88
- webs = Dir.glob("#{ENV['PS_CFG_HOME']}/webserv/*/piaconfig")
91
+ def find_webs_nix
92
+ webs = do_cmd("find #{env('PS_CFG_HOME')}/webserv/*/piaconfig -maxdepth 0",false).split(/\n+/)
89
93
  webs.map! {|web| web.split("/")[-2]}
90
94
  end
91
95
 
96
+ def find_apps_win
97
+ apps = do_cmd("get-childitem #{env('PS_CFG_HOME')}/appserv/*/psappsrv.ubx | select fullname | Format-Table -HideTableHeaders",false).split(/\n+/)
98
+ apps.map! {|app| app.split('\\')[-2]}
99
+ end
100
+
101
+ def find_prcss_win
102
+ prcss = do_cmd("get-childitem #{env('PS_CFG_HOME')}/appserv/prcs/*/psprcsrv.ubx | select fullname | Format-Table -HideTableHeaders",false).split(/\n+/)
103
+ prcss.map! {|prcs| prcs.split("\\")[-2]}
104
+ end
105
+
106
+ def find_webs_win
107
+ webs = do_cmd("get-childitem #{env('PS_CFG_HOME')}/webserv/*/piaconfig | select fullname | Format-Table -HideTableHeaders",false).split(/\n+/)
108
+ webs.map! {|web| web.split("\\")[-2]}
109
+ end
110
+
111
+ def find_apps
112
+ apps = "#{OS_CONST}" == "linux" ? find_apps_nix : find_apps_win
113
+ end
114
+
115
+ def find_prcss
116
+ prcss = "#{OS_CONST}" == "linux" ? find_prcss_nix : find_prcss_win
117
+ end
118
+
119
+ def find_webs
120
+ webs = "#{OS_CONST}" == "linux" ? find_webs_nix : find_webs_win
121
+ end
122
+
92
123
  def do_util
93
124
  puts "TODO: util"
94
125
  end
95
126
 
96
127
  def do_list
97
128
  puts "---"
98
- # puts "hostname: TODO"
99
- puts "ps-home: #{ENV['PS_HOME']}"
100
- puts "ps-cfg-home: #{ENV['PS_CFG_HOME']}"
129
+ print "hostname: " ; do_cmd('hostname')
130
+ print "ps-home: " ; do_cmd('echo ' + env('PS_HOME'))
131
+ print "ps-cfg-home: " ; do_cmd('echo ' + env('PS_CFG_HOME'))
101
132
  puts ""
102
133
  puts "PS_RUNTIME_USER: #{PS_RUNTIME_USER}"
103
134
  puts "PS_PSA_SUDO: #{PS_PSA_SUDO}"
@@ -130,14 +161,14 @@ end
130
161
  def do_status(type, domain)
131
162
  case type
132
163
  when "app"
133
- do_cmd("psadmin -c sstatus -d #{domain}")
134
- do_cmd("psadmin -c cstatus -d #{domain}")
135
- do_cmd("psadmin -c qstatus -d #{domain}")
136
- do_cmd("psadmin -c pslist -d #{domain}")
164
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c sstatus -d #{domain}")
165
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c cstatus -d #{domain}")
166
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c qstatus -d #{domain}")
167
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c pslist -d #{domain}")
137
168
  when "prcs"
138
- do_cmd("#{ENV['PS_HOME']}/bin/psadmin -p status -d #{domain}")
169
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -p status -d #{domain}")
139
170
  when "web"
140
- do_cmd("psadmin -w status -d #{domain}")
171
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -w status -d #{domain}")
141
172
  else
142
173
  puts "Invalid type, see psa help"
143
174
  end
@@ -146,12 +177,11 @@ end
146
177
  def do_start(type, domain)
147
178
  case type
148
179
  when "app"
149
- do_cmd("psadmin -c boot -d #{domain}")
180
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c boot -d #{domain}")
150
181
  when "prcs"
151
- do_cmd("psadmin -p start -d #{domain}")
182
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -p start -d #{domain}")
152
183
  when "web"
153
- do_cmd("${PS_CFG_HOME?}/webserv/#{domain}/bin/startPIA.sh")
154
- #psadmin -w start -d #{domain}") # TODO - this isn't working, do we want it?
184
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -w start -d #{domain}")
155
185
  else
156
186
  puts "Invalid type, see psa help"
157
187
  end
@@ -160,11 +190,11 @@ end
160
190
  def do_stop(type, domain)
161
191
  case type
162
192
  when "app"
163
- do_cmd("psadmin -c shutdown -d #{domain}")
193
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c shutdown -d #{domain}")
164
194
  when "prcs"
165
- do_cmd("psadmin -p stop -d #{domain}")
195
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -p stop -d #{domain}")
166
196
  when "web"
167
- do_cmd("${PS_CFG_HOME?}/webserv/#{domain}/bin/stopPIA.sh")
197
+ do_cmd("#{env('PS_CFG_HOME')}/webserv/#{domain}/bin/stopPIA.sh")
168
198
  else
169
199
  puts "Invalid type, see psa help"
170
200
  end
@@ -173,9 +203,9 @@ end
173
203
  def do_kill(type, domain)
174
204
  case type
175
205
  when "app"
176
- do_cmd("psadmin -c shutdown! -d #{domain}")
206
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c shutdown! -d #{domain}")
177
207
  when "prcs"
178
- do_cmd("psadmin -p kill -d #{domain}")
208
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -p kill -d #{domain}")
179
209
  when "web"
180
210
  return # web kill n/a
181
211
  else
@@ -186,9 +216,9 @@ end
186
216
  def do_configure(type, domain)
187
217
  case type
188
218
  when "app"
189
- do_cmd("psadmin -c configure -d #{domain}")
219
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c configure -d #{domain}")
190
220
  when "prcs"
191
- do_cmd("psadmin -p configure -d #{domain}")
221
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -p configure -d #{domain}")
192
222
  when "web"
193
223
  return # web configure n/a
194
224
  else
@@ -199,11 +229,11 @@ end
199
229
  def do_purge(type, domain)
200
230
  case type
201
231
  when "app"
202
- do_cmd("psadmin -c purge -d #{domain}")
232
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c purge -d #{domain}")
203
233
  when "prcs"
204
234
  do_cmd("echo purge todo")
205
235
  when "web"
206
- do_cmd("rm -rf ${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL*/*/cache*/")
236
+ do_cmd("rm -rf #{env('PS_CFG_HOME')}/webserv/#{domain}/applications/peoplesoft/PORTAL*/*/cache*/")
207
237
  puts "web cache purged"
208
238
  else
209
239
  puts "Invalid type, see psa help"
@@ -213,9 +243,9 @@ end
213
243
  def do_flush(type, domain)
214
244
  case type
215
245
  when "app"
216
- do_cmd("psadmin -c cleanipc -d #{domain}")
246
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -c cleanipc -d #{domain}")
217
247
  when "prcs"
218
- do_cmd("psadmin -p cleanipc -d #{domain}")
248
+ do_cmd("#{PS_PSADMIN_PATH}/psadmin -p cleanipc -d #{domain}")
219
249
  when "web"
220
250
  return # web flush n/a
221
251
  else
@@ -240,12 +270,12 @@ def do_pooladd(type, domain)
240
270
  if PS_POOL_MGMT == "on" then
241
271
  # Change this function to match your pool member addtion process
242
272
  puts "Adding web domain to load balanced pool..."
243
- do_cmd("echo 'true' > ${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/${PS_HEALTH_FILE?}")
273
+ do_cmd("echo 'true' > #{env('PS_CFG_HOME')}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/#{ENV['PS_HEALTH_FILE']}")
244
274
  sleep(PS_HEALTH_TIME.to_i)
245
275
  puts "...domain added to pool."
246
276
  puts ""
247
277
  else
248
- puts "Skipping pool managment. To enable, set $PS_POOL_MGMT to 'on'."
278
+ puts "Skipping pool managment. To enable, set PS_POOL_MGMT to 'on'."
249
279
  end
250
280
  end
251
281
 
@@ -253,12 +283,12 @@ def do_poolrm(type,domain)
253
283
  if PS_POOL_MGMT == "on" then
254
284
  # Change this function to match your pool member removal process
255
285
  puts "Removing domain from load balanced pool..."
256
- do_cmd("rm -f \${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/${PS_HEALTH_FILE?}")
286
+ do_cmd("rm -f #{env('PS_CFG_HOME')}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/#{ENV['PS_HEALTH_FILE']}")
257
287
  sleep(PS_HEALTH_TIME.to_i)
258
288
  puts "...domain removed from pool."
259
289
  puts ""
260
290
  else
261
- puts "Skipping pool managment. To enable, set $PS_POOL_MGMT to 'on'."
291
+ puts "Skipping pool managment. To enable, set PS_POOL_MGMT to 'on'."
262
292
  end
263
293
  end
264
294
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psadmin_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Benson