ci(services): changes to reinclude .exe exclusion
This commit is contained in:
@@ -11,21 +11,21 @@ param (
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Example string to run with the parameters in it.
|
# Example string to run with the parameters in it.
|
||||||
# .C:\scripts\services.ps1 -serviceName "LST_ctl" -option "install" -appPath "E:\LST" -description "Logistics Support Tool controller" -command "E:\LST\controller\lst_ctl.exe"
|
# .\scripts\services.ps1 -serviceName "LST_ctl" -option "install" -appPath "E:\LST" -description "Logistics Support Tool controller" -command "E:\LST\controller\lst_ctl.exe"
|
||||||
# .\scripts\services.ps1 -serviceName "LST_app" -option "install" -appPath "E:\LST" -description "Logistics Support Tool" -command "run start"
|
# .\scripts\services.ps1 -serviceName "LST_app" -option "install" -appPath "E:\LST" -description "Logistics Support Tool" -command "run start"
|
||||||
|
|
||||||
$nssmPath = $AppPath + "\nssm.exe"
|
$nssmPath = $AppPath + "\nssm.exe"
|
||||||
$npmPath = "C:\Program Files\nodejs\npm.cmd" # Path to npm.cmd
|
$npmPath = "C:\Program Files\nodejs\npm.cmd" # Path to npm.cmd
|
||||||
|
|
||||||
if($remote -eq "true"){
|
if ($remote -eq "true") {
|
||||||
# Convert the plain-text password to a SecureString
|
# Convert the plain-text password to a SecureString
|
||||||
$securePass = ConvertTo-SecureString $admpass -AsPlainText -Force
|
$securePass = ConvertTo-SecureString $admpass -AsPlainText -Force
|
||||||
$credentials = New-Object System.Management.Automation.PSCredential($username, $securePass)
|
$credentials = New-Object System.Management.Automation.PSCredential($username, $securePass)
|
||||||
|
|
||||||
# if(-not $username -or -not $admpass){
|
# if(-not $username -or -not $admpass){
|
||||||
# Write-host "Missing adm account info please try again."
|
# Write-host "Missing adm account info please try again."
|
||||||
# exit 1
|
# exit 1
|
||||||
# }
|
# }
|
||||||
|
|
||||||
$plantFunness = {
|
$plantFunness = {
|
||||||
param ($service, $processType, $location)
|
param ($service, $processType, $location)
|
||||||
@@ -37,22 +37,22 @@ if($remote -eq "true"){
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if(-not $service -or -not $processType){
|
if (-not $service -or -not $processType) {
|
||||||
Write-host "The service name or option is missing please enter one of them and try again."
|
Write-host "The service name or option is missing please enter one of them and try again."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($processType -eq "start"){
|
if ($processType -eq "start") {
|
||||||
write-host "Starting $($service)."
|
write-host "Starting $($service)."
|
||||||
Start-Service $service
|
Start-Service $service
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($processType -eq "stop"){
|
if ($processType -eq "stop") {
|
||||||
write-host "Stoping $($service)."
|
write-host "Stoping $($service)."
|
||||||
Stop-Service $service
|
Stop-Service $service
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($processType -eq "restart"){
|
if ($processType -eq "restart") {
|
||||||
write-host "Stoping $($service) to be restarted"
|
write-host "Stoping $($service) to be restarted"
|
||||||
Stop-Service $service
|
Stop-Service $service
|
||||||
Start-Sleep 3 # so we give it enough time to fully stop
|
Start-Sleep 3 # so we give it enough time to fully stop
|
||||||
@@ -60,8 +60,8 @@ if($remote -eq "true"){
|
|||||||
Start-Service $service
|
Start-Service $service
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($processType -eq "prodStop"){
|
if ($processType -eq "prodStop") {
|
||||||
if(-not $location){
|
if (-not $location) {
|
||||||
Write-host "The path to the app is missing please add it in and try again."
|
Write-host "The path to the app is missing please add it in and try again."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -72,8 +72,8 @@ if($remote -eq "true"){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($processType -eq "prodStart"){
|
if ($processType -eq "prodStart") {
|
||||||
if(-not $location){
|
if (-not $location) {
|
||||||
Write-host "The path to the app is missing please add it in and try again."
|
Write-host "The path to the app is missing please add it in and try again."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -87,29 +87,30 @@ if($remote -eq "true"){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Invoke-Command -ComputerName $server -ScriptBlock $plantFunness -ArgumentList $serviceName, $option, $appPath -Credential $credentials
|
Invoke-Command -ComputerName $server -ScriptBlock $plantFunness -ArgumentList $serviceName, $option, $appPath -Credential $credentials
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
||||||
Write-Host "Error: This script must be run as Administrator."
|
Write-Host "Error: This script must be run as Administrator."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if(-not $serviceName -or -not $option){
|
if (-not $serviceName -or -not $option) {
|
||||||
Write-host "The service name or option is missing please enter one of them and try again."
|
Write-host "The service name or option is missing please enter one of them and try again."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($option -eq "start"){
|
if ($option -eq "start") {
|
||||||
write-host "Starting $($serviceName)."
|
write-host "Starting $($serviceName)."
|
||||||
Start-Service $serviceName
|
Start-Service $serviceName
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($option -eq "stop"){
|
if ($option -eq "stop") {
|
||||||
write-host "Stoping $($serviceName)."
|
write-host "Stoping $($serviceName)."
|
||||||
Stop-Service $serviceName
|
Stop-Service $serviceName
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($option -eq "restart"){
|
if ($option -eq "restart") {
|
||||||
write-host "Stoping $($serviceName) to be restarted"
|
write-host "Stoping $($serviceName) to be restarted"
|
||||||
Stop-Service $serviceName
|
Stop-Service $serviceName
|
||||||
Start-Sleep 3 # so we give it enough time to fully stop
|
Start-Sleep 3 # so we give it enough time to fully stop
|
||||||
@@ -117,8 +118,8 @@ if($remote -eq "true"){
|
|||||||
Start-Service $serviceName
|
Start-Service $serviceName
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($option -eq "delete"){
|
if ($option -eq "delete") {
|
||||||
if(-not $appPath){
|
if (-not $appPath) {
|
||||||
Write-host "The path to the app is missing please add it in and try again."
|
Write-host "The path to the app is missing please add it in and try again."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -128,8 +129,8 @@ if($remote -eq "true"){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($option -eq "prodStop"){
|
if ($option -eq "prodStop") {
|
||||||
if(-not $appPath){
|
if (-not $appPath) {
|
||||||
Write-host "The path to the app is missing please add it in and try again."
|
Write-host "The path to the app is missing please add it in and try again."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -140,8 +141,8 @@ if($remote -eq "true"){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($option -eq "prodStart"){
|
if ($option -eq "prodStart") {
|
||||||
if(-not $appPath){
|
if (-not $appPath) {
|
||||||
Write-host "The path to the app is missing please add it in and try again."
|
Write-host "The path to the app is missing please add it in and try again."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -152,8 +153,8 @@ if($remote -eq "true"){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($option -eq "install"){
|
if ($option -eq "install") {
|
||||||
if(-not $appPath -or -not $description -or -not $command){
|
if (-not $appPath -or -not $description -or -not $command) {
|
||||||
Write-host "Please check all parameters are passed to install the app.."
|
Write-host "Please check all parameters are passed to install the app.."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -161,19 +162,20 @@ if($remote -eq "true"){
|
|||||||
|
|
||||||
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
|
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
if(-not $service){
|
if (-not $service) {
|
||||||
write-host $serviceName "is not installed we will install it now"
|
write-host $serviceName "is not installed we will install it now"
|
||||||
|
|
||||||
Write-Host "Installing $serviceName..."
|
Write-Host "Installing $serviceName..."
|
||||||
if($command.Contains(".exe")){
|
if ($command.Contains(".exe")) {
|
||||||
|
|
||||||
& $nssmPath install $serviceName $command
|
& $nssmPath install $serviceName $command
|
||||||
|
|
||||||
$fullAppPath = "$appPath\app"
|
$fullAppPath = $appPath
|
||||||
& $nssmPath set $serviceName AppDirectory $fullAppPath
|
& $nssmPath set $serviceName AppDirectory $fullAppPath
|
||||||
}else {
|
}
|
||||||
& $nssmPath install $serviceName $npmPath $command
|
else {
|
||||||
& $nssmPath set $serviceName AppDirectory $appPath
|
& $nssmPath install $serviceName $npmPath $command
|
||||||
|
& $nssmPath set $serviceName AppDirectory $appPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,20 +186,22 @@ if($remote -eq "true"){
|
|||||||
# Set recovery options
|
# Set recovery options
|
||||||
sc.exe failure $serviceName reset= 0 actions= restart/5000/restart/5000/restart/5000
|
sc.exe failure $serviceName reset= 0 actions= restart/5000/restart/5000/restart/5000
|
||||||
& $nssmPath start $serviceName
|
& $nssmPath start $serviceName
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
write-host $serviceName "is already installed will push the updated info"
|
write-host $serviceName "is already installed will push the updated info"
|
||||||
Write-Host "Updating $serviceName..."
|
Write-Host "Updating $serviceName..."
|
||||||
& $nssmPath stop $serviceName
|
& $nssmPath stop $serviceName
|
||||||
|
|
||||||
if($command.Contains(".exe")){
|
if ($command.Contains(".exe")) {
|
||||||
$fullAppPath = "$appPath\app"
|
$fullAppPath = "$appPath\app"
|
||||||
& $nssmPath set $serviceName AppDirectory $fullAppPath
|
& $nssmPath set $serviceName AppDirectory $fullAppPath
|
||||||
}else {
|
}
|
||||||
|
else {
|
||||||
& $nssmPath set $serviceName AppDirectory $appPath
|
& $nssmPath set $serviceName AppDirectory $appPath
|
||||||
}
|
}
|
||||||
|
|
||||||
& $nssmPath set $serviceName Description $description
|
& $nssmPath set $serviceName Description $description
|
||||||
# & $nssmPath set $serviceName DependOnService "IISADMIN MSSQLSERVER"
|
# & $nssmPath set $serviceName DependOnService "IISADMIN MSSQLSERVER"
|
||||||
# Set recovery options
|
# Set recovery options
|
||||||
sc.exe failure $serviceName reset= 0 actions= restart/5000/restart/5000/restart/5000
|
sc.exe failure $serviceName reset= 0 actions= restart/5000/restart/5000/restart/5000
|
||||||
Start-Sleep 4
|
Start-Sleep 4
|
||||||
|
|||||||
Reference in New Issue
Block a user