Add Unraid plugin package
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
Menu="Tools"
|
||||
Title="U-Navigator"
|
||||
Icon="folder-open"
|
||||
---
|
||||
<?PHP
|
||||
$port = 8088;
|
||||
?>
|
||||
<style>
|
||||
.u-navigator-plugin {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
min-height: calc(100vh - 170px);
|
||||
}
|
||||
|
||||
.u-navigator-plugin iframe {
|
||||
border: 1px solid var(--border-color, #d2d8df);
|
||||
border-radius: 8px;
|
||||
min-height: calc(100vh - 190px);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.u-navigator-plugin .notice {
|
||||
color: var(--text-muted, #677);
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<div class="u-navigator-plugin">
|
||||
<p class="notice">
|
||||
U-Navigator laeuft als lokaler Dienst auf Port <?=htmlspecialchars($port)?>.
|
||||
Falls der Rahmen leer bleibt, pruefe den Dienst mit <code>rc.u-navigator status</code>.
|
||||
</p>
|
||||
<iframe id="u-navigator-frame" title="U-Navigator"></iframe>
|
||||
</div>
|
||||
<script>
|
||||
(() => {
|
||||
const frame = document.getElementById('u-navigator-frame');
|
||||
frame.src = `${window.location.protocol}//${window.location.hostname}:<?=htmlspecialchars($port)?>/`;
|
||||
})();
|
||||
</script>
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user