-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart-service.ps1
46 lines (40 loc) · 1.59 KB
/
start-service.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#REQUIRES -version 2.0
<#
.SYNOPSIS
Download the latest build of this component from Maven and start the service
.NOTES
File Name : start-service.ps1
Author : Jan Helge Maurtvedt [email protected]
Prerequisite : PowerShell V2 over Vista and upper.
.EXAMPLE
./start-service.ps1
.EXAMPLE
Example 2
#>
#Set mode variable for DEV, TEST or PROD mode
$mode = 'TEST'
#Set environment variable
$env:IAM_MODE=$mode
# Set service name, version and repository
$A='UserAdminWebApp'
$V='2.14-SNAPSHOT'
$url = 'http://mvnrepo.cantara.no/service/local/artifact/maven/content?r=altran-snapshots&g=net.whydah.identity&a='+$A+'&v='+$V+'&p=jar'
$user = 'altran'
$pwd = ConvertTo-SecureString "l1nkSys" -AsPlainText -Force
$jarstartconfig = "-DIAM_CONFIG=useradminwebapp."+ $mode + ".properties"
# Kill process if this service already runs
#TODO: Line below gives error: Stop-Process : Cannot bind parameter 'InputObject'. Cannot convert the "UserAdministration" value of type "System.Strin
# g" to type "System.Diagnostics.Process".
# kill -f $A
# Build jarfilename, destination path, etc
$jarfile = $A+'.'+$V+'.jar'
$jardestination = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$jardestination+= "\"+$jarfile
#Download the latest jar file from mvnrepo
$creds = New-Object System.Management.Automation.PSCredential ($user, $pwd)
$webclient = new-object System.Net.WebClient
$webclient.Credentials = $creds
$webclient.DownloadFile($url,$jardestination)
#Start the service
#Todo: Fix so it starts in background
java -jar $jarstartconfig $jarfile