systemquery/build.sh

90 lines
2.4 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Make sure the current directory is the location of this script to simplify matters
cd "$(dirname "$(readlink -f "$0")")" || { echo "Error: Failed to cd to script directory" >&2; exit 1; };
################
### Settings ###
################
# The name of this project
project_name="systemquery";
# The path to the lantern build engine git submodule
lantern_path="./lantern-build-engine";
###
# Custom Settings
###
# Put any custom settings here.
###############################################################################
# Check out the lantern git submodule if needed
if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${lantern_path}"; fi
#shellcheck disable=SC1090
source "${lantern_path}/lantern.sh";
if [[ "$#" -lt 1 ]]; then
echo -e "${FBLE}${project_name}${RS} build script";
echo -e " by Starbeamrainbowlabs";
# shellcheck disable=SC2154
echo -e "${LC}Powered by the lantern build engine, v${version}${RS}";
echo -e "";
echo -e "${CSECTION}Usage${RS}";
echo -e " ./build ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ...";
echo -e "";
echo -e "${CSECTION}Available actions${RS}";
echo -e " ${CACTION}setup${RS} - Perform initial setup";
echo -e " ${CACTION}launch${RS} - Launch a 3-node development swarm";
echo -e "";
exit 1;
fi
###############################################################################
## Starts a new terminal tab.
# $1 The title of the new tab.
# $2..$n The command to arguments
terminal_tab() {
title="${1}";
shift
gnome-terminal --title "${title}" --tab -- "$@";
}
###############################################################################
task_setup() {
stage_begin "Setting up";
check_command git true;
check_command node true;
check_command npm true;
subtask_begin "Initialising submodules";
git submodule update --init;
subtask_end $?;
stage_end 0;
task_begin "Installing dependencies";
npm install;
task_end $?;
}
task_launch() {
task_begin "Launching swarm";
terminal_tab "systemquery:agent-a" src/index.mjs agent --config config/test_a.toml;
terminal_tab "systemquery:agent-b" src/index.mjs agent --config config/test_b.toml;
terminal_tab "systemquery:agent-c" src/index.mjs agent --config config/test_c.toml;
task_end 0;
}
###############################################################################
tasks_run "$@";