From 051621bdfab2617417604f3c7e34c3561442faf1 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 19 Apr 2021 19:37:46 -0400 Subject: [PATCH] Modify monkey_island/linux/run.sh to use pipenv --- deployment_scripts/README.md | 4 ++-- monkey/monkey_island/linux/run.sh | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/deployment_scripts/README.md b/deployment_scripts/README.md index 7281d0d4f..8a6c5d4a8 100644 --- a/deployment_scripts/README.md +++ b/deployment_scripts/README.md @@ -60,8 +60,8 @@ You may also pass in an optional third `false` parameter to disable downloading After the `deploy_linux.sh` script completes, you can start the monkey island. ```sh -cd infection_monkey/monkey -./monkey_island/linux/run.sh +cd infection_monkey/monkey/monkey_island +pipenv run ./linux/run.sh ``` ## Pre-commit hooks diff --git a/monkey/monkey_island/linux/run.sh b/monkey/monkey_island/linux/run.sh index 2a5c45bbe..a284ffa83 100644 --- a/monkey/monkey_island/linux/run.sh +++ b/monkey/monkey_island/linux/run.sh @@ -1,16 +1,21 @@ #!/bin/bash -# Detecting command that calls python 3.7 -python_cmd="" -if [[ $(python --version 2>&1) == *"Python 3.7"* ]]; then - python_cmd="python" -fi -if [[ $(python37 --version 2>&1) == *"Python 3.7"* ]]; then - python_cmd="python37" -fi -if [[ $(python3.7 --version 2>&1) == *"Python 3.7"* ]]; then - python_cmd="python3.7" -fi +start_mongo() { + # TODO: Handle starting and cleaning up mongo inside monkey_island.py or + # monkey_island/main.py. + ./bin/mongodb/bin/mongod --dbpath ./bin/mongodb/db & +} -./monkey_island/bin/mongodb/bin/mongod --dbpath ./monkey_island/bin/mongodb/db & -${python_cmd} ./monkey_island.py +cd_to_monkey() { + # Pipenv must be run from monkey/monkey/monkey_island, but monkey_island.py + # must be executed from monkey/monkey. + cd .. +} + +start_monkey_island() { + cd_to_monkey + python ./monkey_island.py +} + +start_mongo +start_monkey_island