Add Unraid plugin package
This commit is contained in:
@@ -15,7 +15,41 @@ U-Navigator ist als Unraid-Plugin machbar. Empfohlen wird ein hybrider Aufbau au
|
||||
|
||||
Naechster sinnvoller Schritt:
|
||||
|
||||
Unraid-Plugin-Paketierung fuer die bestehende Web-App und das Backend.
|
||||
Go-Backend oder gebuendelte Runtime, damit das Plugin nicht mehr von einer vorhandenen Node.js-Installation abhaengt.
|
||||
|
||||
## Unraid Plugin installieren
|
||||
|
||||
Plugin-URL:
|
||||
|
||||
```text
|
||||
https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg
|
||||
```
|
||||
|
||||
Installation per Unraid Terminal:
|
||||
|
||||
```sh
|
||||
installplg https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg
|
||||
```
|
||||
|
||||
Oder im WebGUI:
|
||||
|
||||
```text
|
||||
Plugins -> Install Plugin -> URL einfuegen -> Install
|
||||
```
|
||||
|
||||
Danach starten:
|
||||
|
||||
```sh
|
||||
rc.u-navigator start
|
||||
```
|
||||
|
||||
Status pruefen:
|
||||
|
||||
```sh
|
||||
rc.u-navigator status
|
||||
```
|
||||
|
||||
Wichtig: Dieser erste Plugin-Spike benoetigt `node` auf dem Unraid-System. Falls `rc.u-navigator start` meldet, dass Node.js fehlt, muss als naechster Schritt das Backend als Go-Binary gebaut oder Node.js separat bereitgestellt werden.
|
||||
|
||||
## Lokal starten
|
||||
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
PLUGIN="u-navigator"
|
||||
VERSION="0.1.0"
|
||||
PKG_DIR="packages"
|
||||
WORK_DIR=".plugin-build"
|
||||
PKG_NAME="${PLUGIN}-${VERSION}.tgz"
|
||||
|
||||
rm -rf "$WORK_DIR"
|
||||
mkdir -p "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/app" "$PKG_DIR"
|
||||
|
||||
cp -R plugin-root/usr "$WORK_DIR/"
|
||||
cp package.json "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/app/"
|
||||
cp -R public "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/app/"
|
||||
cp -R server "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/app/"
|
||||
find "$WORK_DIR" -name "*.test.js" -delete
|
||||
chmod +x "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/scripts/rc.u-navigator"
|
||||
|
||||
tar -czf "$PKG_DIR/$PKG_NAME" -C "$WORK_DIR" usr
|
||||
rm -rf "$WORK_DIR"
|
||||
|
||||
MD5="$(md5 -q "$PKG_DIR/$PKG_NAME" 2>/dev/null || md5sum "$PKG_DIR/$PKG_NAME" | awk '{print $1}')"
|
||||
sed "s/__VERSION__/${VERSION}/g; s/__MD5__/${MD5}/g" u-navigator.plg.in > u-navigator.plg
|
||||
|
||||
echo "Built $PKG_DIR/$PKG_NAME"
|
||||
echo "MD5 $MD5"
|
||||
Binary file not shown.
@@ -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
|
||||
+3
-2
@@ -226,9 +226,10 @@ function statusError(status, message) {
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
const port = Number(process.env.PORT || 8088);
|
||||
const host = process.env.U_NAV_HOST || process.env.HOST || '127.0.0.1';
|
||||
createApp({ env: process.env }).then((app) => {
|
||||
http.createServer(app).listen(port, '127.0.0.1', () => {
|
||||
console.log(`U-Navigator listening on http://127.0.0.1:${port}`);
|
||||
http.createServer(app).listen(port, host, () => {
|
||||
console.log(`U-Navigator listening on http://${host}:${port}`);
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error(error.message);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "u-navigator">
|
||||
<!ENTITY author "michael">
|
||||
<!ENTITY version "0.1.0">
|
||||
<!ENTITY package "&name;-&version;.tgz">
|
||||
]>
|
||||
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
|
||||
|
||||
<CHANGES>
|
||||
### &version;
|
||||
- Initial U-Navigator plugin spike.
|
||||
- Installs WebGUI page, Node.js prototype backend, in-app window manager and drag-and-drop file navigator.
|
||||
</CHANGES>
|
||||
|
||||
<FILE Name="/boot/config/plugins/&name;/&package;">
|
||||
<URL>https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package;</URL>
|
||||
<MD5>9d6e248cb70c803f04bf491b06520764</MD5>
|
||||
</FILE>
|
||||
|
||||
<FILE Run="/bin/bash">
|
||||
<INLINE>
|
||||
mkdir -p /boot/config/plugins/&name;
|
||||
tar -xzf /boot/config/plugins/&name;/&package; -C /
|
||||
chmod +x /usr/local/emhttp/plugins/&name;/scripts/rc.u-navigator
|
||||
ln -sf /usr/local/emhttp/plugins/&name;/scripts/rc.u-navigator /usr/local/sbin/rc.u-navigator
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------"
|
||||
echo " &name; &version; has been installed."
|
||||
echo ""
|
||||
echo " Start: rc.u-navigator start"
|
||||
echo " Stop: rc.u-navigator stop"
|
||||
echo " Status: rc.u-navigator status"
|
||||
echo ""
|
||||
echo " Note: This prototype requires Node.js to be available on Unraid."
|
||||
echo "-----------------------------------------------------------"
|
||||
echo ""
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<FILE Run="/bin/bash" Method="remove">
|
||||
<INLINE>
|
||||
rc.u-navigator stop 2>/dev/null || true
|
||||
rm -f /usr/local/sbin/rc.u-navigator
|
||||
rm -rf /usr/local/emhttp/plugins/&name;
|
||||
rm -rf /boot/config/plugins/&name;
|
||||
rm -f /var/run/&name;.pid
|
||||
echo "&name; has been removed."
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
</PLUGIN>
|
||||
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "u-navigator">
|
||||
<!ENTITY author "michael">
|
||||
<!ENTITY version "__VERSION__">
|
||||
<!ENTITY package "&name;-&version;.tgz">
|
||||
]>
|
||||
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
|
||||
|
||||
<CHANGES>
|
||||
### &version;
|
||||
- Initial U-Navigator plugin spike.
|
||||
- Installs WebGUI page, Node.js prototype backend, in-app window manager and drag-and-drop file navigator.
|
||||
</CHANGES>
|
||||
|
||||
<FILE Name="/boot/config/plugins/&name;/&package;">
|
||||
<URL>https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package;</URL>
|
||||
<MD5>__MD5__</MD5>
|
||||
</FILE>
|
||||
|
||||
<FILE Run="/bin/bash">
|
||||
<INLINE>
|
||||
mkdir -p /boot/config/plugins/&name;
|
||||
tar -xzf /boot/config/plugins/&name;/&package; -C /
|
||||
chmod +x /usr/local/emhttp/plugins/&name;/scripts/rc.u-navigator
|
||||
ln -sf /usr/local/emhttp/plugins/&name;/scripts/rc.u-navigator /usr/local/sbin/rc.u-navigator
|
||||
echo ""
|
||||
echo "-----------------------------------------------------------"
|
||||
echo " &name; &version; has been installed."
|
||||
echo ""
|
||||
echo " Start: rc.u-navigator start"
|
||||
echo " Stop: rc.u-navigator stop"
|
||||
echo " Status: rc.u-navigator status"
|
||||
echo ""
|
||||
echo " Note: This prototype requires Node.js to be available on Unraid."
|
||||
echo "-----------------------------------------------------------"
|
||||
echo ""
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<FILE Run="/bin/bash" Method="remove">
|
||||
<INLINE>
|
||||
rc.u-navigator stop 2>/dev/null || true
|
||||
rm -f /usr/local/sbin/rc.u-navigator
|
||||
rm -rf /usr/local/emhttp/plugins/&name;
|
||||
rm -rf /boot/config/plugins/&name;
|
||||
rm -f /var/run/&name;.pid
|
||||
echo "&name; has been removed."
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
</PLUGIN>
|
||||
Reference in New Issue
Block a user