summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2025-07-29 14:57:57 +0100
committerDaniil Baturin <daniil@baturin.org>2025-07-30 00:52:45 +0100
commit01d76637d8513507ec69962c6b95da32b3736133 (patch)
tree7e989d1fa2dc5979ede90a96ba7960703e237c5a
parent51a17eadc063423a80502462dba0b67cb4fe3496 (diff)
downloadvyos-1x-01d76637d8513507ec69962c6b95da32b3736133.tar.gz
vyos-1x-01d76637d8513507ec69962c6b95da32b3736133.zip
op-mode: T7527: eliminate bare shell snippets in op mode commands
-rw-r--r--op-mode-definitions/monitor-log.xml.in16
-rw-r--r--op-mode-definitions/openvpn.xml.in2
-rw-r--r--op-mode-definitions/policy-route.xml.in8
-rw-r--r--op-mode-definitions/restart-ntp.xml.in2
-rw-r--r--op-mode-definitions/show-console-server.xml.in4
-rw-r--r--op-mode-definitions/show-environment.xml.in2
-rw-r--r--op-mode-definitions/show-interfaces-ethernet.xml.in2
-rw-r--r--op-mode-definitions/show-interfaces-wwan.xml.in4
-rwxr-xr-xop-mode-definitions/show-log.xml.in10
-rw-r--r--op-mode-definitions/vpn-ipsec.xml.in2
-rw-r--r--op-mode-definitions/webproxy.xml.in8
11 files changed, 30 insertions, 30 deletions
diff --git a/op-mode-definitions/monitor-log.xml.in b/op-mode-definitions/monitor-log.xml.in
index 721460be5..a9dae61c9 100644
--- a/op-mode-definitions/monitor-log.xml.in
+++ b/op-mode-definitions/monitor-log.xml.in
@@ -9,19 +9,19 @@
<properties>
<help>Monitor last lines of messages file</help>
</properties>
- <command>SYSTEMD_COLORS=false journalctl --no-hostname --follow --boot</command>
+ <command>bash -c 'SYSTEMD_COLORS=false journalctl --no-hostname --follow --boot'</command>
<children>
<node name="color">
<properties>
<help>Output log in a colored fashion</help>
</properties>
- <command>SYSTEMD_COLORS=false grc journalctl --no-hostname --follow --boot</command>
+ <command>bash -c 'SYSTEMD_COLORS=false grc journalctl --no-hostname --follow --boot'</command>
</node>
<leafNode name="certbot">
<properties>
<help>Monitor last lines of certbot log</help>
</properties>
- <command>if test -f /var/log/letsencrypt/letsencrypt.log; then tail --follow=name /var/log/letsencrypt/letsencrypt.log; else echo "Cerbot log does not exist"; fi</command>
+ <command>bash -c 'if test -f /var/log/letsencrypt/letsencrypt.log; then tail --follow=name /var/log/letsencrypt/letsencrypt.log; else echo "Cerbot log does not exist"; fi'</command>
</leafNode>
<leafNode name="conntrack-sync">
<properties>
@@ -269,7 +269,7 @@
<path>interfaces macsec</path>
</completionHelp>
</properties>
- <command>SRC=$(cli-shell-api returnValue interfaces macsec "$5" source-interface); journalctl --no-hostname --boot --follow --unit "wpa_supplicant-macsec@$SRC.service"</command>
+ <command>journalctl --no-hostname --boot --follow --unit "wpa_supplicant-macsec@`cli-shell-api returnEffectiveValue interfaces macsec $5 source-interface`.service"</command>
</tagNode>
</children>
</node>
@@ -379,7 +379,7 @@
<properties>
<help>Monitor last lines of WPA supplicant</help>
</properties>
- <command>if cli-shell-api existsActive interfaces wireless; then journalctl --no-hostname --boot --follow --unit "wpa_supplicant@*.service"; else echo "No wireless interface configured!"; fi</command>
+ <command>journalctl --no-hostname --boot --follow --unit "wpa_supplicant@*.service"</command>
<children>
<tagNode name="interface">
<properties>
@@ -388,7 +388,7 @@
<path>interfaces wireless</path>
</completionHelp>
</properties>
- <command>if [[ $(cli-shell-api returnActiveValue interfaces wireless $6 type) == "station" ]]; then journalctl --no-hostname --boot --follow --unit "wpa_supplicant@$6.service"; else echo "Wireless interface $6 not configured as station!"; fi</command>
+ <command>journalctl --no-hostname --boot --follow --unit "wpa_supplicant@$6.service"</command>
</tagNode>
</children>
</node>
@@ -396,7 +396,7 @@
<properties>
<help>Monitor last lines of host access point daemon</help>
</properties>
- <command>if cli-shell-api existsActive interfaces wireless; then journalctl --no-hostname --boot --follow --unit "hostapd@*.service"; else echo "No wireless interface configured!"; fi</command>
+ <command>journalctl --no-hostname --boot --follow --unit "hostapd@*.service"</command>
<children>
<tagNode name="interface">
<properties>
@@ -405,7 +405,7 @@
<path>interfaces wireless</path>
</completionHelp>
</properties>
- <command>if [[ $(cli-shell-api returnActiveValue interfaces wireless $6 type) == "access-point" ]]; then journalctl --no-hostname --boot --follow --unit "hostapd@$6.service"; else echo "Wireless interface $6 not configured as access-point!"; fi</command>
+ <command>journalctl --no-hostname --boot --follow --unit "hostapd@$6.service"</command>
</tagNode>
</children>
</node>
diff --git a/op-mode-definitions/openvpn.xml.in b/op-mode-definitions/openvpn.xml.in
index 692eef836..5c1828cd4 100644
--- a/op-mode-definitions/openvpn.xml.in
+++ b/op-mode-definitions/openvpn.xml.in
@@ -14,7 +14,7 @@
<script>${vyos_completion_dir}/list_openvpn_clients.py --all</script>
</completionHelp>
</properties>
- <command>echo kill $4 | socat - UNIX-CONNECT:/run/openvpn/openvpn-mgmt-intf &gt; /dev/null</command>
+ <command>bash -c 'echo kill $4 | socat - UNIX-CONNECT:/run/openvpn/openvpn-mgmt-intf &gt; /dev/null'</command>
</tagNode>
<tagNode name="interface">
<properties>
diff --git a/op-mode-definitions/policy-route.xml.in b/op-mode-definitions/policy-route.xml.in
index e733d976c..7ab2e6ac3 100644
--- a/op-mode-definitions/policy-route.xml.in
+++ b/op-mode-definitions/policy-route.xml.in
@@ -20,7 +20,7 @@
<properties>
<help>Clear counters for specified chain</help>
</properties>
- <command>echo "TODO"</command>
+ <command>bash -c 'echo "Unimplemented"'</command>
</leafNode>
<tagNode name="rule">
<properties>
@@ -34,7 +34,7 @@
<properties>
<help>Clear counters for specified rule</help>
</properties>
- <command>echo "TODO"</command>
+ <command>bash -c 'echo "Unimplemented"'</command>
</leafNode>
</children>
</tagNode>
@@ -52,7 +52,7 @@
<properties>
<help>Clear counters for specified chain</help>
</properties>
- <command>echo "TODO"</command>
+ <command>bash -c 'echo "Unimplemented"'</command>
</leafNode>
<tagNode name="rule">
<properties>
@@ -66,7 +66,7 @@
<properties>
<help>Clear counters for specified rule</help>
</properties>
- <command>echo "TODO"</command>
+ <command>bash -c 'echo "Unimplemented"'</command>
</leafNode>
</children>
</tagNode>
diff --git a/op-mode-definitions/restart-ntp.xml.in b/op-mode-definitions/restart-ntp.xml.in
index 8713dd147..8a64a89ec 100644
--- a/op-mode-definitions/restart-ntp.xml.in
+++ b/op-mode-definitions/restart-ntp.xml.in
@@ -6,7 +6,7 @@
<properties>
<help>Restart NTP service</help>
</properties>
- <command>if cli-shell-api existsActive service ntp; then systemctl restart chrony.service; else echo "Service NTP not configured"; fi</command>
+ <command>bash -c 'if cli-shell-api existsActive service ntp; then systemctl restart chrony.service; else echo "Service NTP not configured"; fi'</command>
</node>
</children>
</node>
diff --git a/op-mode-definitions/show-console-server.xml.in b/op-mode-definitions/show-console-server.xml.in
index 03dd97d83..7b9fe6d70 100644
--- a/op-mode-definitions/show-console-server.xml.in
+++ b/op-mode-definitions/show-console-server.xml.in
@@ -21,13 +21,13 @@
<properties>
<help>Examine console ports and configured baud rates</help>
</properties>
- <command>if cli-shell-api existsActive service console-server; then /usr/bin/console -x; else echo "Console server is not configured"; fi</command>
+ <command>bash -c 'if cli-shell-api existsActive service console-server; then /usr/bin/console -x; else echo "Console server is not configured"; fi'</command>
</leafNode>
<leafNode name="user">
<properties>
<help>Show users on various consoles</help>
</properties>
- <command>if cli-shell-api existsActive service console-server; then /usr/bin/console -u; else echo "Console server is not configured"; fi</command>
+ <command>bash -c 'if cli-shell-api existsActive service console-server; then /usr/bin/console -u; else echo "Console server is not configured"; fi'</command>
</leafNode>
</children>
</node>
diff --git a/op-mode-definitions/show-environment.xml.in b/op-mode-definitions/show-environment.xml.in
index 74d106ad6..c71048ffc 100644
--- a/op-mode-definitions/show-environment.xml.in
+++ b/op-mode-definitions/show-environment.xml.in
@@ -12,7 +12,7 @@
<help>Show hardware monitoring results</help>
</properties>
<!-- Linux always adds "hypervisor" to CPU flags -->
- <command>bash -c 'if ! grep -q hypervisor /proc/cpuinfo; then '${vyos_op_scripts_dir}'/show_sensors.py; else echo "VyOS running under hypervisor, no sensors available"; fi'</command>
+ <command>bash -c 'if ! grep -q hypervisor /proc/cpuinfo; then ${vyos_op_scripts_dir}/show_sensors.py; else echo "VyOS running under hypervisor, no sensors available"; fi'</command>
</leafNode>
</children>
</node>
diff --git a/op-mode-definitions/show-interfaces-ethernet.xml.in b/op-mode-definitions/show-interfaces-ethernet.xml.in
index c6e9a2ec2..08da21a47 100644
--- a/op-mode-definitions/show-interfaces-ethernet.xml.in
+++ b/op-mode-definitions/show-interfaces-ethernet.xml.in
@@ -34,7 +34,7 @@
<properties>
<help>Visually identify specified ethernet interface</help>
</properties>
- <command>echo "Blinking interface $4 for 30 seconds."; ethtool --identify "$4" 30</command>
+ <command>bash -c "echo \"Blinking interface $4 for 30 seconds.\"; ethtool --identify \"$4\" 30"</command>
</leafNode>
<node name="physical">
<properties>
diff --git a/op-mode-definitions/show-interfaces-wwan.xml.in b/op-mode-definitions/show-interfaces-wwan.xml.in
index 6616de9dc..3520e754c 100644
--- a/op-mode-definitions/show-interfaces-wwan.xml.in
+++ b/op-mode-definitions/show-interfaces-wwan.xml.in
@@ -84,13 +84,13 @@
<properties>
<help>Show WWAN module detailed information summary</help>
</properties>
- <command>if cli-shell-api existsActive interfaces wwan $4; then mmcli --modem ${4#wwan}; else echo "Interface \"$4\" unconfigured!"; fi</command>
+ <command>bash -c "if cli-shell-api existsActive interfaces wwan $4; then mmcli --modem ${4#wwan}; else echo \"Interface \"$4\" unconfigured!\"; fi"</command>
</leafNode>
<leafNode name="log">
<properties>
<help>Show interface log for specified interface</help>
</properties>
- <command>echo not implemented</command>
+ <command>bash -c 'echo Unimplemented'</command>
</leafNode>
#include <include/show-interface-type-event-log.xml.i>
</children>
diff --git a/op-mode-definitions/show-log.xml.in b/op-mode-definitions/show-log.xml.in
index 6eb4eb467..cc4a46076 100755
--- a/op-mode-definitions/show-log.xml.in
+++ b/op-mode-definitions/show-log.xml.in
@@ -18,7 +18,7 @@
<list>&lt;1-9999&gt;</list>
</completionHelp>
</properties>
- <command>if ${vyos_validators_dir}/numeric --range 1-9999 "$3"; then journalctl --no-hostname --boot --lines "$3"; fi</command>
+ <command>bash -c "if ${vyos_validators_dir}/numeric --range 1-9999 '$3'; then journalctl --no-hostname --boot --lines $3; fi"</command>
</virtualTagNode>
<leafNode name="audit">
<properties>
@@ -944,7 +944,7 @@
<properties>
<help>Show log for WPA supplicant</help>
</properties>
- <command>if cli-shell-api existsActive interfaces wireless; then journalctl --no-hostname --boot --unit "wpa_supplicant@*.service"; else echo "No wireless interface configured!"; fi</command>
+ <command>bash -c "if cli-shell-api existsActive interfaces wireless; then journalctl --no-hostname --boot --unit \"wpa_supplicant@*.service\"; else echo \"No wireless interface configured!\"; fi"</command>
<children>
<tagNode name="interface">
<properties>
@@ -953,7 +953,7 @@
<path>interfaces wireless</path>
</completionHelp>
</properties>
- <command>if [[ $(cli-shell-api returnActiveValue interfaces wireless $6 type) == "station" ]]; then journalctl --no-hostname --boot --unit "wpa_supplicant@$6.service"; else echo "Wireless interface $6 not configured as station!"; fi</command>
+ <command>bash -c "if [[ $(cli-shell-api returnActiveValue interfaces wireless $6 type) == \"station\" ]]; then journalctl --no-hostname --boot --unit \"wpa_supplicant@$6.service\"; else echo \"Wireless interface $6 not configured as station!\"; fi"</command>
</tagNode>
</children>
</node>
@@ -961,7 +961,7 @@
<properties>
<help>Show log for host access point daemon</help>
</properties>
- <command>if cli-shell-api existsActive interfaces wireless; then journalctl --no-hostname --boot --unit "hostapd@*.service"; else echo "No wireless interface configured!"; fi</command>
+ <command>bash -c 'if cli-shell-api existsActive interfaces wireless; then journalctl --no-hostname --boot --unit "hostapd@*.service"; else echo "No wireless interface configured!"; fi'</command>
<children>
<tagNode name="interface">
<properties>
@@ -970,7 +970,7 @@
<path>interfaces wireless</path>
</completionHelp>
</properties>
- <command>if [[ $(cli-shell-api returnActiveValue interfaces wireless $6 type) == "access-point" ]]; then journalctl --no-hostname --boot --unit "hostapd@$6.service"; else echo "Wireless interface $6 not configured as access-point!"; fi</command>
+ <command>bash -c "if [[ $(cli-shell-api returnActiveValue interfaces wireless $6 type) == \"access-point\" ]]; then journalctl --no-hostname --boot --unit \"hostapd@$6.service\"; else echo \"Wireless interface $6 not configured as access-point!\"; fi"</command>
</tagNode>
</children>
</node>
diff --git a/op-mode-definitions/vpn-ipsec.xml.in b/op-mode-definitions/vpn-ipsec.xml.in
index af7f12ba8..51ac897c8 100644
--- a/op-mode-definitions/vpn-ipsec.xml.in
+++ b/op-mode-definitions/vpn-ipsec.xml.in
@@ -225,7 +225,7 @@
<properties>
<help>Show active IKEv2 RA sessions summary</help>
</properties>
- <command>${vyos_op_scripts_dir}/ipsec.py show_ra_summary; else echo "IPsec process not running"</command>
+ <command>${vyos_op_scripts_dir}/ipsec.py show_ra_summary</command>
</node>
<tagNode name="username">
<properties>
diff --git a/op-mode-definitions/webproxy.xml.in b/op-mode-definitions/webproxy.xml.in
index 76c348f9d..c65f03560 100644
--- a/op-mode-definitions/webproxy.xml.in
+++ b/op-mode-definitions/webproxy.xml.in
@@ -14,13 +14,13 @@
<properties>
<help>Monitor the last lines of the Webproxy access log</help>
</properties>
- <command>if [ -f /var/log/squid/access.log ]; then tail --follow=name /var/log/squid/access.log; else echo "WebProxy access-log does not exist"; fi</command>
+ <command>bash -c 'if [ -f /var/log/squid/access.log ]; then tail --follow=name /var/log/squid/access.log; else echo "WebProxy access-log does not exist"; fi'</command>
</leafNode>
<leafNode name="cache-log">
<properties>
<help>Monitor the last lines of the Webproxy cache log</help>
</properties>
- <command>if [ -f /var/log/squid/cache.log ]; then tail --follow=name /var/log/squid/cache.log; else echo "WebProxy cache-log does not exist"; fi</command>
+ <command>bash -c 'if [ -f /var/log/squid/cache.log ]; then tail --follow=name /var/log/squid/cache.log; else echo "WebProxy cache-log does not exist"; fi'</command>
</leafNode>
</children>
</node>
@@ -63,13 +63,13 @@
<properties>
<help>Show contents of WebProxy access log</help>
</properties>
- <command>if [ -e /var/log/squid/access.log ]; then less $_vyatta_less_options --prompt="file %i of %m, page %dt of %D" -- `printf "%s\n" /var/log/squid/access.log* | sort -nr`; else echo "No WebProxy log"; fi</command>
+ <command>bash -c 'if [ -e /var/log/squid/access.log ]; then less $_vyatta_less_options --prompt="file %i of %m, page %dt of %D" -- `printf "%s\n" /var/log/squid/access.log* | sort -nr`; else echo "No WebProxy log"; fi'</command>
</node>
<node name="update-log">
<properties>
<help>Show update log for url-filter database</help>
</properties>
- <command>if [ -e /opt/vyatta/etc/config/url-filtering/squidguard/updatestatus ]; then cat /opt/vyatta/etc/config/url-filtering/squidguard/updatestatus; else echo "Update log not found"; fi</command>
+ <command>bash -c 'if [ -e /opt/vyatta/etc/config/url-filtering/squidguard/updatestatus ]; then cat /opt/vyatta/etc/config/url-filtering/squidguard/updatestatus; else echo "Update log not found"; fi'</command>
</node>
</children>
</node>