Commit 909aa5bf5feb7156f6fcb18639782f59237b5dd5

Authored by Prince Mbekwa
2 parents 636b6352 743ed073

Merge branch 'edge' of github.com:ktgit/knowledgetree into edge

dmsctl.vbs
... ... @@ -36,13 +36,17 @@ Const SVC_INVALID_SERVICES_ACCOUNT = 22 ' Status Invalid Service Account
36 36 Const SVC_STATUS_SERVICE_EXISTS = 23 ' Status Service Exists
37 37 Const SVC_SERVICE_ALREADY_PAUSED = 24 ' Service Already Paused
38 38  
39   -'Detecting current OS
40   -Dim strComputer, currOS, doRunAs
  39 +Dim strComputer, currOS, currDir, doRunAs, lastErrorCode
  40 +
  41 +' Detecting the current directory
  42 +Set oFso = CreateObject("Scripting.FileSystemObject")
  43 +currDir = oFso.GetParentFolderName(Wscript.ScriptFullName)
41 44  
42 45 strComputer = "."
43 46 currOS = ""
44 47 doRunAs = false
45 48  
  49 +' Detecting the current OS
46 50 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
47 51 Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
48 52  
... ... @@ -52,28 +56,28 @@ For Each objOperatingSystem in colOperatingSystems
52 56 Next
53 57  
54 58 Public Function isWindowsVista()
55   - isWindows7 = false
  59 + isWin = false
56 60 If left(currOS, 19) = "Microsoft Windows Vista" Then
57   - isWindows7 = true
  61 + isWin = TRUE
58 62 End If
59 63 End Function
60 64  
61 65 Public Function isWindows7()
62   - isWindows7 = false
  66 + isWin = false
63 67 If left(currOS, 19) = "Microsoft Windows 7" Then
64   - isWindows7 = true
  68 + isWin = TRUE
65 69 End If
66 70 End Function
67 71  
68 72 Public Function isWindows2008()
69   - isWindows7 = false
  73 + isWin = false
70 74 If left(currOS, 19) = "Microsoft Windows 2008" Then
71   - isWindows7 = true
  75 + isWin = TRUE
72 76 End If
73 77 End Function
74 78  
75 79 ' Will call this further down when the individual services need starting
76   -If doRunAs = true Then
  80 +If doRunAs = TRUE Then
77 81 'runAs "C:\Program Files (x86)\Zend\ktdms\knowledgetree", "dmsctl_install.bat"
78 82 End If
79 83  
... ... @@ -100,38 +104,44 @@ vbNewLine &_
100 104 " only mysql is supported for individual control at this time."
101 105  
102 106 Set objArgs = WScript.Arguments
103   -If objArgs.count < 1 Then
  107 +If (objArgs.count < 1) Then
104 108 Wscript.Echo strUsage
105 109 Else
106 110 Select Case objArgs.Item(0)
107 111 Case "install"
108   - isSuccess = true ' Track if anything went wrong
  112 + isSuccess = TRUE ' Track if anything went wrong
109 113  
110 114 ' Installing KTOffice
111   - result = exec("C:\Program Files\Zend\ktdms\knowledgetree\var\bin\officeinstall.bat")
  115 + result = exec(currDir & "\var\bin\officeinstall.bat")
112 116  
113 117 'Install Failed
114 118 If result = 0 Then
115 119 isSuccess = false
116   - logEvent "The KnowledgeTree KTOffice service could not be installed"
  120 + writeLog "The " & KTOFFICE & " KnowledgeTree service could not be installed."
  121 + Else
  122 + writeLog "The " & KTOFFICE & " KnowledgeTree service was successfully installed."
117 123 End If
118 124  
119 125 ' Installing KTScheduler
120   - result = exec("C:\Program Files\Zend\ktdms\knowledgetree\var\bin\schedulerinstall.bat")
  126 + result = exec(currDir & "\var\bin\schedulerinstall.bat")
121 127  
122 128 'Install Failed
123 129 If result = 0 Then
124 130 isSuccess = false
125   - logEvent "The KnowledgeTree KTScheduler service could not be installed"
  131 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service could not be installed."
  132 + Else
  133 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service was successfully installed."
126 134 End If
127 135  
128 136 ' Installing KTLucene
129   - result = exec("C:\Program Files\Zend\ktdms\knowledgetree\var\bin\luceneinstall.bat")
  137 + result = exec(currDir & "\var\bin\luceneinstall.bat")
