Skip to content

Commit

Permalink
task: Script renaming and variable quoting to work on windows and han…
Browse files Browse the repository at this point in the history
…dle paths with spaces.

Signed-off-by: Dillon <[email protected]>
  • Loading branch information
dljm committed Dec 9, 2023
1 parent 645c20c commit 2a5357e
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 42 deletions.
19 changes: 8 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: '[BUG] '
labels: 'Type: Bug'
title: "[BUG] "
labels: "Type: Bug"
assignees: jerlendds

---

**Bug Description:**
Expand All @@ -13,26 +12,24 @@ A clear and concise description of what the bug is...

**How to Reproduce:**

1.
2.
3.

1.
2.
3.

**Expected behavior:**

...

**Screenshots & Logs:**

Please run `./launcher debug:send` to upload and get a public link to your log files.
Please run `./launcher debug_send` to upload and get a public link to your log files.
This will help us with debugging and solving any issues.

**Environment:**
- OS: Linux
- Browser: Firefox

- OS: Linux
- Browser: Firefox

**Additional context:**

...

24 changes: 12 additions & 12 deletions launcher
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ usage () {
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 python3 venv and install dev dependencies"
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 python3 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)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 python3 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)"
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
Expand Down Expand Up @@ -85,17 +85,17 @@ case "$OB_CMD" in
logs)
./cmd/logs
;;
api:gen)
./cmd/api:gen
api_gen)
./cmd/api_gen
;;
kill)
./cmd/downkill
;;
ui)
./cmd/ui_dev
;;
debug:send)
./cmd/debug:send
debug_send)
./cmd/debug_send
;;
cleanup)
./cmd/stop
Expand All @@ -110,11 +110,11 @@ case "$OB_CMD" in
migrate)
./cmd/migrate
;;
setup:dev)
./cmd/setup:dev
setup_dev)
./cmd/setup_dev
;;
pkg:update)
./cmd/pkg:update
pkg_update)
./cmd/pkg_update
;;
ps)
./cmd/ps
Expand Down
0 ob/cmd/api:gen → ob/cmd/api_gen
100755 → 100644
File renamed without changes.
31 changes: 14 additions & 17 deletions ob/cmd/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,29 @@ check_prereqs() {
python_min_version='3.11.0'
python_rec_version='3.11.4'

# 0. TODO: Install windows and test git crlf config...
# (Please, someone else do this, I really don't want to install windows..)
if [[ $(grep -i Microsoft /proc/version) ]]; then
# Test git crlf config for windows devices
if [ $is_windows ]; then
heading "Windows detected! Checking for environment issues..."
prepare_windows
fi
if [ -z $docker_path ]; then

if [ -z "$docker_path" ]; then
install_docker
fi

# 1. docker daemon running?
# we send stderr to /dev/null cause we don't care about warnings,
# it usually complains about swap which does not matter
test=`$docker_path info 2> /dev/null`
test=`"$docker_path" info 2> /dev/null`
if [[ $? -ne 0 ]] ; then
error "Cannot connect to the docker daemon - verify it is running and you have access"
exit 1
fi

# 2. running recommended docker version
test=($($docker_path --version)) # Get docker version string
test=($("$docker_path" --version)) # Get docker version string
test=${test[2]//,/} # Get version alone and strip comma if exists

# At least minimum docker version
if compare_version "${docker_min_version}" "${test}"; then
echo "ERROR: Docker version ${test} not supported, please upgrade to at least ${docker_min_version}, or recommended ${docker_rec_version}"
Expand All @@ -122,19 +121,17 @@ check_prereqs() {


# 3. has node and running recommended node version
if [ -z "$(which $node)" ]; then
if [ -z "$node" ]; then
warning "Node environment not detected! We recommend installing Node 18.18.2 for this project."
warning "Some ./launcher commands may not work without a node environment."
heading "Attempting to continue without Node..."
fi

test=($($node --version))
test=($("$node" --version))
test=${test[0]//v/} # Get version alone and strip the prefixed v



if compare_version "${node_min_version}" "${test}"; then
echo "WARNING: Node version ${test} not supported, please upgrade to at least ${node_min_version}, or recommended ${node_rec_version}"
warning "WARNING: Node version ${test} not supported, please upgrade to at least ${node_min_version}, or recommended ${node_rec_version}"
fi

# Recommend best Node version
Expand All @@ -143,7 +140,7 @@ check_prereqs() {
fi

# 4. running recommended Python version
test=($($python3 --version))
test=($("$python3" --version))
test=${test[1]///} # Get version alone and strip the prefixed v

if compare_version "${python_min_version}" "${test}"; then
Expand Down Expand Up @@ -180,7 +177,7 @@ check_prereqs() {
esac

# 4. running recommended git version
test=($($git_path --version)) # Get git version string
test=($("$git_path" --version)) # Get git version string
test=${test[2]//,/} # Get version alone and strip comma if exists

# At least minimum version
Expand Down Expand Up @@ -216,7 +213,7 @@ setup_python_env() {

setup_ui_env() {
cd ../frontend/ && yarn && yarn install:hooks
info "Generate the UI API client with: ./launcher api:gen"
info "Generate the UI API client with: ./launcher api_gen"
cd "$OB_DIR"
}

Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion ob/cmd/env
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/bash
# used by ./ob/cmd/* scripts ran by this ./launcher
. ./cmd/_colors
. ./cmd/utils

export node=`which node`
export python3=`which python`
export docker_path=`which docker`
export git_path=`which git`
export is_windows=get_is_windows


# https://docs.docker.com/compose/environment-variables/envvars/
Expand All @@ -16,7 +18,7 @@ export COMPOSE_FILE="$(pwd)/alpha-compose.yml"
export OB_COMPOSE_OVERRIDE="$(pwd)/alpha-compose.override.yml"

ob_compose() {
$docker_path compose -f $COMPOSE_FILE -f $OB_COMPOSE_OVERRIDE "$@"
"$docker_path" compose -f $COMPOSE_FILE -f $OB_COMPOSE_OVERRIDE "$@"
}

# Colored logs...
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ob/cmd/ui_dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

run_uidev() {
unset ERR
cmd/api:gen || ERR=$?
cmd/api_gen || ERR=$?
if [[ $ERR > 0 ]]; then
error "We ran into an error generating the frontends API client. Is the backend running?"
fi
Expand Down
19 changes: 19 additions & 0 deletions ob/cmd/utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Helpful utility functions used by various scripts

function get_is_windows() {
# Check if the OSTYPE variable is null or unset
if [ -z "$OSTYPE" ]; then
return 1 # Not Windows
else
# Check the operating system to determine if it is Windows
case "$OSTYPE" in
msys*|cygwin*|mingw*|win32*)
return 0 # Windows
;;
*)
return 1 # Not Windows
;;
esac
fi
}

0 comments on commit 2a5357e

Please sign in to comment.