Skip to content

Commit

Permalink
Build_scripts: Add deployment type to the build_scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija-lazoroski committed Sep 15, 2021
1 parent 60e3463 commit c653f49
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
4 changes: 3 additions & 1 deletion build_scripts/appimage/appimage.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

LINUXDEPLOY_URL="https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
PYTHON_VERSION="3.7.11"
PYTHON_VERSION="3.7.12"
PYTHON_APPIMAGE_URL="https://github.com/niess/python-appimage/releases/download/python3.7/python${PYTHON_VERSION}-cp37-cp37m-manylinux1_x86_64.AppImage"
APPIMAGE_DIR="$(realpath $(dirname $BASH_SOURCE[0]))"
APPDIR="$APPIMAGE_DIR/squashfs-root"
Expand All @@ -27,6 +27,7 @@ install_package_specific_build_prereqs() {
setup_build_dir() {
local agent_binary_dir=$1
local monkey_repo=$2
local deployment_type=$3

pushd $APPIMAGE_DIR

Expand All @@ -36,6 +37,7 @@ setup_build_dir() {

copy_monkey_island_to_build_dir "$monkey_repo/monkey" "$BUILD_DIR"
copy_server_config_to_build_dir
modify_deployment "$deployment_type" "$BUILD_DIR"
add_agent_binaries_to_build_dir "$agent_binary_dir" "$BUILD_DIR"

install_monkey_island_python_dependencies
Expand Down
23 changes: 21 additions & 2 deletions build_scripts/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exit_if_missing_argument() {
echo_help() {
echo "usage: build_package.sh [--help] [--agent-binary-dir <PATH>] [--branch <BRANCH>]"
echo " [--monkey-repo <PATH>] [--version <MONKEY_VERSION>]"
echo " [--deployment <DEPLOYMENT_TYPE>]"
echo ""
echo "Creates a package for Infection Monkey."
echo ""
Expand All @@ -45,6 +46,9 @@ echo_help() {
echo "--version A version number for the package."
echo " (Default: dev)"
echo ""
echo "--deployment A deployment type for the package."
echo " (Default: develop)"
echo ""
echo "--package Which package to build (\"appimage\" or \"docker.\")"

exit 0
Expand Down Expand Up @@ -72,6 +76,15 @@ install_nodejs() {
sudo apt-get install -y nodejs
}

install_common_build_prereqs() {
sudo apt-get update
sudo apt-get upgrade -y

# monkey island prereqs
sudo apt-get install -y curl libcurl4 openssl git build-essential moreutils
install_nodejs
}

is_valid_git_repo() {
pushd "$1" 2>/dev/null || return 1
git status >/dev/null 2>&1
Expand Down Expand Up @@ -108,7 +121,7 @@ branch="develop"
monkey_repo="$DEFAULT_REPO_MONKEY_HOME"
monkey_version="dev"
package=""

deployment_type="develop"

while (( "$#" )); do
case "$1" in
Expand Down Expand Up @@ -143,6 +156,12 @@ while (( "$#" )); do
monkey_version=$2
shift 2
;;
--deployment)
exit_if_missing_argument "$1" "$2"

deployment_type=$2
shift 2
;;
--package)
exit_if_missing_argument "$1" "$2"

Expand Down Expand Up @@ -188,7 +207,7 @@ install_build_prereqs
install_package_specific_build_prereqs "$WORKSPACE"


setup_build_dir "$agent_binary_dir" "$monkey_repo"
setup_build_dir "$agent_binary_dir" "$monkey_repo" "$deployment_type"
build_package "$monkey_version" "$DIST_DIR"

log_message "Finished building package: $package"
Expand Down
5 changes: 5 additions & 0 deletions build_scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ copy_monkey_island_to_build_dir() {
"$src"/monkey_island "$build_dir/"
}

modify_deployment() {
local deployment_file_path="$2/monkey_island/cc/deployment.json"
echo -e "{\n \"deployment\": \"$1\"\n}" > $deployment_file_path
}

add_agent_binaries_to_build_dir() {
local agent_binary_dir=$1
local island_binaries_path="$2/monkey_island/cc/binaries/"
Expand Down
1 change: 1 addition & 0 deletions build_scripts/docker/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ setup_build_dir() {

copy_monkey_island_to_build_dir "$monkey_repo/monkey" "$build_dir"
copy_server_config_to_build_dir "$build_dir"
modify_deployment "$deployment_type" "$build_dir"
add_agent_binaries_to_build_dir "$agent_binary_dir" "$build_dir"

generate_ssl_cert "$build_dir"
Expand Down

0 comments on commit c653f49

Please sign in to comment.