No more need for run_script.bat.
Cleaned up README.md visually
This commit is contained in:
parent
161265e4c4
commit
e226e74100
|
@ -3,13 +3,17 @@
|
|||
|
||||
Before running the script you must have git installed.<br>
|
||||
`Invoke-WebRequest https://raw.githubusercontent.com/guardicore/monkey/develop/deployment_scripts/deploy_windows.ps1 -OutFile deploy_windows.ps1`
|
||||
|
||||
Then execute the resulting script with your shell.
|
||||
First argument is an empty directory (script can create one) and second is branch you want to clone.
|
||||
|
||||
Example usages:<br>
|
||||
`./run_script.bat` (Sets up monkey in current directory under .\infection_monkey)<br>
|
||||
`./run_script.bat "C:\test"` (Sets up monkey in C:\test)<br>
|
||||
`powershell -ExecutionPolicy ByPass -Command ". .\deploy_windows.ps1; Deploy-Windows -monkey_home C:\test"` (Same as above)<br>
|
||||
`./run_script.bat "" "master"` (Sets up master branch instead of develop in current dir)
|
||||
`.\deploy_windows.ps1` (Sets up monkey in current directory under .\infection_monkey)<br>
|
||||
`.\deploy_windows.ps1 -monkey_home "C:\test"` (Sets up monkey in C:\test)<br>
|
||||
`.\deploy_windows.ps1 -branch "master"` (Sets up master branch instead of develop in current dir)
|
||||
|
||||
If you run into Execution Policy warnings, you can disable them by prefixing the following snippet
|
||||
`powershell -ExecutionPolicy ByPass -Command "[original command here]"`
|
||||
|
||||
Don't forget to add python to PATH or do so while installing it via this script.<br>
|
||||
|
||||
|
|
|
@ -1,18 +1,28 @@
|
|||
param(
|
||||
[Parameter(Mandatory = $false, Position = 0)]
|
||||
[String] $monkey_home = (Get-Item -Path ".\").FullName,
|
||||
|
||||
[Parameter(Mandatory = $false, Position = 1)]
|
||||
[System.String]
|
||||
$branch = "develop"
|
||||
)
|
||||
function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName, [String] $branch = "develop")
|
||||
{
|
||||
|
||||
Write-Output "Downloading to $monkey_home"
|
||||
Write-Output "Branch $branch"
|
||||
# Set variables for script execution
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$webClient = New-Object System.Net.WebClient
|
||||
|
||||
|
||||
# Import the config variables
|
||||
$config_filename = New-TemporaryFile
|
||||
$config_filename = "config.ps1"
|
||||
$config_url = "https://raw.githubusercontent.com/guardicore/monkey/" + $branch + "/deployment_scripts/config.ps1"
|
||||
$webClient.DownloadFile($config_url, $config_filename)
|
||||
. ./config.ps1
|
||||
"Config variables from config.ps1 imported"
|
||||
Remove-Item $config_filename
|
||||
#Remove-Item $config_filename
|
||||
|
||||
|
||||
# If we want monkey in current dir we need to create an empty folder for source files
|
||||
|
@ -35,7 +45,9 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
|
|||
}
|
||||
|
||||
# Download the monkey
|
||||
$output = cmd.exe /c "git clone --single-branch -b $branch $MONKEY_GIT_URL $monkey_home 2>&1"
|
||||
$command = "git clone --single-branch -b $branch $MONKEY_GIT_URL $monkey_home 2>&1"
|
||||
Write-Output $command
|
||||
$output = cmd.exe /c $command
|
||||
$binDir = (Join-Path -Path $monkey_home -ChildPath $MONKEY_ISLAND_DIR | Join-Path -ChildPath "\bin")
|
||||
if ($output -like "*already exists and is not an empty directory.*")
|
||||
{
|
||||
|
@ -242,3 +254,4 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName,
|
|||
"Script finished"
|
||||
|
||||
}
|
||||
Deploy-Windows -monkey_home $monkey_home -branch $branch
|
|
@ -1,8 +0,0 @@
|
|||
SET command=. .\deploy_windows.ps1; Deploy-Windows
|
||||
if NOT "%~1" == "" (
|
||||
SET "command=%command% -monkey_home %~1"
|
||||
)
|
||||
if NOT "%~2" == "" (
|
||||
SET "command=%command% -branch %~2"
|
||||
)
|
||||
powershell -ExecutionPolicy ByPass -Command %command%
|
Loading…
Reference in New Issue