Skip to content

Commit

Permalink
Merge pull request #1155 from ministryofjustice/TM/TM-732/shared-driv…
Browse files Browse the repository at this point in the history
…e-onr-bods

T2 ONR BODS redundancy and shared drive
  • Loading branch information
robertsweetman authored Dec 4, 2024
2 parents 7b3e4f5 + 6720176 commit a917604
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion powershell/Scripts/UserDataScripts/OnrBods.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ $GlobalConfig = @{
# "cmsPrimaryNode" = "t2-tst-bods-asg" # Use this value when testing
"cmsSecondaryNode" = "t2-onr-bods-2"
# "cmsSecondaryNode" = "t2-tst-bods-asg" # Use this value when testing
"cmsPrimaryNodeHostname" = "EC2AMAZ-JM52FS3" # ADD MANUALLY AFTER cmsPrimaryNode DEPLOYED
"cmsPrimaryNodeHostname" = "EC2AMAZ-7VGMSLH" # ADDED MANUALLY AFTER cmsPrimaryNode DEPLOYED
"serviceUser" = "svc_nart"
"serviceUserPath" = "OU=Service,OU=Users,OU=NOMS RBAC,DC=AZURE,DC=NOMS,DC=ROOT"
"nartComputersOU" = "OU=Nart,OU=MODERNISATION_PLATFORM_SERVERS,DC=AZURE,DC=NOMS,DC=ROOT"
"serviceUserDescription" = "Onr BODS service user for AWS in AZURE domain"
"domain" = "AZURE"
"sharedDrive" = "amznfsx7aojksot.azure.noms.root"
}
"oasys-national-reporting-preproduction" = @{
"sysDbName" = "PPBOSYS"
Expand All @@ -44,6 +45,7 @@ $GlobalConfig = @{
"nartComputersOU" = "OU=Nart,OU=MODERNISATION_PLATFORM_SERVERS,DC=AZURE,DC=HMPP,DC=ROOT"
"serviceUserDescription" = "Onr BODS service user for AWS in HMPP domain"
"domain" = "HMPP"
"sharedDrive" = ""
}
"oasys-national-reporting-production" = @{
"domain" = "HMPP"
Expand Down Expand Up @@ -286,6 +288,49 @@ function New-TnsOraFile {

}

function New-SharedDriveShortcut {
param (
[Parameter(Mandatory)]
[hashtable]$Config
)

# NOTE: means there's a desktop shortcut that users can click to access the shared drive with their domain credentials if needed

$share = "\\$($Config.sharedDrive)\share"
$shortcutPath = "C:\Users\Public\Desktop\FSDShare.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$shortcut = $WScriptShell.CreateShortcut($ShortCutPath)
$shortcut.TargetPath = $share
$Shortcut.IconLocation = $share
$Shortcut.Save()
}

# NOTE: this function isn't used but is included because it 'might' be necessary at some point
# There are challenges making this persistently available for all users without implementing things in Active Directory
# function New-SharedDriveMount {
# param (
# [Parameter(Mandatory)]
# [hashtable]$Config
# )

# $Tags = Get-InstanceTags

# $dbenv = ($Tags | Where-Object { $_.Key -eq "oasys-national-reporting-environment" }).Value
# $svcUserPwd = Get-SecretValue -SecretId "/sap/bods/$dbenv/passwords" -SecretKey "svc_nart" -ErrorAction SilentlyContinue
# $user = "$($Config.domain)\$($Config.serviceUser)"
# $drive = "S:"
# $path = "\\$($Config.sharedDrive)\share"

# $DriveParams = @{
# Wait = $true
# NoNewWindow = $true
# FilePath = "cmd.exe"
# ArgumentList = "/c","net use $drive $path $svcUserPwd /USER:$user /PERSISTENT:YES"
# }

# Start-Process @DriveParams
# }

function Install-Oracle19cClient {
param (
[Parameter(Mandatory)]
Expand Down Expand Up @@ -897,3 +942,5 @@ Test-DbCredentials -Config $Config
Install-IPS -Config $Config
Install-DataServices -Config $Config
Set-LoginText -Config $Config
New-SharedDriveShortcut -Config $Config
# }}}

0 comments on commit a917604

Please sign in to comment.