2020-06-02 17:52:54 +05:00
|
|
|
####################################################################################
|
|
|
|
|
## File: Install-MongoDB.ps1
|
|
|
|
|
## Desc: Install MongoDB
|
|
|
|
|
####################################################################################
|
|
|
|
|
|
2022-08-05 20:50:37 +02:00
|
|
|
# Install mongodb package
|
2023-12-11 22:23:36 +01:00
|
|
|
$toolsetContent = Get-ToolsetContent
|
|
|
|
|
$toolsetVersion = $toolsetContent.mongodb.version
|
2023-08-09 14:28:33 +02:00
|
|
|
|
2023-12-04 10:50:53 +01:00
|
|
|
$getMongoReleases = Invoke-WebRequest -Uri "mongodb.com/docs/manual/release-notes/$toolsetVersion/" -UseBasicParsing
|
2023-12-11 22:23:36 +01:00
|
|
|
$targetReleases = $getMongoReleases.Links.href | Where-Object { $_ -like "#$toolsetVersion*---*" }
|
2023-08-09 14:28:33 +02:00
|
|
|
|
2023-12-11 22:23:36 +01:00
|
|
|
$minorVersions = @()
|
|
|
|
|
foreach ($release in $targetReleases) {
|
2023-10-19 17:57:16 +02:00
|
|
|
if ($release -notlike "*upcoming*") {
|
2023-12-04 10:50:53 +01:00
|
|
|
$pattern = '\d+\.\d+\.\d+'
|
|
|
|
|
$version = $release | Select-String -Pattern $pattern -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
|
2023-12-11 22:23:36 +01:00
|
|
|
$minorVersions += $version
|
2023-10-19 17:57:16 +02:00
|
|
|
}
|
2023-12-04 10:50:53 +01:00
|
|
|
}
|
2023-08-09 14:28:33 +02:00
|
|
|
|
2023-12-11 22:23:36 +01:00
|
|
|
$latestVersion = $minorVersions[0]
|
2023-08-09 14:28:33 +02:00
|
|
|
|
2023-11-22 15:14:08 +01:00
|
|
|
Install-Binary `
|
2023-12-11 22:23:36 +01:00
|
|
|
-Url "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-$latestVersion-signed.msi" `
|
2023-12-04 10:50:53 +01:00
|
|
|
-ExtraInstallArgs @('TARGETDIR=C:\PROGRA~1\MongoDB ADDLOCAL=ALL') `
|
2023-12-11 22:23:36 +01:00
|
|
|
-ExpectedSignature $toolsetContent.mongodb.signature
|
2022-08-05 20:50:37 +02:00
|
|
|
|
|
|
|
|
# Add mongodb to the PATH
|
2023-11-23 18:08:20 +01:00
|
|
|
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'mongodb'").PathName
|
2020-06-03 17:35:03 +03:00
|
|
|
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
|
|
|
|
|
Add-MachinePathItem "$mongoBin"
|
2020-07-09 10:53:29 +03:00
|
|
|
|
2022-08-08 15:55:18 +02:00
|
|
|
# Wait for mongodb service running
|
2023-11-23 18:08:20 +01:00
|
|
|
$mongodbService = Get-Service "mongodb"
|
|
|
|
|
$mongodbService.WaitForStatus('Running', '00:01:00')
|
2022-08-08 15:55:18 +02:00
|
|
|
|
2022-08-05 20:50:37 +02:00
|
|
|
# Stop and disable mongodb service
|
2023-11-23 18:08:20 +01:00
|
|
|
Stop-Service $mongodbService
|
|
|
|
|
$mongodbService | Set-Service -StartupType Disabled
|
2022-08-05 20:50:37 +02:00
|
|
|
|
2023-10-19 17:57:16 +02:00
|
|
|
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"
|