130 138  
131 139 'Install Failed
132 140 If result = 0 Then
133 141 isSuccess = false
134   - logEvent "The KnowledgeTree KTLucene service could not be installed"
  142 + writeLog "The " & KTLUCENE & " KnowledgeTree service could not be installed."
  143 + Else
  144 + writeLog "The " & KTLUCENE & " KnowledgeTree service was successfully installed."
135 145 End If
136 146  
137 147 If (isSuccess) Then
... ... @@ -141,69 +151,254 @@ Else
141 151 End If
142 152  
143 153 Case "start"
144   - isSuccess = true
145   -
146   - svcName = KTOFFICE
147   - If (NOT isServiceStarted(svcName)) Then
148   - If (NOT startService(svcName)) Then
149   - isSuccess = false
  154 + If (objArgs.count > 1) Then
  155 + Select Case objArgs.Item(1)
  156 + Case "soffice"
  157 + isSuccess = TRUE
  158 + svcName = KTOFFICE
  159 + If (NOT isServiceStarted(svcName)) Then
  160 + If (NOT startService(svcName)) Then
  161 + isSuccess = FALSE
  162 + writeLog "The " & KTOFFICE & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  163 + Else
  164 + writeLog "The " & KTOFFICE & " KnowledgeTree service was successfully started"
  165 + End If
  166 +
  167 + writeLog "Successfully started " & KTOFFICE
  168 + Else
  169 + writeLog KTOFFICE & " already started. Result Code: " & lastErrorCode
  170 + End If
  171 +
  172 + If (isSuccess) Then
  173 + Wscript.Echo "The " & KTOFFICE & " KnowledgeTree service was successfully started"
  174 + Else
  175 + Wscript.Echo "The " & KTOFFICE & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  176 + End If
  177 +
  178 + Case "scheduler"
  179 + isSuccess = TRUE
  180 + svcName = KTSCHEDULER
  181 + If (NOT isServiceStarted(svcName)) Then
  182 + If (NOT startService(svcName)) Then
  183 + isSuccess = FALSE
  184 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  185 + Else
  186 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service was successfully started"
  187 + End If
  188 +
  189 + writeLog "Successfully started " & KTSCHEDULER
  190 + Else
  191 + writeLog KTSCHEDULER & " already started. Result Code: " & lastErrorCode
  192 + End If
  193 +
  194 + If (isSuccess) Then
  195 + Wscript.Echo "The " & KTSCHEDULER & " KnowledgeTree service was successfully started"
  196 + Else
  197 + Wscript.Echo "The " & KTSCHEDULER & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  198 + End If
  199 +
  200 + Case "lucene"
  201 + isSuccess = TRUE
  202 + svcName = KTLUCENE
  203 + If (NOT isServiceStarted(svcName)) Then
  204 + If (NOT startService(svcName)) Then
  205 + isSuccess = false
  206 + writeLog "The " & KTLUCENE & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  207 + Else
  208 + writeLog "The " & KTLUCENE & " KnowledgeTree service was successfully started"
  209 + End If
  210 +
  211 + writeLog "Successfully started " & KTLUCENE
  212 + Else
  213 + writeLog KTLUCENE & " already started. Result Code: " & lastErrorCode
  214 + End If
  215 +
  216 + If (isSuccess) Then
  217 + Wscript.Echo "The " & KTLUCENE & " KnowledgeTree service was successfully started"
  218 + Else
  219 + Wscript.Echo "The " & KTLUCENE & " KnowledgeTree service could not be started. Result Code: " & lastErrorCode
  220 + End If
  221 + End Select
  222 + Else
  223 + isSuccess = TRUE
  224 +
  225 + svcName = KTOFFICE
  226 + If (NOT isServiceStarted(svcName)) Then
  227 + If (NOT startService(svcName)) Then
  228 + isSuccess = false
  229 + End If
  230 + writeLog "Successfully started " & KTOFFICE
  231 + Else
  232 + writeLog KTOFFICE & " already started. Result Code: " & lastErrorCode
