First Commit
This commit is contained in:
commit
b451b84885
17 files changed
+387789
No files matched your search
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install edge Jetson counter + dashboard; disable legacy MQTT frigate-counter.
|
||||
# Run on the Jetson: sudo ./install-services.sh
|
||||
set -euo pipefail
|
||||
|
||||
INSTALL_DIR="${INSTALL_DIR:-/opt/jetson-counter}"
|
||||
VENV_DIR="${VENV_DIR:-/opt/jetson-counter/venv}"
|
||||
SERVICE_USER="${SERVICE_USER:-jetson}"
|
||||
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
echo "Run as root: sudo ./install-services.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "${INSTALL_DIR}/.env" ]]; then
|
||||
echo "Missing ${INSTALL_DIR}/.env"
|
||||
echo " cp ${INSTALL_DIR}/config.env.example ${INSTALL_DIR}/.env && nano ${INSTALL_DIR}/.env"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -x "${VENV_DIR}/bin/python" ]]; then
|
||||
echo "Missing venv: ${VENV_DIR}/bin/python"
|
||||
echo " sudo ./setup-venv.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sed -i 's/\r$//' "${INSTALL_DIR}/.env" 2>/dev/null || true
|
||||
|
||||
mkdir -p "${INSTALL_DIR}/.ultralytics" "${INSTALL_DIR}/.torch"
|
||||
chown -R "${SERVICE_USER}:${SERVICE_USER}" "${INSTALL_DIR}"
|
||||
|
||||
# Disable legacy MQTT counter (replace mode)
|
||||
for legacy in frigate-counter frigate-counter-dashboard; do
|
||||
if systemctl is-enabled "${legacy}" &>/dev/null; then
|
||||
systemctl disable --now "${legacy}" || true
|
||||
echo "Disabled legacy ${legacy}"
|
||||
fi
|
||||
done
|
||||
|
||||
for unit in jetson-counter jetson-counter-dashboard; do
|
||||
sed -e "s|/opt/jetson-counter|${INSTALL_DIR}|g" \
|
||||
-e "s|User=jetson|User=${SERVICE_USER}|g" \
|
||||
-e "s|Group=jetson|Group=${SERVICE_USER}|g" \
|
||||
"${INSTALL_DIR}/${unit}.service" > "/etc/systemd/system/${unit}.service"
|
||||
echo "Installed /etc/systemd/system/${unit}.service"
|
||||
done
|
||||
|
||||
chown -R "${SERVICE_USER}:${SERVICE_USER}" "${INSTALL_DIR}"
|
||||
|
||||
PYTHONNOUSERSITE=1 "${VENV_DIR}/bin/python" -c "
|
||||
from ultralytics import YOLO
|
||||
import torch
|
||||
print('import ok | cuda', torch.cuda.is_available())
|
||||
" || {
|
||||
echo "Import check failed — fix venv before starting services."
|
||||
exit 1
|
||||
}
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl reset-failed jetson-counter jetson-counter-dashboard 2>/dev/null || true
|
||||
systemctl enable jetson-counter jetson-counter-dashboard
|
||||
systemctl restart jetson-counter jetson-counter-dashboard
|
||||
|
||||
echo ""
|
||||
systemctl --no-pager status jetson-counter jetson-counter-dashboard || true
|
||||
echo ""
|
||||
echo "Logs: sudo journalctl -u jetson-counter -f"
|
||||
echo "Dashboard: http://$(hostname -I | awk '{print $1}'):5000"
|
||||
Reference in new issue
Block a user