Files
osintbuddy/launcher
jerlendds 30a83ee05f Rework /usr/bin/env from sh to bash
pre-commit, launcher, _colors, api:gen, bootstrap, build, cleanup, container_id, container_ids, debug:send, downkill, env, logs, migrate, pkg:update, ps, python, restart, setup:dev, shell, start, stop, and ui_dev
2023-11-05 07:17:46 -07:00

128 lines
4.4 KiB
Bash
Executable File

#!/usr/bin/env bash
export OB_CMD=$1;
export OB_CMD_ARGS=$2;
export OB_CMD_OPT1=${3:-""};
export OB_CMD_OPT2=${4:-""};
export OB_CMD_OPT3=${5:-""};
export OB_DIR="$(pwd)/ob"
if [ -f ./ob/cmd/env ]; then
cd $OB_DIR
. ./cmd/env;
else
echo "Error! Please run the ./launcher only from the root osintbuddy directory."
exit 1
fi
# localhost:45910/login/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=read&state=
usage_containers () {
echo ""
echo -e "$(c 0uY) CONTAINERS: CONTAINER DESCRIPTION.$(c)"
echo -e " $(c Y )ui$(c): React - SPA frontend."
echo -e " $(c Y )backend$(c): FastAPI - running on Uvicorn with hot reloading."
echo -e " $(c Y )casdoor$(c): Casdoor - An open-source IAM / SSO platform with web UI supporting OAuth 2.0, OIDC, etc"
echo -e " $(c Y )worker$(c): Celery - Distributed Task Queue."
echo -e " $(c Y )clearly$(c): Clearly - Real time monitor for your celery tasks and workers."
echo -e " $(c Y )redis$(c): Redis - In-memory database that persists on disk. Used by worker and for caching."
echo -e " $(c Y )s3$(c): Minio S3 object storage - In the future we plan to also support seaweedfs."
echo -e " $(c Y )db$(c): PostgreSQL - need I say anything else?"
echo -e " $(c Y )sdb$(c): ScyllaDB - a NoSQL database that optimizes for raw performance. Used by JanusGraph."
# TODO: Make lucene the default option...
# > "Apache Lucene performs better in small scale, single machine applications..."
# source: https://docs.janusgraph.org/index-backend/
echo -e " $(c Y )index$(c): Solr - Open source enterprise search platform - Used by JanusGraph."
echo -e " $(c Y )janus$(c): JanusGraph - Distributed, open source, massively scalable graph database."
exit 1
}
usage () {
echo -e "Launcher usage: $(c G)./launcher COMMAND COMMAND_ARGS $(c)"
echo -e "$(c 0usBB) COMMANDS: COMMAND DESCRIPTION.$(c)"
echo -e " $(c YsB)start$(c): Start the OSINTBuddy app and tail the logs."
echo -e " $(c YsB)stop$(c): Stop the OSINTBuddy app (or a specific container ./launcher stop janus)."
echo -e " $(c YsB)build$(c): Build the OSINTBuddy app (or a specific container ./launcher build ui)."
echo -e " $(c YsB)restart$(c): Restart the app (or a specific container: ./launcher restart janus)."
echo -e " $(c YsB)api:gen$(c): Generate API client SDK from the backend OpenAPI spec; launch the UI outside of the container"
echo -e " $(c YsB)setup:dev$(c): Create python venv and install dev dependencies"
echo -e " $(c YsB)bootstrap$(c): Initialize and download dependencies and check for environment misconfigurations"
echo -e " $(c YsB)debug:send$(c): Upload all logs to https://paste.c-net.org for help with debugging"
echo -e " $(c YsB)cleanup$(c): Remove docker volumes."
echo -e " $(c YsB)exec$(c): Execute commands for a container."
echo -e " $(c YsB)migrate$(c): Generate a migration."
echo -e " $(c YsB)python$(c): Open a python shell on the backend."
echo -e " $(c YsB)ui$(c): Stop the UI container and launch the frontend locally."
echo -e " $(c YsB)kill$(c): Kill containers; down the stack."
echo -e " $(c YsB)containers$(c): List the names you can access the containers by"
echo -e " $(c YsB)pkg:update$(c): Update the osintbuddy package locally and in docker from the osintbuddy-plugins repo (used in dev)"
usage_containers
exit 1
}
if [ -z "$OB_CMD" -a "$OB_CMD" != "cleanup" ]; then
usage
fi
case "$OB_CMD" in
bootstrap)
./cmd/bootstrap
;;
start)
./cmd/start
;;
restart)
./cmd/restart
;;
stop)
./cmd/stop
;;
build)
./cmd/build
;;
logs)
./cmd/logs
;;
api:gen)
./cmd/api:gen
;;
kill)
./cmd/downkill
;;
ui)
./cmd/ui_dev
;;
debug:send)
./cmd/debug:send
;;
cleanup)
./cmd/stop
./cmd/cleanup
;;
exec)
./cmd/shell
;;
python)
./cmd/python
;;
migrate)
./cmd/migrate
;;
setup:dev)
./cmd/setup:dev
;;
pkg:update)
./cmd/pkg:update
;;
ps)
./cmd/ps
;;
containers)
./usage_containers
;;
show)
./print_access_urls
;;
esac