-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnetbird.plg
More file actions
300 lines (238 loc) · 9.89 KB
/
Copy pathnetbird.plg
File metadata and controls
300 lines (238 loc) · 9.89 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "netbird">
<!ENTITY author "NetBird">
<!ENTITY version "2026.06.22.2046">
<!ENTITY launch "Settings/Netbird">
<!ENTITY gitUser "netbirdio">
<!ENTITY gitRepo "netbird-unraid">
<!ENTITY pluginURL "https://raw.githubusercontent.com/&gitUser;/&gitRepo;/main/plugin/netbird.plg">
<!ENTITY pluginLOC "/boot/config/plugins/&name;">
<!ENTITY emhttpLOC "/usr/local/emhttp/plugins/&name;">
<!-- NetBird upstream binary -->
<!ENTITY netbirdVer "0.74.0">
<!ENTITY netbirdFile "netbird_&netbirdVer;_linux_amd64.tar.gz">
<!ENTITY netbirdURL "https://github.com/netbirdio/netbird/releases/download/v&netbirdVer;/&netbirdFile;">
<!ENTITY netbirdSHA256 "3eb409003d891e4e4867f8157103dc388b92d8ac7ec7d26b5596a234557b307e">
<!-- Plugin support package (built from src/) -->
<!ENTITY pkgName "unraid-netbird-utils">
<!ENTITY pkgFile "&pkgName;-&version;-noarch-1.txz">
<!ENTITY pkgURL "https://github.com/&gitUser;/&gitRepo;/releases/download/&version;/&pkgFile;">
<!ENTITY pkgSHA256 "bbbeb611bd8ec107921c054f49f86362bfd48158328649d5b22a4dd7605a3f41">
]>
<PLUGIN
name="&name;"
author="&author;"
version="&version;"
launch="&launch;"
pluginURL="&pluginURL;"
min="7.0.0"
support="https://github.com/&gitUser;/&gitRepo;/issues"
project="https://github.com/&gitUser;/&gitRepo;"
>
<CHANGES>
<![CDATA[
### 2026.06.22.2046
**Maintenance**
- chore: update NetBird to 0.73.2 (#19)
### 2026.06.22.1943
**Bug Fixes**
- fix: reliably detect and cycle the NetBird daemon on stop/restart (#18)
- fix: restart NetBird daemon on update so the dashboard shows the new version (#16)
- fix: render the dashboard widget as a grid tile so it aligns and can be moved (#17)
### 2026.06.22.1415
**Maintenance**
- chore: update NetBird to 0.73.0 (#13)
### 2026.06.14.1644
**Fixes**
- ci: use GH\_PAT for NetBird auto-bump PRs (#11)
**New Features**
- feat: add release publishing and changelog automation (#7)
**Maintenance**
- chore: update NetBird to 0.72.4 (#12)
### 2026.05.27.1742
- Update NetBird to 0.71.4.
### 2026.05.26.0027
- Update NetBird to 0.71.4.
### 2026.05.22.2255
- Update NetBird to 0.71.4.
### 2026.05.22.2030
- Update NetBird to 0.71.4.
### 2026.05.22.1837
- Update NetBird to 0.71.4.
### 2026.05.22.0312
- Update NetBird to 0.71.4.
### 2026.05.22.0233
- Update NetBird to 0.71.4.
### 2026.05.16.0001
- Initial preview release. NetBird 0.71.2 running natively on Unraid as a system plugin.
Older releases: https://github.com/netbirdio/netbird-unraid/releases
]]>
</CHANGES>
<!--
================================================================================
Fetch NetBird binary tarball
================================================================================
-->
<FILE Name="&pluginLOC;/&netbirdFile;">
<URL>&netbirdURL;</URL>
<SHA256>&netbirdSHA256;</SHA256>
</FILE>
<!--
================================================================================
Fetch plugin support package (pages, rc.d script, etc.)
================================================================================
-->
<FILE Name="&pluginLOC;/&pkgFile;">
<URL>&pkgURL;</URL>
<SHA256>&pkgSHA256;</SHA256>
</FILE>
<!--
================================================================================
Install script
================================================================================
-->
<FILE Run="/bin/bash">
<INLINE>
<![CDATA[
# Clean any prior in-RAM install of plugin pages
if [ -d "/usr/local/emhttp/plugins/netbird" ]; then
rm -rf /usr/local/emhttp/plugins/netbird
fi
# Install plugin support package (pages, rc.d script, default config, etc.)
upgradepkg --install-new /boot/config/plugins/netbird/unraid-netbird-utils-]]>&version;<![CDATA[-noarch-1.txz
# Extract NetBird upstream binary into /usr/local/sbin
mkdir -p /usr/local/sbin
tar -xzf /boot/config/plugins/netbird/]]>&netbirdFile;<![CDATA[ -C /tmp/
install -m 0755 /tmp/netbird /usr/local/sbin/netbird
rm -f /tmp/netbird /tmp/LICENSE /tmp/README.md
rm -rf /tmp/LICENSES
# Persist NetBird's two state dirs on the USB flash via symlinks.
# NetBird writes config/profile data to /etc/netbird and runtime state to /var/lib/netbird.
mkdir -p /boot/config/plugins/netbird/etc
mkdir -p /boot/config/plugins/netbird/lib
# Make sure target paths are clear, then link them
[ -L /etc/netbird ] && rm -f /etc/netbird
[ -d /etc/netbird ] && rm -rf /etc/netbird
ln -s /boot/config/plugins/netbird/etc /etc/netbird
[ -L /var/lib/netbird ] && rm -f /var/lib/netbird
[ -d /var/lib/netbird ] && rm -rf /var/lib/netbird
ln -s /boot/config/plugins/netbird/lib /var/lib/netbird
# Exclude state dir from Unraid Connect flash backup (state can include auth tokens)
echo "lib" >> /boot/config/plugins/netbird/.gitignore
echo "etc/.cache" >> /boot/config/plugins/netbird/.gitignore
# Add wt0 to Unraid's nginx include list so the WebGUI binds to the NetBird IP.
NEC=/boot/config/network-extra.cfg
if [ -f "$NEC" ] && grep -q '^include_interfaces=' "$NEC" ; then
if ! grep -q 'wt0' "$NEC" ; then
sed -i 's/^include_interfaces="\(.*\)"/include_interfaces="\1 wt0"/' "$NEC"
sed -i 's/include_interfaces=" /include_interfaces="/' "$NEC"
echo " added wt0 to existing include_interfaces in $NEC"
fi
else
cat > "$NEC" <<NEOF
include_interfaces="wt0"
exclude_interfaces=""
NEOF
echo " wrote $NEC with include_interfaces=\"wt0\""
fi
# Restart the daemon synchronously (waits for the socket), then reload nginx as
# soon as wt0 appears (so the WebGUI binds to the NetBird IP and is reachable
# from other peers). "restart" (not "start") matters on upgrades: the old daemon
# is still running the previous binary, so a plain "start" would no-op on it and
# `netbird status` would keep reporting the old version until the next reboot.
# stop is a safe no-op on a clean install where nothing is running yet.
/etc/rc.d/rc.netbird restart
(
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
if ip -4 addr show wt0 >/dev/null 2>&1; then
/etc/rc.d/rc.nginx reload >/dev/null 2>&1
exit 0
fi
sleep 2
done
) >/dev/null 2>&1 </dev/null &
disown 2>/dev/null || true
# Clean up older versions on flash
rm -f $(ls /boot/config/plugins/netbird/unraid-netbird-utils-*.txz 2>/dev/null | grep -v ']]>&version;<![CDATA[')
rm -f $(ls /boot/config/plugins/netbird/netbird_*_linux_amd64.tar.gz 2>/dev/null | grep -v ']]>&netbirdFile;<![CDATA[')
# Flash-backup safety warning: NetBird's state dir holds the WireGuard
# private key, so if it ended up in Unraid Connect's flash backup it's a
# credential leak risk.
if [ -d "/boot/.git" ]; then
if git --git-dir /boot/.git log --all --name-only --diff-filter=A -- config/plugins/netbird/lib/ 2>/dev/null | grep -q . ; then
echo "******************************"
echo "* WARNING *"
echo "******************************"
echo ""
echo "The NetBird state directory has been backed up to Unraid Connect via Flash backup."
echo ""
echo "To remove this backup:"
echo " 1. Settings -> Management Access"
echo " 2. Under Unraid Connect, deactivate flash backup (delete cloud copy)"
echo " 3. Reactivate flash backup"
/usr/local/emhttp/webGui/scripts/notify -l '/Settings/ManagementAccess' -i 'alert' -e 'NetBird State' -s 'NetBird state backed up to Unraid Connect.' -d 'The NetBird state directory has been backed up to Unraid Connect. This is a potential security risk. From the Management Settings page, deactivate flash backup and delete cloud backups, then reactivate flash backup.'
fi
fi
echo ""
echo "----------------------------------------------------"
echo " NetBird ]]>&netbirdVer;<![CDATA[ has been installed."
echo " Plugin version: ]]>&version;<![CDATA["
echo "----------------------------------------------------"
echo ""
]]>
</INLINE>
</FILE>
<!--
================================================================================
Remove script
================================================================================
-->
<FILE Run="/bin/bash" Method="remove">
<INLINE>
<![CDATA[
# Stop the daemon (graceful), then make sure nothing lingers
/etc/rc.d/rc.netbird stop 2>/dev/null
/usr/local/sbin/netbird down >/dev/null 2>&1
pkill -f '/usr/local/sbin/netbird service run' 2>/dev/null
sleep 1
pkill -9 -f '/usr/local/sbin/netbird service run' 2>/dev/null
rm -f /var/run/netbird.sock /var/run/netbird.pid
# Tear down the WireGuard interface if it's still up
ip link delete wt0 2>/dev/null
# Remove binary (default path plus any stray copy still on PATH)
rm -f /usr/local/sbin/netbird
for b in $(command -v netbird 2>/dev/null); do rm -f "$b"; done
hash -r 2>/dev/null
# Remove plugin package
removepkg unraid-netbird-utils 2>/dev/null
# Drop persistence symlinks (leaves /boot/config/plugins/netbird intact so
# the user can reinstall without losing their NetBird identity)
rm -f /etc/netbird
rm -f /var/lib/netbird
# Strip wt0 from Unraid's nginx include list and reload nginx so it stops
# trying to bind to the (now-gone) NetBird interface.
NEC=/boot/config/network-extra.cfg
if [ -f "$NEC" ] && grep -q 'wt0' "$NEC" ; then
sed -i 's/include_interfaces="\([^"]*\)wt0\([^"]*\)"/include_interfaces="\1\2"/' "$NEC"
sed -i 's/include_interfaces="[[:space:]]*/include_interfaces="/' "$NEC"
sed -i 's/[[:space:]]*"/"/' "$NEC"
fi
( sleep 5 ; /etc/rc.d/rc.nginx reload >/dev/null 2>&1 ) >/dev/null 2>&1 </dev/null &
disown 2>/dev/null || true
# Remove pages
rm -rf /usr/local/emhttp/plugins/netbird
# Tarball / package caches on flash
rm -f /boot/config/plugins/netbird/*.tar.gz
rm -f /boot/config/plugins/netbird/*.txz
echo ""
echo "----------------------------------------------------"
echo " NetBird plugin removed."
echo " Configuration preserved at /boot/config/plugins/netbird/"
echo " (delete that directory by hand to fully purge.)"
echo "----------------------------------------------------"
echo ""
]]>
</INLINE>
</FILE>
</PLUGIN>