mac ver
This commit is contained in:
1 parent
f7961b8e70
commit
f8357220fc
9 files changed
+197
-51
No files matched your search
@@ -6,11 +6,81 @@ set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BACKONE_REPO="${BACKONE_REPO:-$ROOT/../BackOne}"
|
||||
|
||||
if [[ "$(uname -s)" != "Linux" ]]; then
|
||||
echo "This script is Linux-only." >&2
|
||||
echo "On macOS, edit /Library/Application Support/BackOne/local.conf as valid JSON," >&2
|
||||
echo "then restart the BackOne daemon/app instead of using systemctl." >&2
|
||||
exit 1
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
CONF="/Library/Application Support/BackOne/local.conf"
|
||||
PORT="$(cat "/Library/Application Support/BackOne/backone.port" 2>/dev/null || echo 9993)"
|
||||
echo "macOS secure chat settings"
|
||||
echo ""
|
||||
|
||||
if [[ "${EUID}" -eq 0 ]]; then
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
from pathlib import Path
|
||||
path = Path("/Library/Application Support/BackOne/local.conf")
|
||||
cfg = json.loads(path.read_text())
|
||||
settings = cfg.setdefault("settings", {})
|
||||
settings["webhubBind"] = "overlay"
|
||||
settings["webhubAllowOverlayChat"] = True
|
||||
settings.setdefault("webhubPort", 9993)
|
||||
path.write_text(json.dumps(cfg, indent=2) + "\n")
|
||||
print(f"Updated {path}")
|
||||
print(" webhubBind = overlay")
|
||||
print(" webhubAllowOverlayChat = true")
|
||||
print(" webhubPort =", settings.get("webhubPort", 9993))
|
||||
PY
|
||||
echo ""
|
||||
echo "Restarting backone daemon..."
|
||||
pkill -x backone 2>/dev/null || true
|
||||
sleep 1
|
||||
"/Library/Application Support/BackOne/launch.sh" >/tmp/backone.log 2>&1 &
|
||||
sleep 2
|
||||
else
|
||||
echo "Run with sudo to apply overlay settings automatically:"
|
||||
echo " sudo $0"
|
||||
echo ""
|
||||
echo "Or verify ${CONF} contains:"
|
||||
echo ' "settings": {'
|
||||
echo ' "webhubBind": "overlay",'
|
||||
echo ' "webhubAllowOverlayChat": true'
|
||||
echo ' }'
|
||||
echo ""
|
||||
python3 - <<'PY' 2>/dev/null || true
|
||||
import json
|
||||
from pathlib import Path
|
||||
path = Path("/Library/Application Support/BackOne/local.conf")
|
||||
try:
|
||||
cfg = json.loads(path.read_text())
|
||||
settings = cfg.get("settings") or {}
|
||||
print("Current settings:")
|
||||
print(" webhubBind =", settings.get("webhubBind"))
|
||||
print(" webhubAllowOverlayChat =", settings.get("webhubAllowOverlayChat"))
|
||||
print(" webhubPort =", settings.get("webhubPort", 9993))
|
||||
if settings.get("webhubBind") not in (None, "", "overlay"):
|
||||
print("WARN: webhubBind should be overlay for cross-host chat on macOS")
|
||||
except Exception as exc:
|
||||
print(f"Could not parse {path}: {exc}")
|
||||
PY
|
||||
echo ""
|
||||
echo "Then restart the daemon:"
|
||||
echo ' sudo pkill -x backone'
|
||||
echo ' sudo "/Library/Application Support/BackOne/launch.sh" >/tmp/backone.log 2>&1 &'
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "Verifying listen address (port ${PORT})..."
|
||||
if command -v lsof >/dev/null 2>&1; then
|
||||
lsof -nP -iTCP -sTCP:LISTEN 2>/dev/null | rg ":${PORT} " || echo " WARN: nothing listening on port ${PORT}" >&2
|
||||
fi
|
||||
echo ""
|
||||
echo "Verifying overlay relay (no auth) on 127.0.0.1:${PORT}..."
|
||||
code="$(curl -s -o /dev/null -w '%{http_code}' -X POST -H 'Content-Type: application/json' \
|
||||
-d '{"networkId":"0000000000000000","senderId":"0000000000","senderName":"t","targetId":"0000000000","body":"t","at":1}' \
|
||||
"http://127.0.0.1:${PORT}/controller/comms/chat/relay")"
|
||||
echo " POST /controller/comms/chat/relay -> HTTP ${code}"
|
||||
if [[ "$code" != "200" ]]; then
|
||||
echo " WARN: relay no-auth check failed — peers may see connection errors" >&2
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "${EUID}" -ne 0 ]]; then
|
||||
|
||||
@@ -7,12 +7,21 @@ NETWORK_ID="${1:?network id required (16 hex chars)}"
|
||||
TARGET_ID="${2:?target peer id required (10 hex chars)}"
|
||||
MSG="${3:-ping from send-secure-chat-test.sh}"
|
||||
|
||||
OS="$(uname -s)"
|
||||
if [[ "$OS" == "Darwin" ]]; then
|
||||
SERVICE_HOME="/Library/Application Support/BackOne"
|
||||
DEFAULT_HUB_PORT=9993
|
||||
else
|
||||
SERVICE_HOME="/var/lib/backone"
|
||||
DEFAULT_HUB_PORT=9994
|
||||
fi
|
||||
|
||||
TOKEN="$(
|
||||
cat ~/.backone-local-auth 2>/dev/null \
|
||||
|| cat ~/.backOneAuthToken 2>/dev/null \
|
||||
|| sudo cat /var/lib/backone/authtoken.secret
|
||||
|| sudo cat "${SERVICE_HOME}/authtoken.secret"
|
||||
)"
|
||||
PORT="$(cat /var/lib/backone/backone.port 2>/dev/null || echo 9993)"
|
||||
PORT="$(cat "${SERVICE_HOME}/backone.port" 2>/dev/null || echo 9993)"
|
||||
|
||||
MY_ID="$(
|
||||
curl -sf -H "X-ZT1-Auth: $TOKEN" "http://127.0.0.1:${PORT}/status" \
|
||||
@@ -24,8 +33,12 @@ HUB_PORT="$(
|
||||
| jq -r '.webhubPort // empty' 2>/dev/null || true
|
||||
)"
|
||||
if [[ -z "$HUB_PORT" ]]; then
|
||||
if ss -tln 2>/dev/null | grep -q '127.0.0.1:9994'; then
|
||||
HUB_PORT=9994
|
||||
if [[ "$OS" == "Darwin" ]]; then
|
||||
if nc -z 127.0.0.1 "$DEFAULT_HUB_PORT" 2>/dev/null; then
|
||||
HUB_PORT="$DEFAULT_HUB_PORT"
|
||||
fi
|
||||
elif ss -tln 2>/dev/null | rg -q "127\\.0\\.0\\.1:${DEFAULT_HUB_PORT}"; then
|
||||
HUB_PORT="$DEFAULT_HUB_PORT"
|
||||
else
|
||||
echo "Could not detect webhub port. Is backone-webhub running?" >&2
|
||||
exit 1
|
||||
@@ -52,12 +65,12 @@ else
|
||||
echo "Peer VL1: not in /peer list"
|
||||
fi
|
||||
|
||||
if ! cmp -s /usr/sbin/backone "${BACKONE_REPO:-$HOME/git/BackOne}/backone" 2>/dev/null; then
|
||||
if [[ "$OS" != "Darwin" ]] && ! cmp -s /usr/sbin/backone "${BACKONE_REPO:-$HOME/git/BackOne}/backone" 2>/dev/null; then
|
||||
echo ""
|
||||
echo "WARN: system backone is not the patched build — run:" >&2
|
||||
echo " sudo ./scripts/install-secure-chat-deps.sh" >&2
|
||||
fi
|
||||
if ! cmp -s /usr/lib/backone/addons/webhub/backone-webhub \
|
||||
if [[ "$OS" != "Darwin" ]] && ! cmp -s /usr/lib/backone/addons/webhub/backone-webhub \
|
||||
"${BACKONE_REPO:-$HOME/git/BackOne}/addons/webhub/backone-webhub" 2>/dev/null; then
|
||||
echo "WARN: system webhub is outdated — run install script above" >&2
|
||||
fi
|
||||
@@ -74,7 +87,11 @@ for candidate in /usr/bin/python3 python3; do
|
||||
done
|
||||
if [[ -z "$PYTHON" ]]; then
|
||||
echo "python3-websockets is required. Install with:" >&2
|
||||
echo " sudo apt install python3-websockets" >&2
|
||||
if [[ "$OS" == "Darwin" ]]; then
|
||||
echo " python3 -m pip install websockets" >&2
|
||||
else
|
||||
echo " sudo apt install python3-websockets" >&2
|
||||
fi
|
||||
echo " # or: pip install websockets (outside the BackOneUI venv)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user