-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp-install-website.ps1
96 lines (79 loc) · 4.51 KB
/
app-install-website.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Param(
[Parameter(HelpMessage="Where are the source files for the application? (required)")]
[string]$sourceFolder,
[Parameter(Mandatory=$True,HelpMessage="Where is the folder where applications are installed to? (required)")]
[string]$destinationFolder,
[Parameter(HelpMessage="Where is the folder where applications are backed up before being updated?")]
[string]$backupFolder,
[Parameter(Mandatory=$True,HelpMessage="Where are the XDT transforms for the *.example.config files? (required)")]
[string]$transformsFolder,
[Parameter(Mandatory=$True,HelpMessage="What is the name of the IIS site where the application is being set up? (required)")]
[string]$websiteName,
[Parameter(Mandatory=$True,HelpMessage="Why is this change being made? (required)")]
[string]$comment
)
########################################################################
### BOOTSTRAP. Copy this section into each application setup script ###
### to make sure required functions are available. ###
########################################################################
$pathOfThisScript = Split-Path $MyInvocation.MyCommand.Path -Parent
$parentFolderOfThisScript = $pathOfThisScript | Split-Path -Parent
$scriptsProject = 'Escc.WebApplicationSetupScripts'
$functionsPath = "$pathOfThisScript\..\$scriptsProject\functions.ps1"
if (Test-Path $functionsPath) {
Write-Host "Checking $scriptsProject is up-to-date"
Push-Location "$pathOfThisScript\..\$scriptsProject"
git pull origin master
Pop-Location
Write-Host
.$functionsPath
} else {
if ($env:GIT_ORIGIN_URL) {
$repoUrl = $env:GIT_ORIGIN_URL -f $scriptsProject
git clone $repoUrl "$pathOfThisScript\..\$scriptsProject"
}
else
{
Write-Warning '$scriptsProject project not found. Please set a GIT_ORIGIN_URL environment variable on your system so that it can be downloaded.
Example: C:\>set GIT_ORIGIN_URL=https://example-git-server.com/{0}"
{0} will be replaced with the name of the repository to download.'
Exit
}
}
########################################################################
### END BOOTSTRAP. #####################################################
########################################################################
$projectName = "Escc.Umbraco.Expiry.Web"
$sourceFolder = NormaliseFolderPath $sourceFolder "$PSScriptRoot\$projectName"
$destinationFolder = NormaliseFolderPath $destinationFolder
$backupFolder = NormaliseFolderPath $backupFolder
if (!$backupFolder) { $backupFolder = "$destinationFolder\backups" }
$backupFolder = "$backupFolder\$websiteName"
$destinationFolder = "$destinationFolder\$websiteName"
$transformsFolder = NormaliseFolderPath $transformsFolder
BackupApplication "$destinationFolder/$projectName" $backupFolder $comment
robocopy $sourceFolder "$destinationFolder/$projectName" /MIR /IF *.dll *.js *.css *.png glyphicons*.* *.cshtml *.asax csc.* csi.* /XD App_Data obj Properties App_Start
TransformConfig "$sourceFolder\web.example.config" "$destinationFolder\$projectName\web.config" "$transformsFolder\$projectName\web.release.config"
if (Test-Path "$transformsFolder\$projectName\web.$websiteName.config") {
TransformConfig "$destinationFolder\$projectName\web.config" "$destinationFolder\$projectName\web.temp1.config" "$transformsFolder\$projectName\web.$websiteName.config"
copy "$destinationFolder\$projectName\web.temp1.config" "$destinationFolder\$projectName\web.config"
del "$destinationFolder\$projectName\web.temp1.config"
}
copy "$sourceFolder\Views\web.config" "$destinationFolder\$projectName\Views\web.config"
EnableDotNet40InIIS
CreateApplicationPool "$projectName-$websiteName"
CheckSiteExistsBeforeAddingApplication $websiteName
CreateVirtualDirectory $websiteName "umbraco-expiry" "$destinationFolder\$projectName" true "$projectName-$websiteName"
DisableAnonymousAuthentication $websiteName "umbraco-expiry"
EnableWindowsAuthentication $websiteName "umbraco-expiry"
# Give application pool account write access so that it can create clientDependency cache files
Write-Host "Granting Modify access to the application pool account"
if (!(Test-Path "$destinationFolder\$projectName\App_Data")) {
md "$destinationFolder\$projectName\App_Data"
}
$acl = Get-Acl "$destinationFolder/$projectName/App_Data"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS AppPool\$projectName-$websiteName", "Modify", "ContainerInherit,ObjectInherit", "None", "Allow")
$acl.SetAccessRule($rule)
Set-Acl "$destinationFolder/$projectName/App_Data" $acl
Write-Host
Write-Host "Done." -ForegroundColor "Green"