omega-mission
Omega Mission: seeded-Omega mission orchestrator (hash-chained journal, tiered command checks). Host-tested; live dispatch not yet run.
Brought by drakestapleton
omega-mission / install.sh
| 1 | #!/bin/sh |
| 2 | set -eu |
| 3 | cd "$(dirname "$0")" |
| 4 | # Installation only; no build, worker dispatch, or service changes. |
| 5 | [ -x build/mission ] || { echo 'build first' >&2; exit 2; } |
| 6 | if [ "$#" = 2 ]; then prefix=$1; bindir=$2 |
| 7 | elif [ "$#" = 0 ]; then |
| 8 | head=$(git rev-parse HEAD) |
| 9 | # The versioned prefix must name the commit the binary was compiled from. |
| 10 | [ "$(cat build/mission.head 2>/dev/null)" = "$head" ] || { echo 'build/mission is not built from clean HEAD; run build.sh' >&2; exit 2; } |
| 11 | prefix="$HOME/.local/opt/omega-mission/$(printf '%.8s' "$head")" |
| 12 | bindir="$HOME/.local/bin" |
| 13 | else echo 'usage: install.sh [PREFIX BINDIR]' >&2; exit 2 |
| 14 | fi |
| 15 | link="$bindir/mission" |
| 16 | [ ! -e "$link" ] || [ -L "$link" ] || { echo "refusing to replace non-symlink $link" >&2; exit 2; } |
| 17 | if [ -e "$prefix/mission" ]; then |
| 18 | # Immutable prefix: identical bytes re-point the link; different bytes refuse. |
| 19 | cmp -s build/mission "$prefix/mission" || { echo 'immutable install prefix holds different bytes' >&2; exit 2; } |
| 20 | else |
| 21 | mkdir -p "$prefix" |
| 22 | cp build/mission "$prefix/mission.new" |
| 23 | chmod 755 "$prefix/mission.new" |
| 24 | mv "$prefix/mission.new" "$prefix/mission" |
| 25 | fi |
| 26 | mkdir -p "$bindir" |
| 27 | ln -sfn "$prefix/mission" "$link" |
| 28 | printf '%s\n' "$link" |