150 233 End If
151   - End If
152 234  
153   - svcName = KTSCHEDULER
154   - If (NOT isServiceStarted(svcName)) Then
155   - If (NOT startService(svcName)) Then
156   - isSuccess = false
  235 + svcName = KTSCHEDULER
  236 + If (NOT isServiceStarted(svcName)) Then
  237 + If (NOT startService(svcName)) Then
  238 + isSuccess = false
  239 + End If
  240 + writeLog "Successfully started " & KTSCHEDULER
  241 + Else
  242 + writeLog KTSCHEDULER & " already started. Result Code: " & lastErrorCode
157 243 End If
158   - End If
159 244  
160   - svcName = KTLUCENE
161   - If (NOT isServiceStarted(svcName)) Then
162   - If (NOT startService(svcName)) Then
163   - isSuccess = false
  245 + svcName = KTLUCENE
  246 + If (NOT isServiceStarted(svcName)) Then
  247 + If (NOT startService(svcName)) Then
  248 + isSuccess = false
  249 + End If
  250 + writeLog "Successfully started " & KTLUCENE
  251 + Else
  252 + writeLog KTLUCENE & " already started. Result Code: " & lastErrorCode
164 253 End If
165   - End If
166 254  
167   - If (isSuccess) Then
168   - Wscript.Echo "The KnowledgeTree services were successfully started"
169   - Else
170   - Wscript.Echo "There were errors starting the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  255 + If (isSuccess) Then
  256 + Wscript.Echo "The KnowledgeTree services were successfully started"
  257 + Else
  258 + Wscript.Echo "There were errors starting the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  259 + End If
171 260 End If
172   -
173 261 Case "stop"
174   - isSuccess = true
  262 + If (objArgs.count > 1) Then
  263 + Select Case objArgs.Item(1)
  264 + Case "soffice"
  265 + isSuccess = TRUE
  266 + svcName = KTOFFICE
  267 + If (isServiceStarted(svcName)) Then
  268 + If (NOT stopService(svcName)) Then
  269 + isSuccess = false
  270 + writeLog "The " & KTOFFICE & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  271 + Else
  272 + writeLog "The " & KTOFFICE & " KnowledgeTree service was successfully stopped"
  273 + End If
  274 +
  275 + writeLog "Successfully stopped " & KTOFFICE
  276 + Else
  277 + writeLog KTOFFICE & " already stopped. Result Code: " & lastErrorCode
  278 + End If
  279 +
  280 + If (isSuccess) Then
  281 + Wscript.Echo "The " & KTOFFICE & " KnowledgeTree service was successfully stopped"
  282 + Else
  283 + Wscript.Echo "The " & KTOFFICE & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  284 + End If
  285 +
  286 + Case "scheduler"
  287 + isSuccess = TRUE
  288 + svcName = KTSCHEDULER
  289 + If (isServiceStarted(svcName)) Then
  290 + If (NOT stopService(svcName)) Then
  291 + isSuccess = false
  292 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  293 + Else
  294 + writeLog "The " & KTSCHEDULER & " KnowledgeTree service was successfully stopped"
  295 + End If
  296 +
  297 + writeLog "Successfully stopped " & KTSCHEDULER
  298 + Else
  299 + writeLog KTSCHEDULER & " already stopped. Result Code: " & lastErrorCode
  300 + End If
  301 +
  302 + If (isSuccess) Then
  303 + Wscript.Echo "The " & KTSCHEDULER & " KnowledgeTree service was successfully stopped"
  304 + Else
  305 + Wscript.Echo "The " & KTSCHEDULER & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  306 + End If
  307 +
  308 + Case "lucene"
  309 + isSuccess = TRUE
  310 + svcName = KTLUCENE
  311 + If (isServiceStarted(svcName)) Then
  312 + If (NOT stopService(svcName)) Then
  313 + isSuccess = false
  314 + writeLog "The " & KTLUCENE & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  315 + Else
  316 + writeLog "The " & KTLUCENE & " KnowledgeTree service was successfully stopped"
  317 + End If
  318 +
  319 + writeLog "Successfully stopped " & KTLUCENE
  320 + Else
  321 + writeLog KTLUCENE & " already stopped. Result Code: " & lastErrorCode
  322 + End If
  323 +
  324 + If (isSuccess) Then
  325 + Wscript.Echo "The " & KTLUCENE & " KnowledgeTree service was successfully stopped"
  326 + Else
  327 + Wscript.Echo "The " & KTLUCENE & " KnowledgeTree service could not be stopped. Result Code: " & lastErrorCode
  328 + End If
  329 + End Select
  330 + Else
  331 + 'Stopping all the services
  332 + isSuccess = TRUE
  333 +
  334 + svcName = KTOFFICE
  335 + If (isServiceStarted(svcName)) Then
  336 + If (NOT stopService(svcName)) Then
  337 + isSuccess = false
  338 + End If
  339 + writeLog "Successfully stopped " & KTOFFICE
  340 + Else
  341 + writeLog KTOFFICE & " already stopped. Result Code: " & lastErrorCode
  342 + End If
  343 +
  344 + svcName = KTSCHEDULER
  345 + If (isServiceStarted(svcName)) Then
  346 + If (NOT stopService(svcName)) Then
  347 + isSuccess = false
  348 + End If
  349 + writeLog "Successfully stopped " & KTSCHEDULER
  350 + Else
  351 + writeLog KTSCHEDULER & " already stopped. Result Code: " & lastErrorCode
  352 + End If
  353 +
  354 + svcName = KTLUCENE
  355 + If (isServiceStarted(svcName)) Then
  356 + If (NOT stopService(svcName)) Then
  357 + isSuccess = false
  358 + End If
  359 + writeLog "Successfully stopped " & KTLUCENE
  360 + Else
  361 + writeLog KTLUCENE & " already stopped. Result Code: " & lastErrorCode
  362 + End If
  363 +
  364 + If (isSuccess) Then
  365 + Wscript.Echo "The KnowledgeTree services were successfully stopped"
  366 + Else
  367 + Wscript.Echo "There were errors sopping the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  368 + End If
  369 + End If
  370 +
  371 + Case "uninstall"
  372 + isSuccess = TRUE
