Switched to original server implementation & included server shim
This commit is contained in:
60
V3.1/build/hub-shim/install-server.sh
Normal file
60
V3.1/build/hub-shim/install-server.sh
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DEST_DIR="/opt/jibo-hub-shim"
|
||||
CONF_DIR="/etc/jibo-hub-shim"
|
||||
SERVICE_FILE_SRC="$SRC_DIR/systemd/jibo-hub-shim.service"
|
||||
SERVICE_FILE_DEST="/etc/systemd/system/jibo-hub-shim.service"
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "Please run as root (sudo)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$DEST_DIR" "$CONF_DIR"
|
||||
|
||||
# Copy code (keep node_modules on server side; do not copy any from build tree)
|
||||
rsync -a --delete \
|
||||
--exclude node_modules \
|
||||
--exclude .git \
|
||||
--exclude '*.log' \
|
||||
"$SRC_DIR/" "$DEST_DIR/"
|
||||
|
||||
# Install default config if missing
|
||||
if [[ ! -f "$CONF_DIR/config.json" ]]; then
|
||||
if [[ -f "$SRC_DIR/config.example.json" ]]; then
|
||||
cp "$SRC_DIR/config.example.json" "$CONF_DIR/config.json"
|
||||
elif [[ -f "$SRC_DIR/config.json" ]]; then
|
||||
cp "$SRC_DIR/config.json" "$CONF_DIR/config.json"
|
||||
else
|
||||
echo "No config.example.json found; create $CONF_DIR/config.json manually." >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install env file if missing
|
||||
if [[ ! -f "$CONF_DIR/jibo-hub-shim.env" ]]; then
|
||||
cp "$SRC_DIR/systemd/jibo-hub-shim.env.example" "$CONF_DIR/jibo-hub-shim.env"
|
||||
fi
|
||||
|
||||
# Install/refresh systemd unit
|
||||
install -m 0644 "$SERVICE_FILE_SRC" "$SERVICE_FILE_DEST"
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
# Install dependencies if npm exists
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
cd "$DEST_DIR"
|
||||
npm install --omit=dev
|
||||
else
|
||||
echo "npm not found; ensure the 'ws' module is available for node resolution." >&2
|
||||
fi
|
||||
|
||||
systemctl enable --now jibo-hub-shim.service
|
||||
|
||||
echo
|
||||
systemctl --no-pager --full status jibo-hub-shim.service || true
|
||||
|
||||
echo
|
||||
echo "Installed. Config: $CONF_DIR/config.json"
|
||||
echo "Logs: journalctl -u jibo-hub-shim -f"
|
||||
Reference in New Issue
Block a user