Rework launcher source syntax

.gitmodules, .gitignore, osintbuddy-plugins, api.ts, launcher, _colors, api:gen, bootstrap, build, cleanup, debug:send, downkill, env, logs, migrate, pkg:update, ps, python, restart, setup:dev, shell, start, stop, and ui_dev
This commit is contained in:
jerlendds
2023-11-05 06:02:36 -07:00
parent 9ed052e262
commit 4960576cde
22 changed files with 95 additions and 91 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "backend/osintbuddy-plugins"]
path = backend/osintbuddy-plugins
url = git@github.com:jerlendds/osintbuddy-plugins.git

View File

@@ -1,6 +1,26 @@
import { emptyApi as api } from "./baseApi";
const injectedRtkApi = api.injectEndpoints({
endpoints: (build) => ({
refreshPlugins: build.query<
RefreshPluginsApiResponse,
RefreshPluginsApiArg
>({
query: (queryArg) => ({
url: `/api/v1/node/refresh`,
params: { hid: queryArg.hid },
}),
}),
createGraphEntity: build.mutation<
CreateGraphEntityApiResponse,
CreateGraphEntityApiArg
>({
query: (queryArg) => ({
url: `/api/v1/node/`,
method: "POST",
body: queryArg.createNode,
params: { hid: queryArg.hid },
}),
}),
getCasdoorConfig: build.query<
GetCasdoorConfigApiResponse,
GetCasdoorConfigApiArg
@@ -123,26 +143,6 @@ const injectedRtkApi = api.injectEndpoints({
method: "PUT",
}),
}),
refreshPlugins: build.query<
RefreshPluginsApiResponse,
RefreshPluginsApiArg
>({
query: (queryArg) => ({
url: `/api/v1/node/refresh`,
params: { hid: queryArg.hid },
}),
}),
createGraphEntity: build.mutation<
CreateGraphEntityApiResponse,
CreateGraphEntityApiArg
>({
query: (queryArg) => ({
url: `/api/v1/node/`,
method: "POST",
body: queryArg.createNode,
params: { hid: queryArg.hid },
}),
}),
createScanMachine: build.mutation<
CreateScanMachineApiResponse,
CreateScanMachineApiArg
@@ -176,6 +176,17 @@ const injectedRtkApi = api.injectEndpoints({
overrideExisting: false,
});
export { injectedRtkApi as api };
export type RefreshPluginsApiResponse =
/** status 200 Successful Response */ any;
export type RefreshPluginsApiArg = {
hid: string;
};
export type CreateGraphEntityApiResponse =
/** status 200 Successful Response */ any;
export type CreateGraphEntityApiArg = {
hid: string;
createNode: CreateNode;
};
export type GetCasdoorConfigApiResponse =
/** status 200 Successful Response */ any;
export type GetCasdoorConfigApiArg = void;
@@ -264,17 +275,6 @@ export type UpdateEntityFavoriteIdApiResponse =
export type UpdateEntityFavoriteIdApiArg = {
hid: string;
};
export type RefreshPluginsApiResponse =
/** status 200 Successful Response */ any;
export type RefreshPluginsApiArg = {
hid: string;
};
export type CreateGraphEntityApiResponse =
/** status 200 Successful Response */ any;
export type CreateGraphEntityApiArg = {
hid: string;
createNode: CreateNode;
};
export type CreateScanMachineApiResponse =
/** status 200 Successful Response */ any;
export type CreateScanMachineApiArg = {
@@ -291,12 +291,6 @@ export type DeleteScanProjectApiResponse =
export type DeleteScanProjectApiArg = {
sid: number;
};
export type Status = {
status: string;
};
export type HttpError = {
detail: string;
};
export type ValidationError = {
loc: (string | number)[];
msg: string;
@@ -305,6 +299,20 @@ export type ValidationError = {
export type HttpValidationError = {
detail?: ValidationError[];
};
export type XyPosition = {
x: number;
y: number;
};
export type CreateNode = {
label: string;
position: XyPosition;
};
export type Status = {
status: string;
};
export type HttpError = {
detail: string;
};
export type User = {
name: string;
username?: string | null;
@@ -372,19 +380,13 @@ export type EntityBase = {
source?: string;
is_favorite?: boolean;
};
export type XyPosition = {
x: number;
y: number;
};
export type CreateNode = {
label: string;
position: XyPosition;
};
export type ScanMachineCreate = {
name: string;
description: string;
};
export const {
useRefreshPluginsQuery,
useCreateGraphEntityMutation,
useGetCasdoorConfigQuery,
usePostSigninMutation,
usePostSignoutMutation,
@@ -403,8 +405,6 @@ export const {
useUpdateEntityByIdMutation,
useDeleteEntityMutation,
useUpdateEntityFavoriteIdMutation,
useRefreshPluginsQuery,
useCreateGraphEntityMutation,
useCreateScanMachineMutation,
useGetScanMachinesQuery,
useDeleteScanProjectMutation,

View File

@@ -9,7 +9,7 @@ export OB_DIR="$(pwd)/ob"
if [ -f ./ob/cmd/env ]; then
cd $OB_DIR
source cmd/env;
. ./cmd/env;
else
echo "Error! Please run the ./launcher only from the root osintbuddy directory."
exit 1
@@ -67,61 +67,61 @@ fi
case "$OB_CMD" in
bootstrap)
cmd/bootstrap
./cmd/bootstrap
;;
start)
cmd/start
./cmd/start
;;
restart)
cmd/restart
./cmd/restart
;;
stop)
cmd/stop
./cmd/stop
;;
build)
cmd/build
./cmd/build
;;
logs)
cmd/logs
./cmd/logs
;;
api:gen)
cmd/api:gen
./cmd/api:gen
;;
kill)
cmd/downkill
./cmd/downkill
;;
ui)
cmd/ui_dev
./cmd/ui_dev
;;
debug:send)
cmd/debug:send
./cmd/debug:send
;;
cleanup)
cmd/stop
cmd/cleanup
./cmd/stop
./cmd/cleanup
;;
exec)
cmd/shell
./cmd/shell
;;
python)
cmd/python
./cmd/python
;;
migrate)
cmd/migrate
./cmd/migrate
;;
setup:dev)
cmd/setup:dev
./cmd/setup:dev
;;
pkg:update)
cmd/pkg:update
./cmd/pkg:update
;;
ps)
cmd/ps
./cmd/ps
;;
containers)
usage_containers
./usage_containers
;;
show)
print_access_urls
./print_access_urls
;;
esac

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
# https://github.com/ppo/bash-colors (v0.3.0)
c() { [ $# == 0 ] && printf "\e[0m" || printf "$1" | sed 's/\(.\)/\1;/g;s/\([SDIUFNHT]\)/2\1/g;s/\([KRGYBMCW]\)/3\1/g;s/\([krgybmcw]\)/4\1/g;y/SDIUFNHTsdiufnhtKRGYBMCWkrgybmcw/12345789123457890123456701234567/;s/^\(.*\);$/\\e[\1m/g'; }

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_api_gen () {
heading "Generating client SDK..."

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
# From https://stackoverflow.com/a/44660519/702738
compare_version() {
@@ -195,12 +195,12 @@ setup_python_env() {
else
cd ..
python3 -m venv venv && \
. venv/bin/activate && \
. ./venv/bin/activate && \
pip install --upgrade pip && \
pip install -r backend/requirements.txt && \
pip install backend/osintbuddy-plugins
fi
info "Activate virtual environment: . venv/bin/activate"
info "Activate virtual environment: . ./venv/bin/activate"
cd "$OB_DIR"
}

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_build() {
if [ ! -z "$OB_CMD" ] & [ ! -z "$OB_CMD_ARGS" ]; then

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_cleanup() {
heading "Stopping containers and removing volumes"

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
pastebin() {
ob_compose logs > osintbuddy-debug.log

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_down_kill() {
source cmd/container_ids
. ./cmd/container_ids
$docker_path kill $ID_OB_UI $ID_OB_BACKEND $ID_OB_REDIS $ID_OB_DB $ID_OB_JANUS $ID_OB_SDB $ID_OB_INDEX $ID_OB_WORKER $ID_OB_CLEARLY $ID_OB_S3
ob_compose down
}

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env sh
# used in ./ob/cmd/* scripts ran by ./launcher
source cmd/_colors
. ./cmd/_colors
export docker_path=`which docker`
export git_path=`which git`

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_logs() {
heading "Loading $OB_CMD_ARGS logs"

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
migration_message="$OB_CMD_ARGS"

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
pkg_update () {
cd ../

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_ps () {
$docker_path ps

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_python() {

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_restart() {
if [ ! -z "$OB_CMD" ] & [ ! -z "$OB_CMD_ARGS" ]; then

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_setup_dev () {
cd ../

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_shell() {
heading "Running $OB_CMD_OPT1 inside $OB_CMD_ARGS"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
start() {
if [[ ! -z "$OB_CMD_ARGS" ]]; then

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_stop() {

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. cmd/env
. ./cmd/env
run_uidev() {
unset ERR
@@ -10,7 +10,7 @@ run_uidev() {
success "Starting frontend:"
info " http://localhost:3000"
ob_compose stop ui > /dev/null 2>&1
source $COMPOSE_ENV_FILES
. $COMPOSE_ENV_FILES
echo "REACT_APP_BASE_URL (used by ui to call backend): $REACT_APP_BASE_URL"
cd ../frontend
export REACT_APP_BASE_URL=$REACT_APP_BASE_URL