175 373  
176 374 svcName = KTOFFICE
177   - If (isServiceStarted(svcName)) Then
178   - If (NOT stopService(svcName)) Then
179   - isSuccess = false
180   - End If
  375 + If (NOT uninstallService(svcName)) Then
  376 + isSuccess = false
  377 + writeLog "The KnowledgeTree KTOffice service could not be uninstalled"
181 378 End If
182 379  
183 380 svcName = KTSCHEDULER
184   - If (isServiceStarted(svcName)) Then
185   - If (NOT stopService(svcName)) Then
186   - isSuccess = false
187   - End If
  381 + If (NOT uninstallService(svcName)) Then
  382 + isSuccess = false
  383 + writeLog "The KnowledgeTree KTScheduler service could not be uninstalled"
188 384 End If
189 385  
190 386 svcName = KTLUCENE
191   - If (isServiceStarted(svcName)) Then
192   - If (NOT stopService(svcName)) Then
193   - isSuccess = false
194   - End If
  387 + If (NOT uninstallService(svcName)) Then
  388 + isSuccess = false
  389 + writeLog "The KnowledgeTree KTLucene service could not be uninstalled"
195 390 End If
196 391  
197 392 If (isSuccess) Then
198   - Wscript.Echo "The KnowledgeTree services were successfully stopped"
  393 + Wscript.Echo "The KnowledgeTree services were uninstalled"
199 394 Else
200   - Wscript.Echo "There were errors sopping the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
  395 + Wscript.Echo "There were errors uninstalling the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
201 396 End If
202 397  
203   - Case "uninstall"
204   - isSuccess = true ' Track if anything went wrong
  398 + Case "uninstall_old" 'Depricated : This method prevents verbose error logging, using WMI to uninstall instead
  399 + isSuccess = TRUE ' Track if anything went wrong
205 400  
206   - ' Stopping Then Uninstalling
  401 + ' Stopping Then FALSE
207 402 'svcName = KTOFFICE
208 403 'If (isServiceStarted(svcName)) Then
209 404 ' If (NOT stopService(svcName)) Then
... ... @@ -211,16 +406,16 @@ Else
211 406 ' End If
212 407 'End If
213 408  
214   - ' Uninstalling KTOffice
  409 + ' FALSE KTOffice
215 410 result = exec("sc delete " & KTOFFICE)
216 411  
217 412 'Uninstall Failed
218 413 If result = 0 Then
219 414 isSuccess = false
220   - logEvent "The KnowledgeTree KTOffice service could not be uninstalled"
  415 + writeLog "The KnowledgeTree KTOffice service could not be uninstalled"
