#!/bin/sh set -e here=$(cd "$(dirname "$0")" && pwd) bindir="${RELAY2_PREFIX:-$HOME/bin}" root="${RELAY2_ROOT:-$HOME/.relay2}" venv="$root/venv" python="${RELAY2_PYTHON:-python3}" if [ "${1:-}" = "--uninstall" ]; then rm -f "$bindir/relay2" rm -rf "$venv" echo "removed $bindir/relay2 and $venv" echo "your messages were left alone. Remove them yourself if you want them gone:" echo " $root" exit 0 fi if ! command -v "$python" >/dev/null 2>&1; then echo "$python not found. Install Python 3.9 or newer first." >&2 exit 1 fi if ! "$python" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 9) else 1)'; then echo "relay2 needs Python 3.9 or newer; $python is $("$python" -V 2>&1)." >&2 exit 1 fi echo "creating a private Python environment in $venv" "$python" -m venv "$venv" "$venv/bin/python" -m pip install --quiet --disable-pip-version-check pyyaml chmod +x "$here/relay2" mkdir -p "$bindir" rm -f "$bindir/relay2" printf '#!/bin/sh\nexec "%s" "%s" "$@"\n' "$venv/bin/python" "$here/relay2" > "$bindir/relay2" chmod 755 "$bindir/relay2" echo "installed:" echo " $bindir/relay2, which runs $here/relay2 with $venv/bin/python" echo " data root $root" echo "" echo "The launcher points back into this directory, so keep it where it is." case ":$PATH:" in *":$bindir:"*) ;; *) echo "" echo "NOTE: $bindir is not on PATH. Add to your shell startup file:" echo " export PATH=\"$bindir:\$PATH\"" ;; esac echo "" echo "next:" echo " export RELAY_ROLE=" echo " relay2 send --to someone --subject hello --body 'first message'" echo " relay2 watch --once" echo " relay2 inbox"