Make deploy_linux.sh download the configuration, avoiding need for duplicate git clone.

This commit is contained in:
Daniel Goldberg 2020-01-04 23:17:48 +02:00
parent 1cb66b46fa
commit 3191b2d94e
2 changed files with 34 additions and 6 deletions

View File

@ -15,7 +15,9 @@ Don't forget to add python to PATH or do so while installing it via this script.
Linux deployment script is meant for Ubuntu 16.x machines.
You must have root permissions, but don't run the script as root.<br>
Launch deploy_linux.sh from scripts directory.<br>
`wget https://raw.githubusercontent.com/guardicore/monkey/develop/deployment_scripts/deploy_linux.sh`
Then execute the resulting script with your shell.
First argument should be an absolute path of an empty directory (script will create one if doesn't exist, default is ./infection_monkey).
Second parameter is the branch you want to clone (develop by default).
Example usages:<br>

View File

@ -1,10 +1,31 @@
#!/bin/bash
source config
exists() {
command -v "$1" >/dev/null 2>&1
}
is_root() {
return $(id -u)
}
has_sudo() {
# 0 true, 1 false
timeout 1 sudo id && return 0 || return 1
}
config_branch=${2:-"develop"}
config_url="https://raw.githubusercontent.com/guardicore/monkey/"$config_branch"/deployment_scripts/config"
if exists curl; then
file=$(mktemp)
curl -s -o $file "$config_url"
source $file
rm $file
else
echo 'Your system does not have curl, exiting'
exit 1
fi
# Setup monkey either in dir required or current dir
monkey_home=${1:-$(pwd)}
if [[ $monkey_home == $(pwd) ]]; then
@ -30,8 +51,13 @@ log_message() {
echo -e "-------------------------------------------\n"
}
sudo -v
if [[ $? != 0 ]]; then
if is_root; then
echo "Please don't runt this script as root"
exit 1
fi
HAS_SUDO=$(has_sudo)
if [[ ! $HAS_SUDO ]]; then
echo "You need root permissions for some of this script operations. Quiting."
exit 1
fi
@ -46,8 +72,8 @@ if ! exists git; then
fi
if ! exists wget; then
echo 'Your system does have wget, please install and re-run this script'
exit 1
echo 'Your system does have wget, please install and re-run this script'
exit 1
fi
log_message "Cloning files from git"