221 416 End If
222 417  
223   - ' Stopping Then Uninstalling
  418 + ' Stopping Then FALSE
224 419 'svcName = KTSCHEDULER
225 420 'If (isServiceStarted(svcName)) Then
226 421 ' If (NOT stopService(svcName)) Then
... ... @@ -228,32 +423,30 @@ Else
228 423 ' End If
229 424 'End If
230 425  
231   - ' Uninstalling KTScheduler
  426 + ' FALSE KTScheduler
232 427 result = exec("sc delete " & KTSCHEDULER)
233 428  
234 429 'Uninstall Failed
235 430 If result = 0 Then
236 431 isSuccess = false
237   - logEvent "The KnowledgeTree KTScheduler service could not be uninstalled"
  432 + writeLog "The KnowledgeTree KTScheduler service could not be uninstalled"
238 433 End If
239   -
240   -
241 434  
242   - ' Stopping Then Uninstalling
  435 + ' Stopping Then FALSE
243 436 'svcName = KTLUCENE
244 437 'If (isServiceStarted(svcName)) Then
245 438 ' If (NOT stopService(svcName)) Then
246   - ' isSuccess = false
  439 + ' isSuccess = FALSE
247 440 ' End If
248 441 'End If
249 442  
250   - ' Uninstalling KTLucene
  443 + ' FALSE KTLucene
251 444 result = exec("sc delete " & KTLUCENE)
252 445  
253 446 'Uninstall Failed
254 447 If result = 0 Then
255   - isSuccess = false
256   - logEvent "The KnowledgeTree KTLucene service could not be uninstalled"
  448 + isSuccess = FALSE
  449 + writeLog "The KnowledgeTree KTLucene service could not be uninstalled"
257 450 End If
258 451  
259 452 If (isSuccess) Then
... ... @@ -261,21 +454,56 @@ Else
261 454 Else
262 455 Wscript.Echo "There were errors uninstalling the KnowledgeTree services please see the log for details ('knowledgetree/var/log/dmsctl.log')"
263 456 End If
  457 +
264 458  
265 459 Case Else
266 460 Wscript.Echo strUsage
267 461 End Select
268 462  
269 463 End If
  464 +
  465 +' Method to check if a service is installed
  466 +Public Function isServiceInstalled(ByVal svcName)
  467 + strComputer = "."
  468 + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  469 +
  470 + ' Obtain an instance of the the class
  471 + ' using a key property value.
  472 +
  473 + isServiceInstalled = FALSE
  474 +
  475 + svcQry = "SELECT * from Win32_Service"
  476 + Set objOutParams = objWMIService.ExecQuery(svcQry)
  477 +
  478 + For Each objSvc in objOutParams
  479 +
  480 + Select Case objSvc.Name
  481 + Case svcName
  482 + isServiceInstalled = TRUE
  483 + End Select
  484 +
  485 + Next
  486 +
  487 + If (Not isServiceInstalled) Then
  488 + lastErrorCode = SVC_INVALID_NAME
  489 + End If
270 490  
  491 +End Function
  492 +
271 493 ' Method to interrogate a service
272 494 Public Function isServiceStarted(ByVal svcName)
  495 + If (NOT isServiceInstalled( svcName )) Then
  496 + isServiceStarted = FALSE
  497 + Exit Function
  498 + End If
  499 +
273 500 strComputer = "."
274 501 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  502 +
275 503 ' Obtain an instance of the the class
276 504 ' using a key property value.
277 505 Set objShare = objWMIService.Get("Win32_Service.Name='" & svcName & "'")
278   -
  506 +
279 507 ' no InParameters to define
280 508  
281 509 ' Execute the method and obtain the return status.
... ... @@ -283,16 +511,24 @@ Public Function isServiceStarted(ByVal svcName)
283 511 ' is created by the provider.
284 512 Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='" & svcName & "'", "InterrogateService")
285 513  
  514 + lastErrorCode = objOutParams.ReturnValue
  515 +
286 516 If (objOutParams.ReturnValue = SVC_SERVICE_NOT_ACTIVE) Then
287 517 isServiceStarted = FALSE
288 518 Else
289 519 isServiceStarted = TRUE
290 520 End If
291   -
  521 +
