forked from p34709852/monkey
Build: Create separate mongo installation script for Windows
This commit is contained in:
parent
36faa9f5a3
commit
3e5ae392c9
|
@ -21,7 +21,6 @@ $WINDOWS_64_BINARY_PATH = "monkey-windows-64.exe"
|
|||
$MONKEY_ISLAND_DIR = Join-Path "\monkey" -ChildPath "monkey_island"
|
||||
$MONKEY_DIR = Join-Path "\monkey" -ChildPath "infection_monkey"
|
||||
$TEMP_PYTHON_INSTALLER = ".\python.exe"
|
||||
$TEMP_MONGODB_ZIP = ".\mongodb.zip"
|
||||
$TEMP_OPEN_SSL_ZIP = ".\openssl.zip"
|
||||
$TEMP_CPP_INSTALLER = "cpp.exe"
|
||||
$TEMP_NPM_INSTALLER = "node.msi"
|
||||
|
@ -29,7 +28,6 @@ $TEMP_UPX_ZIP = "upx.zip"
|
|||
$UPX_FOLDER = "upx-3.96-win64"
|
||||
|
||||
# Other url's
|
||||
$MONGODB_URL = "https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2012plus-v4.2-latest.zip"
|
||||
$OPEN_SSL_URL = "https://indy.fulgan.com/SSL/openssl-1.0.2u-x64_86-win64.zip"
|
||||
$CPP_URL = "https://go.microsoft.com/fwlink/?LinkId=746572"
|
||||
$NPM_URL = "https://nodejs.org/dist/v16.14.2/node-v16.14.2-x64.msi"
|
||||
|
|
|
@ -163,25 +163,8 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
|
|||
[Environment]::SetEnvironmentVariable("Path", $env:Path, "User")
|
||||
}
|
||||
|
||||
# Download mongodb
|
||||
if (!(Test-Path -Path (Join-Path -Path $binDir -ChildPath "mongodb")))
|
||||
{
|
||||
"Downloading mongodb ..."
|
||||
$webClient.DownloadFile($MONGODB_URL, $TEMP_MONGODB_ZIP)
|
||||
"Unzipping mongodb"
|
||||
Expand-Archive $TEMP_MONGODB_ZIP -DestinationPath $binDir
|
||||
# Get unzipped folder's name
|
||||
$mongodb_folder = Get-ChildItem -Path $binDir | Where-Object -FilterScript {
|
||||
($_.Name -like "mongodb*")
|
||||
} | Select-Object -ExpandProperty Name
|
||||
# Move all files from extracted folder to mongodb folder
|
||||
New-Item -ItemType directory -Path (Join-Path -Path $binDir -ChildPath "mongodb")
|
||||
"Moving extracted files"
|
||||
Move-Item -Path (Join-Path -Path $binDir -ChildPath $mongodb_folder | Join-Path -ChildPath "\bin\*") -Destination (Join-Path -Path $binDir -ChildPath "mongodb\")
|
||||
"Removing zip file"
|
||||
Remove-Item $TEMP_MONGODB_ZIP
|
||||
Remove-Item (Join-Path -Path $binDir -ChildPath $mongodb_folder) -Recurse
|
||||
}
|
||||
$install_mongo_script = (Join-Path -Path $monkey_home -ChildPath "$MONKEY_ISLAND_DIR\windows\install_mongo.ps1")
|
||||
Invoke-Expression "$install_mongo_script -binDir $binDir"
|
||||
|
||||
# Download OpenSSL
|
||||
"Downloading OpenSSL ..."
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
param(
|
||||
[Parameter(Mandatory = $true, Position = 0)]
|
||||
[String]$binDir
|
||||
)
|
||||
|
||||
$MONGODB_URL = "https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2012plus-v4.2-latest.zip"
|
||||
$TEMP_MONGODB_ZIP = ".\mongodb.zip"
|
||||
|
||||
|
||||
if (!(Test-Path -Path (Join-Path -Path $binDir -ChildPath "mongodb")))
|
||||
{
|
||||
"Downloading mongodb ..."
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
(New-Object System.Net.WebClient).DownloadFile($MONGODB_URL, $TEMP_MONGODB_ZIP)
|
||||
|
||||
"Unzipping mongodb"
|
||||
Expand-Archive $TEMP_MONGODB_ZIP -DestinationPath $binDir
|
||||
|
||||
# Get unzipped folder's name
|
||||
$mongodb_folder_name = Get-ChildItem -Path $binDir | Where-Object -FilterScript {
|
||||
($_.Name -like "mongodb*")
|
||||
} | Select-Object -ExpandProperty Name
|
||||
|
||||
# Move mongod file and license file from extracted folder to mongodb folder
|
||||
New-Item -ItemType directory -Path (Join-Path -Path $binDir -ChildPath "mongodb")
|
||||
"Moving extracted mongod and license files"
|
||||
$mongodb_folder_path = (Join-Path -Path $binDir -ChildPath $mongodb_folder_name)
|
||||
$mongodb_bin_folder_path = (Join-Path -Path $mongodb_folder_path -ChildPath "\bin\")
|
||||
$mongod_binary = (Join-Path -Path $mongodb_bin_folder_path -ChildPath "mongod.exe")
|
||||
$license_file = (Join-Path -Path $mongodb_folder_path -ChildPath "LICENSE-Community.txt")
|
||||
Move-Item -Path $mongod_binary -Destination (Join-Path -Path $binDir -ChildPath "mongodb\")
|
||||
Move-Item -Path $license_file -Destination (Join-Path -Path $binDir -ChildPath "mongodb\")
|
||||
|
||||
"Removing zip file and folder with extracted contents"
|
||||
Remove-Item $TEMP_MONGODB_ZIP
|
||||
Remove-Item $mongodb_folder_path -Recurse
|
||||
}
|
Loading…
Reference in New Issue