-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraidman.plg
More file actions
203 lines (173 loc) · 8.56 KB
/
raidman.plg
File metadata and controls
203 lines (173 loc) · 8.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "raidman">
<!ENTITY author "Selim">
<!ENTITY version "2026.02.08">
<!ENTITY launch "Settings/raidman">
<!ENTITY gitURL "https://github.com/windium/raidman-plugin">
<!ENTITY pluginURL "https://raw.githubusercontent.com/windium/raidman-plugin/main/raidman.plg">
]>
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;" icon="icon.png" min="6.9.0" support="link">
<CHANGES>
<CHANGE>2026.02.07 - Fix: Removed legacy API key support and verbose key loading logs. Rebuilt binary for Linux.</CHANGE>
<CHANGE>2026.01.25 - Refactor: Removed WebView-based xterm.js terminal. Native terminal now connects directly to WebSocket backend.</CHANGE>
<CHANGE>2026.01.09 - Major Refactor: Backend rewritten in modular Go architecture (Standard Layout). Hybrid Array polling added.</CHANGE>
<CHANGE>2026.01.06 - Security: All /raidman/ routes now require x-api-key header authentication, including noVNC static files.</CHANGE>
<CHANGE>2026.01.01L - Fix: Keep .sh extension for notification agent to match Unraid convention.</CHANGE>
<CHANGE>2026.01.01k - Improve: Enhanced notification agent with fallback defaults, better logging, and hostname/timestamp support.</CHANGE>
<CHANGE>2026.01.01j - Fix: Created legacy Raidman.sh script with environment variables instead of positional arguments.</CHANGE>
<CHANGE>2026.01.01i - Fix: Improved notification agent script structure and logging for better execution.</CHANGE>
<CHANGE>2026.01.01h - Fix: Restored {0} placeholder required by Unraid notification system.</CHANGE>
<CHANGE>2026.01.01g - Fix: Removed invalid placeholder in Notification Agent script that caused execution failure.</CHANGE>
<CHANGE>2026.01.01f - Fix: Restored missing XML declaration header in Notification Agent file.</CHANGE>
<CHANGE>2026.01.01d - Fix: Replaced heredoc with safe echo calls in Notification Agent to prevent syntax errors.</CHANGE>
<CHANGE>2026.01.01c - Fix: Improved Notification Agent JSON payload construction to prevent empty requests.</CHANGE>
<CHANGE>2026.01.01b - Fix: Notification Agent now correctly uses Environment Variables instead of arguments.</CHANGE>
<CHANGE>2026.01.01a - Debug: Added extensive logging to Notification Agent for troubleshooting.</CHANGE>
<CHANGE>2026.01.01 - Fix: Updated Notification Agent format to standard XML structure.</CHANGE>
<CHANGE>2025.12.30n - Feat: Added Native Notification Agent (Expo Push).</CHANGE>
<CHANGE>2025.12.30m - Feat: Added Docker Log streaming via WebSocket.</CHANGE>
<CHANGE>2025.12.30l - Feat: Added VM VNC (NoVNC) and VM Log support.</CHANGE>
<CHANGE>2025.12.30k - Security Fix: Added No-Cache headers to prevent WebView caching of sensitive API keys.</CHANGE>
<CHANGE>2025.12.30j - Security: Enforce x-api-key via Headers only. Inject key into index.html securely.</CHANGE>
<CHANGE>2025.12.30i - Fix Auth: Added 'allow all' to Nginx config to bypass login redirect (simulating /graphql).</CHANGE>
<CHANGE>2025.12.30h - Revert: Switch back to Nginx + TCP. Added Self-Healing Monitor for config peristence.</CHANGE>
<CHANGE>2025.12.30g - Fix XML Header: Restored missing XML declaration.</CHANGE>
<CHANGE>2025.12.30f - Refactor: Use Native Unraid /logterminal Proxy Unix Socket. Dropped custom Nginx config.</CHANGE>
<CHANGE>2025.12.30e - Fix Nginx Config: Properly include Nginx config in locations.conf.</CHANGE>
<CHANGE>2025.12.30d - Debugging: Inspecting Nginx servers.conf.</CHANGE>
<CHANGE>2025.12.30c - Debugging: Expanded Nginx environment checks.</CHANGE>
<CHANGE>2025.12.30b - Debugging: Added Nginx verification in install script.</CHANGE>
<CHANGE>2025.12.30 - Fix Nginx 404: Added redirect for /raidman and verified config.</CHANGE>
<CHANGE>2025.12.29a - Fix 502 Error: Added logging and verified binary.</CHANGE>
<CHANGE>2025.12.29 - Initial Release with Unraid API Compatible Security (x-api-key validation).</CHANGE>
</CHANGES>
<!--
The 'source' file.
-->
<FILE Name="/boot/config/plugins/&name;/raidman.conf">
<URL>https://raw.githubusercontent.com/windium/raidman-plugin/main/raidman.conf</URL>
</FILE>
<FILE Name="/boot/config/plugins/&name;/raidman">
<URL>https://raw.githubusercontent.com/windium/raidman-plugin/main/raidman</URL>
</FILE>
<FILE Name="/boot/config/plugins/&name;/raidman.page">
<URL>https://raw.githubusercontent.com/windium/raidman-plugin/main/src/raidman.page</URL>
</FILE>
<FILE Name="/boot/config/plugins/&name;/icon.png">
<URL>https://raw.githubusercontent.com/windium/raidman-plugin/main/icon.png</URL>
</FILE>
<!--
The 'install' script.
-->
<FILE Run="/bin/bash">
<INLINE>
<![CDATA[
echo "Installing Raidman..."
echo "Creating directories..."
# Create directory
mkdir -p /usr/local/emhttp/plugins/raidman
echo "Copying binary..."
# Copy binary
cp /boot/config/plugins/raidman/raidman /usr/local/emhttp/plugins/raidman/raidman
chmod +x /usr/local/emhttp/plugins/raidman/raidman
cp /boot/config/plugins/raidman/icon.png /usr/local/emhttp/plugins/raidman/icon.png
cp /boot/config/plugins/raidman/raidman.page /usr/local/emhttp/plugins/raidman/raidman.page
# -------------------------------------------------
# Nginx Configuration
# -------------------------------------------------
echo "Configuring Nginx..."
cp /boot/config/plugins/raidman/raidman.conf /etc/nginx/conf.d/raidman.conf
# Function to inject config
inject_nginx() {
if !grep -q "include /etc/nginx/conf.d/raidman.conf;" /etc/nginx/conf.d/locations.conf; then
echo "Injecting Raidman config into locations.conf..."
# Ensure newline
echo "" >> /etc/nginx/conf.d/locations.conf
echo "include /etc/nginx/conf.d/raidman.conf;" >> /etc/nginx/conf.d/locations.conf
/usr/sbin/nginx -s reload
fi
}
inject_nginx
# -------------------------------------------------
# Download noVNC from Official GitHub Releases
# -------------------------------------------------
echo "Downloading noVNC..."
NOVNC_VERSION="1.6.0"
NOVNC_DIR="/usr/local/emhttp/plugins/raidman/web/novnc"
# Create web directory
mkdir -p /usr/local/emhttp/plugins/raidman/web
# Download and extract noVNC if not already present
if [ ! -d "$NOVNC_DIR" ]; then
# Check for existing noVNC in dynamix.vm.manager
STOCK_NOVNC="/usr/local/emhttp/plugins/dynamix.vm.manager/novnc"
if [ -d "$STOCK_NOVNC" ]; then
echo "Found local noVNC in dynamix.vm.manager, copying..."
cp -r "$STOCK_NOVNC" "$NOVNC_DIR"
echo "noVNC copied from local system."
else
echo "Fetching noVNC v${NOVNC_VERSION}..."
cd /tmp
wget -q "https://github.com/novnc/noVNC/archive/refs/tags/v${NOVNC_VERSION}.tar.gz" -O novnc.tar.gz
# Verify Checksum (v1.6.0)
# Note: This checksum is for the auto-generated tarball from GitHub.
# If GitHub changes compression, this might break.
# Ideally we should host our own verifiable tarball.
# For now, we log the sum for audit.
echo "Calculated Checksum: $(sha256sum novnc.tar.gz | awk '{print $1}')"
tar -xzf novnc.tar.gz
mv "noVNC-${NOVNC_VERSION}" "$NOVNC_DIR"
rm novnc.tar.gz
echo "noVNC installed successfully"
fi
else
echo "noVNC already present, skipping download"
fi
# -------------------------------------------------
# Start Service (Bound to Localhost TCP)
# -------------------------------------------------
echo "Starting Raidman Service..."
# Kill any existing instance
killall raidman 2>/dev/null
# Start strict
# We use a subshell to prevent hanging the console
(
/usr/local/emhttp/plugins/raidman/raidman -host 127.0.0.1 -port 9876 > /var/log/raidman.log 2>&1
) &
PID=$!
echo $PID > /var/run/raidman.pid
echo "Raidman started with PID $PID"
echo ""
echo "----------------------------------------------------"
echo " raidman has been installed."
echo " Copyright 2025, Selim;"
echo " Version: 2026.01.06;"
echo "----------------------------------------------------"
echo ""
]]>
</INLINE>
</FILE>
<!--
The 'remove' script.
-->
<FILE Run="/bin/bash" Method="remove">
<INLINE>
<![CDATA[
echo "----------------------------------------------------"
echo " raidman has been uninstalled."
echo "----------------------------------------------------"
echo ""
# Kill process
killall raidman 2>/dev/null
# Clean up Nginx configuration
rm -f /etc/nginx/conf.d/raidman.conf
sed -i '\#include /etc/nginx/conf.d/raidman.conf;#d' /etc/nginx/conf.d/locations.conf
/usr/sbin/nginx -s reload
# Remove files
rm -rf /usr/local/emhttp/plugins/raidman
# Note: We do NOT remove /boot/config/plugins/raidman to preserve user configuration.
# If you wish to fully remove it, please delete that directory manually.
]]>
</INLINE>
</FILE>
</PLUGIN>