Add Unraid plugin package

This commit is contained in:
Mikei386
2026-06-22 22:15:33 +02:00
parent 37ddea08f4
commit 92434a945d
8 changed files with 268 additions and 3 deletions
@@ -0,0 +1,62 @@
#!/bin/bash
PLUGIN="u-navigator"
APP_DIR="/usr/local/emhttp/plugins/${PLUGIN}/app"
PID_FILE="/var/run/${PLUGIN}.pid"
LOG_FILE="/var/log/${PLUGIN}.log"
PORT="${U_NAV_PORT:-8088}"
ROOTS="${U_NAV_ROOTS:-/mnt/user}"
HOST="${U_NAV_HOST:-0.0.0.0}"
is_running() {
[[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null
}
start() {
if is_running; then
echo "${PLUGIN} is already running with PID $(cat "$PID_FILE")"
return 0
fi
if ! command -v node >/dev/null 2>&1; then
echo "node is required but was not found. Install/provide Node.js before starting ${PLUGIN}."
return 1
fi
mkdir -p "$(dirname "$PID_FILE")"
U_NAV_ROOTS="$ROOTS" U_NAV_HOST="$HOST" PORT="$PORT" nohup node "${APP_DIR}/server/server.js" >>"$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "${PLUGIN} started on ${HOST}:${PORT} with roots ${ROOTS}"
}
stop() {
if ! is_running; then
rm -f "$PID_FILE"
echo "${PLUGIN} is not running"
return 0
fi
kill "$(cat "$PID_FILE")" 2>/dev/null || true
rm -f "$PID_FILE"
echo "${PLUGIN} stopped"
}
status() {
if is_running; then
echo "${PLUGIN} is running with PID $(cat "$PID_FILE")"
else
echo "${PLUGIN} is not running"
return 1
fi
}
case "$1" in
start) start ;;
stop) stop ;;
restart) stop; start ;;
status) status ;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 2
;;
esac