diff options
| author | info@mode42.com <info@mode42.com> | 2026-08-08 03:54:55 +0000 |
|---|---|---|
| committer | info@mode42.com <info@mode42.com> | 2026-08-08 03:54:55 +0000 |
| commit | 20cb29c2f8c5c87bc590896854a20b1473ceb358 (patch) | |
| tree | 2857f41513a56ad41af97b57362639298aa7f033 /scripts/hybbx.sh | |
#2
Diffstat (limited to 'scripts/hybbx.sh')
| -rwxr-xr-x | scripts/hybbx.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/scripts/hybbx.sh b/scripts/hybbx.sh new file mode 100755 index 0000000..9652654 --- /dev/null +++ b/scripts/hybbx.sh @@ -0,0 +1,86 @@ +#!/bin/sh +# Start hybbxd only. Build and install with CMake (see README). +# +# Default install (source tree): ./bin/hybbx-start +# Prefix install: /usr/local/hybbx/hybbx-start (or $HOME/hybbx/…) +# Dev (no install): ./scripts/hybbx.sh +# +# Detached: hybbx-start --screen | --tmux [--attach] +set -e + +self="${0#./}" +case "$self" in + /*) script_path="$self" ;; + *) script_path="$(pwd)/$self" ;; +esac +script_dir="$(cd "$(dirname "$script_path")" && pwd)" +script_name="$(basename "$script_path")" + +# Installed layout: <tree>/hybbx-start + <tree>/hybbxd (./bin or <prefix>/hybbx) +if [ "$script_name" = "hybbx-start" ] && [ -x "$script_dir/hybbxd" ]; then + prefix="$script_dir" + config="${HYBBX_CONFIG:-$prefix/hybbx.ini}" + binary="$script_dir/hybbxd" + export HYBBX_ROOT="${HYBBX_ROOT:-$prefix}" + cd "$prefix" + if [ ! -f "$config" ]; then + echo "Config not found: $config" >&2 + exit 1 + fi + if [ "$#" -eq 0 ]; then + exec "$binary" -c "$config" + fi + exec "$binary" -c "$config" "$@" +fi + +# Explicit or known install roots +root="$(cd "$script_dir/.." && pwd)" +if [ -n "$HYBBX_ROOT" ]; then + prefix="$HYBBX_ROOT" +elif [ -x "$root/bin/hybbxd" ]; then + prefix="$root/bin" +elif [ -x "/usr/local/hybbx/hybbxd" ]; then + prefix="/usr/local/hybbx" +elif [ -n "$HOME" ] && [ -x "$HOME/hybbx/hybbxd" ]; then + prefix="$HOME/hybbx" +else + prefix="" +fi + +if [ -n "$prefix" ]; then + config="${HYBBX_CONFIG:-$prefix/hybbx.ini}" + binary="$prefix/hybbxd" + if [ -x "$binary" ] && [ -f "$config" ]; then + export HYBBX_ROOT="${HYBBX_ROOT:-$prefix}" + cd "$prefix" + if [ "$#" -eq 0 ]; then + exec "$binary" -c "$config" + fi + exec "$binary" -c "$config" "$@" + fi +fi + +# Development tree (repo checkout, no cmake --install yet) +config="${HYBBX_CONFIG:-$root/local/hybbx.ini}" +build="$root/build/src/hybbxd" + +if [ -f "$config" ] && [ -x "$build" ]; then + export HYBBX_ROOT="${HYBBX_ROOT:-$root}" + cd "$root" + if [ "$#" -eq 0 ]; then + exec "$build" -c "$config" + fi + exec "$build" -c "$config" "$@" +fi + +echo "HyBBX not found." >&2 +echo "Build and install (default → ./bin):" >&2 +echo " cmake -B build -DCMAKE_BUILD_TYPE=Release" >&2 +echo " cmake --build build" >&2 +echo " cmake --install build" >&2 +echo " ./bin/hybbx-start" >&2 +echo "System prefix:" >&2 +echo " cmake -B build -DCMAKE_INSTALL_PREFIX=/usr/local" >&2 +echo " cmake --build build && sudo cmake --install build" >&2 +echo " /usr/local/hybbx/hybbx-start" >&2 +exit 1 |
