#!/usr/bin/env bash # Plexum-fabric-channel-plugin local installer. # # Builds + installs: # ~/.plexum/plugins/plexum-fabric-channel/plexum-fabric-channel-plugin # ~/.plexum/plugins/plexum-fabric-channel/manifest.json (initial; empty channels list) # ~/.local/bin/plexum-fabric-register (CLI for binding agents) # # Re-runnable: rebuilds binaries; overwrites manifest only if --reset-manifest. # Profile data (identity registry, channel configs) is never touched. # # Flags: # --profile
Override profile root (default ~/.plexum)
# --reset-manifest Overwrite the manifest's channels list with one
# derived from current channels/*.json (matches what
# the plugin advertises at runtime). Useful after
# adding/removing channels.
set -euo pipefail
REPO="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
PROFILE_DIR="${HOME}/.plexum"
USER_BIN="${HOME}/.local/bin"
RESET_MANIFEST=0
while [[ $# -gt 0 ]]; do
case "$1" in
--profile) PROFILE_DIR="$2"; shift 2 ;;
--reset-manifest) RESET_MANIFEST=1; shift ;;
-h|--help) sed -n '2,/^set -euo/p' "$0" | sed -n '/^#/p' | sed 's/^# \{0,1\}//'; exit 0 ;;
*) echo "unknown flag: $1" >&2; exit 2 ;;
esac
done
log() { printf '\033[1;34m[fabric-install]\033[0m %s\n' "$*"; }
command -v go >/dev/null || { echo "go not found on PATH" >&2; exit 1; }
PLUGIN_DIR="${PROFILE_DIR}/plugins/plexum-fabric-channel"
mkdir -p "${PLUGIN_DIR}" "${USER_BIN}"
cd "${REPO}"
VERSION="$(git describe --tags --always 2>/dev/null || echo dev)"
LDFLAGS="-X main.Version=${VERSION}"
log "building plexum-fabric-channel-plugin (v=${VERSION})"
CGO_ENABLED=0 go build -ldflags="${LDFLAGS}" \
-o "${PLUGIN_DIR}/plexum-fabric-channel-plugin" ./cmd/plexum-fabric-channel-plugin
log "building plexum-fabric-register"
CGO_ENABLED=0 go build -ldflags="${LDFLAGS}" \
-o "${USER_BIN}/plexum-fabric-register" ./cmd/plexum-fabric-register
MANIFEST_PATH="${PLUGIN_DIR}/manifest.json"
if [[ ! -f "${MANIFEST_PATH}" || ${RESET_MANIFEST} -eq 1 ]]; then
log "writing initial manifest at ${MANIFEST_PATH}"
# Build channels[] from any channels/*.json that name our plugin.
CHANNELS_DIR="${PROFILE_DIR}/channels"
CHANNELS_JSON='[]'
if [[ -d "${CHANNELS_DIR}" ]]; then
CHANNELS_JSON=$(python3 -c "
import json, os, sys
out = []
for f in sorted(os.listdir('${CHANNELS_DIR}')):
if not f.endswith('.json'): continue
try:
d = json.load(open(os.path.join('${CHANNELS_DIR}', f)))
except Exception:
continue
if d.get('plugin') == 'plexum-fabric-channel':
out.append({'name': f[:-5], 'outboundTool': 'send'})
print(json.dumps(out))
")
fi
cat > "${MANIFEST_PATH}" <