Skip to content

Commit 3c36abe

Browse files
committed
add azure deploy scripts
1 parent 0b0968e commit 3c36abe

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

InstallScripts/deploy.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Function Deploy
2+
{
3+
##param (
4+
##[Parameter(Mandatory=$true)]
5+
##[string] $enviroment,
6+
## [Parameter(Mandatory=$true)]
7+
## [string] $artifiactName
8+
## )
9+
$enviroment = "development"
10+
$artifiactName = "sgp_1.3.1.200.zip"
11+
12+
Import-Module ".\remoteDeployModules.psm1"
13+
$azureConnectionString = "DefaultEndpointsProtocol=https;AccountName=pebbledeploybucket;AccountKey=V4K6iBIbAdDsoQ/Ly7RBpEF8dFvtOdRomFV4a80hxzp5eTxBaOwbkUSE2IELSV+f+5ZG9KVobY7WR/Yy3dABAA=="
14+
$containerName = "testbucket"
15+
Import-Module "C:\Windows\System32\AzureHelper.dll"
16+
17+
#Upload the artifact to the blob store to use later
18+
Push-AzureBlobUpload -ContainerName $containerName -ConnectionString $azureConnectionString -LocalFileName $artifiactName
19+
20+
#Replace config with latest from git
21+
rm config -Recurse -Force -ErrorAction SilentlyContinue
22+
git clone git@github.com:BedeGaming/config.git -b powershell-remote-deploy-scripts
23+
24+
#Loop through each settings folder in the enviroment and install the service
25+
$settingsFolder = ("config\"+$enviroment)
26+
foreach ($serverName in (Get-ChildItem -Path $settingsFolder)){
27+
28+
Write-Host ("Deploying to " + $serverName)
29+
$settings = Get-Content ("config\"+$enviroment +"\" + $serverName + "\settings.xml")
30+
RemoteInstall -remotePC $serverName -azureConnectionString $azureConnectionString -artifiactName $artifiactName -containerName $containerName -settings $settings
31+
}
32+
}
33+
34+
try{
35+
Deploy
36+
}catch{
37+
Write-Error $_.Exception.Message
38+
Read-Host
39+
exit 1
40+
41+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Function RemoteInstall
2+
{
3+
param ([string] $remotePC, [string] $azureConnectionString, [string] $artifiactName, [string] $containerName, [string] $settings)
4+
5+
$params = $remotePC, $azureConnectionString,$artifiactName,$containerName,$settings
6+
$remoteSession = new-pssession -computerName $remotePC
7+
8+
invoke-command -session $remoteSession -ArgumentList $params -ScriptBlock {
9+
try
10+
{
11+
mkdir -ErrorAction SilentlyContinue "C:\BEDE\Temp"
12+
Set-Location "C:\BEDE\Temp"
13+
14+
#Download File
15+
$ZipName = "Artifacts.zip"
16+
$file = "C:\BEDE\Temp\" + $ZipName
17+
Import-Module "C:\Windows\System32\AzureHelper.dll"
18+
Get-AzureBlobDownload -ConnectionString $args[1] -RemoteFileName $args[2] -ContainerName $args[3] -LocalFileName $file
19+
20+
#Unzip it
21+
$shell_app=new-object -com shell.application
22+
$zip_file = $shell_app.namespace($file)
23+
$destination = $shell_app.namespace((Get-Location).Path)
24+
$destination.Copyhere($zip_file.items())
25+
26+
#Make the settings file
27+
$args[4] > settings.xml
28+
29+
#Run Installer
30+
Invoke-Expression ("C:\BEDE\Temp\UnInstallerSub.ps1 -dir C:\BEDE\Temp")
31+
Invoke-Expression ("C:\BEDE\Temp\InstallerSub.ps1 -dir C:\BEDE\Temp")
32+
33+
#Clear the temp directory
34+
get-childitem "C:\BEDE\Temp" -recurse | remove-item -recurse
35+
}
36+
finally
37+
{
38+
Exit-PSSession
39+
}
40+
}
41+
}
42+
43+
44+
export-modulemember RemoteInstall

0 commit comments

Comments
 (0)