292 522 end Function
293 523  
294 524 ' Method to start a service
295 525 Public Function startService(ByVal svcName)
  526 + If (NOT isServiceInstalled( svcName )) Then
  527 + writeLog "The KnowledgeTree " & svcName & " service could not be started because it isn't installed. Run 'dmsctl.vbs install' to correct."
  528 + startService = FALSE
  529 + Exit Function
  530 + End If
  531 +
296 532 strComputer = "."
297 533 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
298 534 ' Obtain an instance of the the class
... ... @@ -306,6 +542,8 @@ Public Function startService(ByVal svcName)
306 542 ' is created by the provider.
307 543 Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='" & svcName & "'", "StartService")
308 544  
  545 + lastErrorCode = objOutParams.ReturnValue
  546 +
309 547 If (objOutParams.ReturnValue = SVC_SUCCESS) Then
310 548 startService = TRUE
311 549 Else
... ... @@ -316,6 +554,12 @@ End Function
316 554  
317 555 ' Method to stop a service
318 556 Public Function stopService(ByVal svcName)
  557 + If (NOT isServiceInstalled( svcName )) Then
  558 + writeLog "The KnowledgeTree " & svcName & " service could not be stopped because it isn't installed. Run 'dmsctl.vbs install' to correct."
  559 + stopService = FALSE
  560 + Exit Function
  561 + End If
  562 +
319 563 strComputer = "."
320 564 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
321 565 ' Obtain an instance of the the class
... ... @@ -328,6 +572,8 @@ Public Function stopService(ByVal svcName)
328 572 ' The OutParameters object in objOutParams
329 573 ' is created by the provider.
330 574 Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='" & svcName & "'", "StopService")
  575 +
  576 + lastErrorCode = objOutParams.ReturnValue
331 577  
332 578 If (objOutParams.ReturnValue = SVC_SUCCESS) Then
333 579 stopService = TRUE
... ... @@ -337,6 +583,49 @@ Public Function stopService(ByVal svcName)
337 583  
338 584 End Function
339 585  
  586 +' Method to uninstall a service
  587 +Public Function uninstallService(ByVal svcName)
  588 + If (NOT isServiceInstalled( svcName )) Then
  589 + uninstallService = TRUE ' Service already uninstalled so return TRUE
  590 + Exit Function
  591 + End If
  592 +
  593 + wasStopped = TRUE
  594 + If (NOT stopService(svcName)) Then
  595 + wasStopped = FALSE
  596 + End If
  597 +
  598 + strComputer = "."
  599 + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  600 + ' Obtain an instance of the the class
  601 + ' using a key property value.
  602 + Set objShare = objWMIService.Get("Win32_Service.Name='" & svcName & "'")
  603 +
  604 + ' no InParameters to define
  605 +
  606 + ' Execute the method and obtain the return status.
  607 + ' The OutParameters object in objOutParams
  608 + ' is created by the provider.
  609 + Set objOutParams = objWMIService.ExecMethod("Win32_Service.Name='" & svcName & "'", "Delete")
  610 +
  611 + lastErrorCode = objOutParams.ReturnValue
  612 +
  613 + If (objOutParams.ReturnValue = SVC_SUCCESS) Then
  614 + uninstallService = TRUE
  615 + Else
  616 + uninstallService = FALSE
  617 +
  618 + ' Extra Event logging to assist the Administrator
  619 + If (wasStopped) Then
  620 + writeLog "The KnowledgeTree " & svcName & " service could not be uninstalled because it could not be stopped. Stop this service manually before uninstalling."
  621 + uninstallService = FALSE ' Must be stop service before it can be uninstalled
  622 + End If
  623 +
  624 + End If
  625 +
  626 +End Function
  627 +
  628 +
340 629 ' Execute a command
341 630 Public Function exec(ByVal cmd)
342 631  
... ... @@ -363,7 +652,7 @@ End Sub
363 652  
364 653 ' Event logging only works on Server 2003, 2000 and XP
365 654 Public Sub logEvent(ByVal strMessage)
366   -
  655 +
