Files
RustBox/dev.sh
T
Mateusz Gruszczyński dacdf9c27d
RustBox CI / rustbox (push) Canceled after 0s
v0.2.8
2026-11-01 20:40:40 +01:00

75 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
# Local development settings live in .env. RustBox reads environment variables
# from the process; it does not parse dotenv files itself. Export the file here
# before applying development defaults so explicit .env values always win.
ENV_FILE="${RUSTBOX_ENV_FILE:-$ROOT/.env}"
if [ -f "$ENV_FILE" ]; then
set -a
# shellcheck disable=SC1090
. "$ENV_FILE"
set +a
fi
if ! command -v cargo >/dev/null 2>&1; then
echo "error: Rust/Cargo is required" >&2
exit 1
fi
mkdir -p "$ROOT/.dev/data"
export RUSTBOX_CONFIG="${RUSTBOX_CONFIG:-$ROOT/config.dev.toml}"
export DATA_DIR="${DATA_DIR:-$ROOT/.dev/data}"
# Keep application debugging useful without enabling verbose INFO/DEBUG output
# from every dependency. A legacy/simple RUST_LOG level from .env is scoped to
# RustBox automatically; explicit directive filters (containing '=' or ',') are
# respected exactly as provided.
case "${RUST_LOG:-}" in
""|debug)
export RUST_LOG="warn,rustbox=debug,tower_http=info"
;;
trace)
export RUST_LOG="warn,rustbox=trace,tower_http=debug"
;;
info)
export RUST_LOG="warn,rustbox=info,tower_http=info"
;;
warn|error|off)
export RUST_LOG="${RUST_LOG}"
;;
*)
export RUST_LOG="${RUST_LOG}"
;;
esac
if [ ! -f "$RUSTBOX_CONFIG" ]; then
echo "error: config not found: $RUSTBOX_CONFIG" >&2
exit 1
fi
echo "RustBox: http://127.0.0.1:3001"
display_path() {
local value="$1"
if [[ "$value" == "$ROOT"/* ]]; then
printf './%s' "${value#"$ROOT"/}"
else
printf '%s' "$(basename "$value")"
fi
}
echo "Config: $(display_path "$RUSTBOX_CONFIG")"
echo "Data: $(display_path "$DATA_DIR")"
if [ -f "$ENV_FILE" ]; then
echo "Env: $(display_path "$ENV_FILE")"
fi
echo "IMAP: ${IMAP_HOST:-localhost}:${IMAP_PORT:-993}"
echo "SMTP: ${SMTP_HOST:-${IMAP_HOST:-localhost}}:${SMTP_PORT:-587}"
echo
cargo run --quiet --bin rustbox -- --check-config
exec cargo run --bin rustbox -- "$@"