Skip to content

Commit 1d32420

Browse files
committed
op-mode: T7527: move assorted embedded shel snippets to script files
1 parent 594e776 commit 1d32420

10 files changed

+41
-14
lines changed

op-mode-definitions/install-mok.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<properties>
77
<help>Install Secure Boot MOK (Machine Owner Key)</help>
88
</properties>
9-
<command>if test -f /var/lib/shim-signed/mok/vyos-dev-2025-shim.der; then mokutil --ignore-keyring --import /var/lib/shim-signed/mok/vyos-dev-2025-shim.der; else echo "Secure Boot Machine Owner Key not found"; fi</command>
9+
<command>${vyos_op_scripts_dir}/install_mok.sh</command>
1010
</leafNode>
1111
</children>
1212
</node>

op-mode-definitions/show-interfaces-bonding.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<properties>
2424
<help>Show detailed interface information</help>
2525
</properties>
26-
<command>if [ -f "/proc/net/bonding/$4" ]; then cat "/proc/net/bonding/$4"; else echo "Interface $4 does not exist!"; fi</command>
26+
<command>${vyos_op_scripts_dir}/show_bonding_detail.sh "$4"</command>
2727
</leafNode>
2828
<node name="lacp">
2929
<properties>

op-mode-definitions/show-interfaces-pppoe.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<path>interfaces pppoe</path>
2727
</completionHelp>
2828
</properties>
29-
<command>if [ -d "/sys/class/net/$4" ]; then /usr/sbin/pppstats "$4"; fi</command>
29+
<command>${vyos_op_scripts_dir}/show_ppp_stats.sh "$4"</command>
3030
</leafNode>
3131
#include <include/show-interface-type-event-log.xml.i>
3232
</children>

op-mode-definitions/show-interfaces-sstpc.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<path>interfaces sstpc</path>
2727
</completionHelp>
2828
</properties>
29-
<command>if [ -d "/sys/class/net/$4" ]; then /usr/sbin/pppstats "$4"; fi</command>
29+
<command>${vyos_op_scripts_dir}/show_ppp_stats.sh "$4"</command>
3030
</leafNode>
3131
#include <include/show-interface-type-event-log.xml.i>
3232
</children>

op-mode-definitions/suricata.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<properties>
77
<help>Update Suricata</help>
88
</properties>
9-
<command>if test -f /run/suricata/suricata.yaml; then suricata-update --suricata-conf /run/suricata/suricata.yaml; systemctl restart suricata; else echo "Service Suricata not configured"; fi </command>
9+
<command>${vyos_op_scripts_dir}/update_suricata.sh</command>
1010
</node>
1111
</children>
1212
</node>

op-mode-definitions/vpn-ipsec.xml.in

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
<properties>
184184
<help>Show summary of IKE process information</help>
185185
</properties>
186-
<command>if systemctl is-active --quiet strongswan ; then systemctl status strongswan ; else echo "Process is not running" ; fi</command>
186+
<command>systemctl status strongswan</command>
187187
</node>
188188
</children>
189189
</node>
@@ -213,25 +213,25 @@
213213
<properties>
214214
<help>Show detail active IKEv2 RA sessions</help>
215215
</properties>
216-
<command>if systemctl is-active --quiet strongswan ; then ${vyos_op_scripts_dir}/ipsec.py show_ra_detail; else echo "IPsec process not running" ; fi</command>
216+
<command>${vyos_op_scripts_dir}/ipsec.py show_ra_detail</command>
217217
</node>
218218
<tagNode name="connection-id">
219219
<properties>
220220
<help>Show detail active IKEv2 RA sessions by connection-id</help>
221221
</properties>
222-
<command>if systemctl is-active --quiet strongswan ; then ${vyos_op_scripts_dir}/ipsec.py show_ra_detail --conn-id="$6"; else echo "IPsec process not running" ; fi</command>
222+
<command>${vyos_op_scripts_dir}/ipsec.py show_ra_detail --conn-id="$6"</command>
223223
</tagNode>
224224
<node name="summary">
225225
<properties>
226226
<help>Show active IKEv2 RA sessions summary</help>
227227
</properties>
228-
<command>if systemctl is-active --quiet strongswan ; then ${vyos_op_scripts_dir}/ipsec.py show_ra_summary; else echo "IPsec process not running" ; fi</command>
228+
<command>${vyos_op_scripts_dir}/ipsec.py show_ra_summary; else echo "IPsec process not running"</command>
229229
</node>
230230
<tagNode name="username">
231231
<properties>
232232
<help>Show detail active IKEv2 RA sessions by username</help>
233233
</properties>
234-
<command>if systemctl is-active --quiet strongswan ; then ${vyos_op_scripts_dir}/ipsec.py show_ra_detail --username="$6"; else echo "IPsec process not running" ; fi</command>
234+
<command>${vyos_op_scripts_dir}/ipsec.py show_ra_detail --username="$6"</command>
235235
</tagNode>
236236
</children>
237237
</node>
@@ -268,12 +268,12 @@
268268
-->
269269
<node name="detail">
270270
<properties>
271-
<help>Show Verbose Detail on all active IPsec Security Associations (SA)</help>
271+
<help>Show verbose details on all active IPsec security associations (SA)</help>
272272
</properties>
273-
<command>if systemctl is-active --quiet strongswan ; then ${vyos_op_scripts_dir}/ipsec.py show_sa_detail ; else echo "IPsec process not running" ; fi</command>
273+
<command>${vyos_op_scripts_dir}/ipsec.py show_sa_detail</command>
274274
</node>
275275
</children>
276-
<command>if systemctl is-active --quiet strongswan ; then ${vyos_op_scripts_dir}/ipsec.py show_sa ; else echo "IPsec process not running" ; fi</command>
276+
<command>${vyos_op_scripts_dir}/ipsec.py show_sa</command>
277277
</node>
278278
<node name="state">
279279
<properties>
@@ -285,7 +285,7 @@
285285
<properties>
286286
<help>Show status of IPsec process</help>
287287
</properties>
288-
<command>if systemctl is-active --quiet strongswan >/dev/null ; then echo -e "IPsec Process Running: $(pgrep charon)\n$(/usr/sbin/ipsec status)" ; else echo "IPsec process not running" ; fi</command>
288+
<command>/usr/sbin/ipsec status</command>
289289
</node>
290290
</children>
291291
</node>

src/op_mode/install_mok.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
if test -f /var/lib/shim-signed/mok/vyos-dev-2025-shim.der; then
4+
mokutil --ignore-keyring --import /var/lib/shim-signed/mok/vyos-dev-2025-shim.der;
5+
else
6+
echo "Secure Boot Machine Owner Key not found";
7+
fi

src/op_mode/show_bonding_detail.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
if [ -f "/proc/net/bonding/$1" ]; then
4+
cat "/proc/net/bonding/$1";
5+
else
6+
echo "Interface $1 does not exist!";
7+
fi

src/op_mode/show_ppp_stats.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
if [ -d "/sys/class/net/$1" ]; then
4+
/usr/sbin/pppstats "$1";
5+
fi

src/op_mode/update_suricata.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
if test -f /run/suricata/suricata.yaml; then
4+
suricata-update --suricata-conf /run/suricata/suricata.yaml;
5+
systemctl restart suricata;
6+
else
7+
echo "Service Suricata not configured";
8+
fi

0 commit comments

Comments
 (0)