367 656 If (NOT isWindowsVista() AND NOT isWindows7 AND NOT isWindows2008) Then
368 657 Const EVENT_SUCCESS = 0
369 658 Set objShell = Wscript.CreateObject("Wscript.Shell")
... ... @@ -371,3 +660,13 @@ Public Sub logEvent(ByVal strMessage)
371 660 End If
372 661  
373 662 End Sub
  663 +
  664 +' Event logging only works on Server 2003, 2000 and XP
  665 +Public Sub writeLog(ByVal strMessage)
  666 + Set objFSO = CreateObject("Scripting.FileSystemObject")
  667 + ForAppending = 8
  668 + Set objTextFile = objFSO.OpenTextFile (currDir & "\var\log\dmsctl.log", ForAppending, True)
  669 + objTextFile.WriteLine strMessage
  670 + objTextFile.Close
  671 +End Sub
  672 +
... ...
setup/wizard/lib/services/unixScheduler.php
... ... @@ -179,7 +179,7 @@ class unixScheduler extends unixService {
179 179 function start() {
180 180 // TODO : Write sh on the fly? Not sure the reasoning here
181 181 $source = $this->getSchedulerSourceLoc();
182   - $this->writeSchedulerTask();
  182 +// $this->writeSchedulerTask();
183 183 $logFile = "/dev/null";
184 184 // @unlink($logFile);
185 185 if($source) { // Source
... ...
setup/wizard/steps/configuration.php
... ... @@ -247,10 +247,12 @@ class configuration extends Step
247 247 public function doRun($edit = false)
248 248 {
249 249 $server = $this->getServerInfo();
250   - if(!$edit) $this->temp_variables['server'] = $server;
  250 + if(!$edit || $this->util->isMigration())
  251 + $this->temp_variables['server'] = $server;
251 252  
252 253 $paths = $this->getPathInfo($server['file_system_root']['value']);
253   - if(!$edit) $this->temp_variables['paths'] = $paths;
  254 + if(!$edit || $this->util->isMigration())
  255 + $this->temp_variables['paths'] = $paths;
254 256  
255 257 // Rewrite file system root
256 258 if(!$this->fpath) {
... ... @@ -432,13 +434,15 @@ class configuration extends Step
432 434 {
433 435 if(isset($this->temp_variables['paths'])) {
434 436 if ($this->util->isMigration()) { // Check if its an upgrade
435   - $this->readInstallation(); // Read values from config.ini of other installation
  437 + $this->readConfigPath(); // Read contents of config-path file as only var Documents are used of old stack
  438 + $this->readInstallation(); // Read values from config.ini of other installation and overwrite config-path's
436 439 $dirs = $this->getFromConfigPath(); // Store contents
437 440 } else {
438 441 $dirs = $this->temp_variables['paths']; // Pull from temp
439 442 }
440 443 } else {
441 444 if ($this->util->isMigration()) { // Check if its an upgrade
  445 + $this->readConfigPath(); // Read contents of config-path file as only var Documents are used of old stack
442 446 $this->readInstallation(); // Read values from config.ini of other installation
443 447 } else {
444 448 $this->readConfigPath(); // Read contents of config-path file
... ... @@ -455,13 +459,13 @@ class configuration extends Step
455 459 }
456 460 if(WINDOWS_OS)
457 461 $path = preg_replace('/\//', '\\',$path);
458   - $dirs[$key]['path'] = $path;
459   - $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows
460   - if(isset($dir['file'])) {
461   - $class = $this->util->checkPermission($path, false, true);
462   - } else {
463   - $class = $this->util->checkPermission($path, $dir['create']);
464   - }
  462 + $dirs[$key]['path'] = $path;
  463 + $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows
  464 + if(isset($dir['file'])) {
  465 + $class = $this->util->checkPermission($path, false, true);
  466 + } else {
  467 + $class = $this->util->checkPermission($path, $dir['create']);
  468 + }
465 469 if(isset($class['msg'])) {
466 470 if($class['class'] != 'tick') {
467 471 $this->temp_variables['paths_perms'] = $class['class'];
... ...
var/bin/schedulerTask.sh
... ... @@ -2,11 +2,11 @@
2 2 PHP_CLI="/usr/local/zend/bin/php"
3 3  
4 4 BIN_DIR=$(dirname $0)
5   -INSTALL_DIR="../../${BIN_DIR}"
  5 +INSTALL_DIR="../..${BIN_DIR}"
6 6  
7 7 cd $INSTALL_DIR/bin
8 8  
9 9 while true; do
10 10 $PHP_CLI -Cq scheduler.php
11 11 sleep 30
12   -done
13 12 \ No newline at end of file
  13 +done
... ...