Merge pull request #1467 from guardicore/1205/modify-build-scripts-deployment

Add deployment type to the build_scripts
This commit is contained in:
Mike Salvatore 2021-09-15 10:31:33 -04:00 committed by GitHub
commit 64c9ccaf46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 2 deletions

View File

@ -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
@ -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

View File

@ -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 ""
@ -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
@ -108,7 +112,7 @@ branch="develop"
monkey_repo="$DEFAULT_REPO_MONKEY_HOME"
monkey_version="dev"
package=""
deployment_type=""
while (( "$#" )); do
case "$1" in
@ -143,6 +147,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"
@ -188,7 +198,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"

View File

@ -15,6 +15,13 @@ copy_monkey_island_to_build_dir() {
"$src"/monkey_island "$build_dir/"
}
modify_deployment() {
if [ -n "$1" ]; then
local deployment_file_path="$2/monkey_island/cc/deployment.json"
echo -e "{\n \"deployment\": \"$1\"\n}" > $deployment_file_path
fi
}
add_agent_binaries_to_build_dir() {
local agent_binary_dir=$1
local island_binaries_path="$2/monkey_island/cc/binaries/"

View File

@ -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"