#!/bin/sh # Registers usher as a Firefox/LibreWolf native messaging host for the # current user on Linux. Installs to ~/.local/bin and registers the # manifest in ~/.librewolf/native-messaging-hosts and # ~/.mozilla/native-messaging-hosts. No sudo required. # # POSIX sh — no bashisms. Runs on any minimal Linux base. # After running, restart LibreWolf and load the extension from # about:debugging to verify usher connects (check the Browser Console: # Ctrl+Shift+J). set -eu HOST_NAME="com.vestibule.usher" EXT_ID="vestibule@vestibule.kiosk" SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) PROJECT_ROOT=$(cd "${SCRIPT_DIR}/.." && pwd) HELPER_BIN="${PROJECT_ROOT}/helper/target/release/usher" if [ ! -x "${HELPER_BIN}" ]; then echo "error: usher binary not found at ${HELPER_BIN}" >&2 echo " build it first: (cd ${PROJECT_ROOT}/helper && cargo build --release)" >&2 exit 1 fi # Install binary to ~/.local/bin (no sudo required) TARGET_BIN="${HOME}/.local/bin/usher" BIN_DIR=$(dirname "${TARGET_BIN}") mkdir -p "${BIN_DIR}" install -m 0755 "${HELPER_BIN}" "${TARGET_BIN}" echo "installed binary: ${TARGET_BIN}" # Substitute the absolute install path into the manifest template. # Paths travel as argv, never interpolated into source (SEI CERT # IDS03-ENUM; a path containing a quote must not alter the program). MANIFEST_TEMPLATE="${PROJECT_ROOT}/config/com.vestibule.usher.linux.json" GENERATED_MANIFEST=$(mktemp) trap 'rm -f "${GENERATED_MANIFEST}"' EXIT INT TERM python3 - "${MANIFEST_TEMPLATE}" "${GENERATED_MANIFEST}" "${TARGET_BIN}" <<'PYEOF' import json import sys template, generated, target_bin = sys.argv[1:4] with open(template) as f: manifest = json.load(f) manifest["path"] = target_bin with open(generated, "w") as f: json.dump(manifest, f, indent=2) PYEOF # Install manifest into both LibreWolf and Mozilla native-messaging-hosts # directories. LibreWolf reads from ~/.librewolf, vanilla Firefox from # ~/.mozilla. Covering both is harmless and future-proof. for DIR in \ "${HOME}/.librewolf/native-messaging-hosts" \ "${HOME}/.mozilla/native-messaging-hosts"; do mkdir -p "${DIR}" install -m 0644 "${GENERATED_MANIFEST}" "${DIR}/${HOST_NAME}.json" echo "installed manifest: ${DIR}/${HOST_NAME}.json" done echo echo "Done. Restart LibreWolf, load the extension from about:debugging," echo "and check the Browser Console (Ctrl+Shift+J) for '[vestibule] usher hello'."