Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
Ragnar/scripts/provision_network_tools.sh at main · PierreGode/Ragnar · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
PierreGode
Ragnar
Repository navigation
Code
Issues
1
(1)
Pull requests
1
(1)
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
Ragnar
/
scripts
/
provision_network_tools.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
171 lines (163 loc) · 7.82 KB
main
Breadcrumbs
Ragnar
/
scripts
/
provision_network_tools.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
171 lines (163 loc) · 7.82 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!
/bin/bash
#
#
provision_network_tools.sh
#
#
Idempotent system provisioning shared by the CLI updater (update_ragnar.sh)
#
and the in-app "Update" button (webapp_modern.py -> _execute_git_update).
#
Historically only the CLI updater installed these, so updating from the
#
Settings tab left a device without traceroute/mtr/lldpd/arp-scan etc. and
#
with radios still rfkill-blocked. This one script is the single source of
#
truth so both paths provision identically.
#
#
Does three things, each safe to re-run:
#
1. Unblock all radios (rfkill) + install a persistent boot/hot-plug rule.
#
2. Install network diagnostic tools (with per-distro package fallbacks).
#
3. Configure lldpd to decode CDPv1/v2, EDP, FDP and SONMP for switch discovery.
#
#
Must run as root. Prints plain progress lines; never exits non-zero for a
#
single failed tool so a partial environment still gets everything it can.
GREEN=
'
\033[0;32m
'
YELLOW=
'
\033[1;33m
'
NC=
'
\033[0m
'
#
No colors when output is captured (e.g. the in-app Update button pipes this
#
through subprocess) so the web UI doesn't show raw ANSI escape codes.
if
[
!
-t
1 ]
;
then
GREEN=
'
'
;
YELLOW=
'
'
;
NC=
'
'
fi
if
[
"
$(
id -u
)
"
-ne
0 ]
;
then
echo
-e
"
${YELLOW}
provision_network_tools.sh must run as root - skipping.
${NC}
"
exit
0
fi
#
---------------------------------------------------------------------------
#
1. Radios unblocked (rfkill)
#
---------------------------------------------------------------------------
#
USB Bluetooth and monitor-mode/injection WiFi dongles come up soft-blocked
#
and stay dead until unblocked. Unblock now and install a persistent udev
#
rule so it also survives reboot and hot-plug.
echo
-e
"
Ensuring radios are unblocked (rfkill)...
"
if
command
-v rfkill
>
/dev/null
2>&1
;
then
rfkill unblock all
RFKILL_BIN=
"
$(
command -v rfkill
)
"
cat
>
/etc/udev/rules.d/99-ragnar-rfkill.rules
<<
RFEOF
# Ragnar: auto-unblock every radio when it appears (boot + hot-plug).
# USB Bluetooth and monitor-mode/injection WiFi dongles are soft-blocked by
# default and stay dead until unblocked.
SUBSYSTEM=="rfkill", ACTION=="add", RUN+="
$RFKILL_BIN
unblock all"
RFEOF
chmod 644 /etc/udev/rules.d/99-ragnar-rfkill.rules
if
command
-v udevadm
>
/dev/null
2>&1
;
then
udevadm control --reload-rules
2>
/dev/null
||
true
udevadm trigger --subsystem-match=rfkill
2>
/dev/null
||
true
fi
echo
-e
"
${GREEN}
All radios unblocked and persistent rfkill rule installed.
${NC}
"
else
echo
-e
"
${YELLOW}
rfkill not available - skipping radio unblock.
${NC}
"
fi
#
---------------------------------------------------------------------------
#
2. Network diagnostic tools
#
---------------------------------------------------------------------------
#
Tools for the Network > Diagnostics / Switch & L2 / Interfaces tabs.
#
Package names (and their fallbacks) mirror install_ragnar.sh so distros that
#
name a package differently -- mtr vs mtr-tiny, whois vs jwhois, the
#
speedtest-cli python variants -- still resolve instead of silently failing.
echo
-e
"
Ensuring network diagnostic tools...
"
if
command
-v apt-get
>
/dev/null
2>&1
;
then
#
sbin tools (lldpctl, arp-scan, ethtool, traceroute) may not be on a bare
#
PATH; make sure the presence checks can find them.
export
PATH=
"
$PATH
:/usr/local/sbin:/usr/sbin:/sbin
"
#
"binary:pkg1 pkg2 ..." -- first candidate package that provides the
#
binary wins; remaining candidates are only tried if it is still missing.
net_tools=(
"
traceroute:traceroute
"
"
mtr:mtr-tiny mtr
"
"
whois:whois jwhois
"
"
lldpctl:lldpd
"
"
arp-scan:arp-scan arpscan
"
"
ethtool:ethtool
"
"
speedtest-cli:speedtest-cli python3-speedtest-cli python-speedtest-cli
"
)
#
Refresh the package index once, but only if something is actually missing
#
-- an update run never did `apt-get update`, so installs against a stale
#
index silently failed (unlike a fresh install, which updates first).
need_net_install=false
for
entry
in
"
${net_tools[@]}
"
;
do
command
-v
"
${entry
%%:*
}
"
>
/dev/null
2>&1
||
{ need_net_install=true
;
break
;
}
done
#
...but not on every single update. Some of these tools are simply not
#
packaged for every suite (speedtest-cli is the usual one), so "something is
#
missing" can be permanently true - and that turned a minutes-long
#
apt-get update into a fixed cost of every update on those boxes, with the
#
update card sitting on "Finishing update: network tools..." each time.
#
Refresh at most once every six hours; a genuinely missing package is still
#
retried immediately against the index already on disk.
APT_STAMP=/var/lib/ragnar/apt-index-refreshed
if
[
"
$need_net_install
"
=
true
]
;
then
stamp_age=999999
if
[
-f
"
$APT_STAMP
"
]
;
then
stamp_age=
$((
$(date
+%
s)
-
$(stat
-
c
%
Y "
$APT_STAMP
"
2
>/
dev
/
null
||
echo
0
)
))
fi
if
[
"
$stamp_age
"
-gt
21600 ]
;
then
echo
-e
"
Refreshing package index...
"
DEBIAN_FRONTEND=noninteractive apt-get update -y
>
/dev/null
2>&1
||
true
mkdir -p
"
$(
dirname
"
$APT_STAMP
"
)
"
2>
/dev/null
||
true
touch
"
$APT_STAMP
"
2>
/dev/null
||
true
else
echo
-e
"
Package index refreshed
$((
stamp_age
/
60
))
m ago - reusing it
"
fi
fi
for
entry
in
"
${net_tools[@]}
"
;
do
bin=
"
${entry
%%:*
}
"
;
pkgs=
"
${entry
#*:
}
"
if
command
-v
"
$bin
"
>
/dev/null
2>&1
;
then
continue
fi
installed=false
for
pkg
in
$pkgs
;
do
DEBIAN_FRONTEND=noninteractive apt-get install -y
"
$pkg
"
>
/dev/null
2>&1
||
true
if
command
-v
"
$bin
"
>
/dev/null
2>&1
;
then
echo
-e
"
${GREEN}
✓
${NC}
Installed
$bin
(
$pkg
)
"
installed=true
break
fi
done
if
[
"
$installed
"
=
false
]
;
then
echo
-e
"
${YELLOW}
!
${NC}
Could not install
$bin
(tried:
$pkgs
)
"
fi
done
echo
-e
"
${GREEN}
✓
${NC}
Network tools checked
"
else
echo
-e
"
${YELLOW}
apt-get not available - skipping network tool install.
${NC}
"
fi
#
The speedtest diagnostic (network_diagnostics.py) probes `speedtest-cli`
#
first, then a bare `speedtest`. The apt speedtest-cli package usually ships
#
both binaries, but on distros where it only provides speedtest-cli, guarantee
#
a `speedtest` alias too so neither lookup can miss.
if
command
-v speedtest-cli
>
/dev/null
2>&1
&&
!
command
-v speedtest
>
/dev/null
2>&1
;
then
ln -sf
"
$(
command -v speedtest-cli
)
"
/usr/local/bin/speedtest \
&&
echo
-e
"
${GREEN}
✓
${NC}
Linked speedtest -> speedtest-cli
"
fi
#
---------------------------------------------------------------------------
#
3. lldpd switch-discovery decoding
#
---------------------------------------------------------------------------
#
Configure lldpd to also decode CDPv1/v2, EDP, FDP and SONMP (non-LLDP switches)
if
command
-v lldpd
>
/dev/null
2>&1
||
command
-v lldpctl
>
/dev/null
2>&1
;
then
mkdir -p /etc/default
cat
>
/etc/default/lldpd
<<
'
LLDPEOF
'
# Ragnar: decode CDPv1/v2 (Cisco), EDP (Extreme), FDP (Foundry), SONMP (Nortel)
# neighbours in addition to LLDP, so switch discovery covers non-LLDP gear.
DAEMON_ARGS="-c -e -f -s"
LLDPEOF
systemctl
enable
lldpd
>
/dev/null
2>&1
||
true
systemctl restart lldpd
>
/dev/null
2>&1
||
true
echo
-e
"
${GREEN}
✓
${NC}
lldpd configured for switch discovery
"
fi
#
---------------------------------------------------------------------------
#
4. Raspberry Pi Connect (backup remote access — Mesh tab)
#
---------------------------------------------------------------------------
#
Install the rpi-connect binary so Ragnar's Mesh tab can sign in / report it.
#
Idempotent + ARM-only + never fails the run (see install_pi_connect.sh).
_pc=
"
$(
dirname
"
$0
"
)
/install_pi_connect.sh
"
if
[
-f
"
$_pc
"
]
;
then
echo
-e
"
Ensuring Raspberry Pi Connect...
"
bash
"
$_pc
"
||
true
fi
exit
0
You can’t perform that action at this time.