diff options
-rw-r--r-- | op-mode-definitions/poweroff.xml | 40 | ||||
-rw-r--r-- | op-mode-definitions/reboot.xml | 40 | ||||
-rw-r--r-- | op-mode-definitions/show-arp.xml | 27 | ||||
-rw-r--r-- | op-mode-definitions/show-bridge.xml | 37 | ||||
-rw-r--r-- | op-mode-definitions/show-configuration.xml | 39 | ||||
-rw-r--r-- | op-mode-definitions/show-date.xml | 30 | ||||
-rw-r--r-- | op-mode-definitions/show-disk.xml | 24 | ||||
-rw-r--r-- | op-mode-definitions/show-hardware.xml | 95 | ||||
-rw-r--r-- | op-mode-definitions/show-raid.xml | 18 | ||||
-rw-r--r-- | op-mode-definitions/show-users.xml | 30 | ||||
-rwxr-xr-x | src/completion/list_disks.sh | 5 | ||||
-rwxr-xr-x | src/completion/list_raidset.sh | 3 | ||||
-rwxr-xr-x | src/op_mode/show-configuration-files.sh | 10 | ||||
-rwxr-xr-x | src/op_mode/show-disk-format.sh | 8 | ||||
-rwxr-xr-x | src/op_mode/show-raid.sh | 17 |
15 files changed, 423 insertions, 0 deletions
diff --git a/op-mode-definitions/poweroff.xml b/op-mode-definitions/poweroff.xml new file mode 100644 index 000000000..07cea7927 --- /dev/null +++ b/op-mode-definitions/poweroff.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="poweroff"> + <properties> + <help>Poweroff the system</help> + </properties> + <command>/opt/vyatta/bin/sudo-users/vyatta-poweroff.pl --action poweroff</command> + <children> + <leafNode name="now"> + <properties> + <help>Poweroff the system without confirmation</help> + </properties> + <command>/opt/vyatta/bin/sudo-users/vyatta-poweroff.pl --action poweroff --now</command> + </leafNode> + + <leafNode name="cancel"> + <properties> + <help>Cancel a pending poweroff</help> + </properties> + <command>/opt/vyatta/bin/sudo-users/vyatta-poweroff.pl --action poweroff_cancel</command> + </leafNode> + + + <tagNode name="at"> + <properties> + <help>Poweroff at a specific time</help> + <completionHelp> + <list>HH:MM</list> + <list>MMDDYY</list> + <list>midnight</list> + <list>noon</list> + </completionHelp> + </properties> + <command>/opt/vyatta/bin/sudo-users/vyatta-poweroff.pl --action poweroff_at --at_time '$3'</command> + + </tagNode> + + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/reboot.xml b/op-mode-definitions/reboot.xml new file mode 100644 index 000000000..2c5a85d95 --- /dev/null +++ b/op-mode-definitions/reboot.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="reboot"> + <properties> + <help>Reboot the system</help> + </properties> + <command>/opt/vyatta/bin/sudo-users/vyatta-reboot.pl --action reboot</command> + <children> + <leafNode name="now"> + <properties> + <help>Reboot the system without confirmation</help> + </properties> + <command>/opt/vyatta/bin/sudo-users/vyatta-reboot.pl --action reboot --now</command> + </leafNode> + + <leafNode name="cancel"> + <properties> + <help>Cancel a pending reboot</help> + </properties> + <command>/opt/vyatta/bin/sudo-users/vyatta-reboot.pl --action reboot_cancel</command> + </leafNode> + + + <tagNode name="at"> + <properties> + <help>Reboot at a specific time</help> + <completionHelp> + <list>HH:MM</list> + <list>MMDDYY</list> + <list>midnight</list> + <list>noon</list> + </completionHelp> + </properties> + <command>/opt/vyatta/bin/sudo-users/vyatta-reboot.pl --action reboot_at --at_time '$3'</command> + + </tagNode> + + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-arp.xml b/op-mode-definitions/show-arp.xml new file mode 100644 index 000000000..7256bef61 --- /dev/null +++ b/op-mode-definitions/show-arp.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="arp"> + <properties> + <help>Show Address Resolution Protocol (ARP) information</help> + </properties> + <command>/usr/sbin/arp -e -n</command> + <children> + <tagNode name="interface"> + <properties> + <help>Show Address Resolution Protocol (ARP) cache for specified interface</help> + <completionHelp> + <script>${vyatta_sbindir}/vyatta-interfaces.pl --show ethernet</script> + <script>${vyatta_sbindir}/vyatta-interfaces.pl --show bridge</script> + <script>${vyatta_sbindir}/vyatta-interfaces.pl --show bonding</script> + </completionHelp> + </properties> + <command>/usr/sbin/arp -e -n -i '$4'</command> + </tagNode> + </children> + </node> + + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-bridge.xml b/op-mode-definitions/show-bridge.xml new file mode 100644 index 000000000..0d80de86e --- /dev/null +++ b/op-mode-definitions/show-bridge.xml @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <leafNode name="bridge"> + <properties> + <help>Show bridging information</help> + </properties> + <command>/sbin/brctl show</command> + </leafNode> + <tagNode name="bridge"> + <properties> + <help>Show bridge information for a given bridge interface</help> + <completionHelp> + <script>${vyatta_sbindir}/vyatta-interfaces.pl --show bridge</script> + </completionHelp> + </properties> + <command>/sbin/brctl show '$3'</command> + <children> + <leafNode name="macs"> + <properties> + <help>Show bridge Media Access Control (MAC) address table</help> + </properties> + <command>/sbin/brctl showmacs '$3'</command> + </leafNode> + <leafNode name="spanning-tree"> + <properties> + <help>Show bridge spanning tree information</help> + </properties> + <command>/sbin/brctl showstp '$3'</command> + </leafNode> + </children> + </tagNode> + + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-configuration.xml b/op-mode-definitions/show-configuration.xml new file mode 100644 index 000000000..3fe3cb0dc --- /dev/null +++ b/op-mode-definitions/show-configuration.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="configuration"> + <properties> + <help>Show available saved configurations</help> + </properties> + <!-- no admin check --> + <command>cli-shell-api showCfg --show-active-only --show-hide-secrets</command> + + <children> + <node name="all"> + <properties> + <help>Show running configuration (including default values)</help> + </properties> + <!-- no admin check --> + <command>cli-shell-api showCfg --show-show-defaults --show-active-only --show-hide-secrets</command> + </node> + <node name="commands"> + <properties> + <help> Show running configuration as set commands </help> + </properties> + <!-- no admin check --> + <command>${vyatta_sbindir}/vyatta-config-gen-sets.pl</command> + </node> + <node name="files"> + <properties> + <help> Show available saved configurations </help> + </properties> + <!-- no admin check --> + <command>${vyos_op_scripts_dir}/show-configuration-files.sh</command> + </node> + </children> + </node> + + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-date.xml b/op-mode-definitions/show-date.xml new file mode 100644 index 000000000..dddecd2fb --- /dev/null +++ b/op-mode-definitions/show-date.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="date"> + <properties> + <help>Show system time and date</help> + </properties> + <command>/bin/date</command> + <children> + <node name="utc"> + <properties> + <help>Show system date and time as Coordinated Universal Time</help> + </properties> + <command>/bin/date -u</command> + <children> + <leafNode name="maya"> + <properties> + <help>Show UTC date in Maya calendar format</help> + </properties> + <command>${vyatta_bindir}/maya-date.py $(date +%s)</command> + </leafNode> + </children> + </node> + </children> + </node> + + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-disk.xml b/op-mode-definitions/show-disk.xml new file mode 100644 index 000000000..db473959a --- /dev/null +++ b/op-mode-definitions/show-disk.xml @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <tagNode name="disk"> + <properties> + <help>Show status of disk device</help> + <completionHelp> + <script>${vyos_completion_dir}/list_disks.sh</script> + </completionHelp> + </properties> + <children> + <leafNode name="format"> + <properties> + <help>Show disk drive formatting</help> + </properties> + <command>${vyos_op_scripts_dir}/show-disk-format.sh $3</command> + </leafNode> + </children> + </tagNode> + + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-hardware.xml b/op-mode-definitions/show-hardware.xml new file mode 100644 index 000000000..c1ee927cf --- /dev/null +++ b/op-mode-definitions/show-hardware.xml @@ -0,0 +1,95 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="hardware"> + <properties> + <help>Show system hardware details</help> + </properties> + <children> + <node name="cpu"> + <properties> + <help>Show CPU info</help> + </properties> + <command>lscpu</command> + <children> + <node name="detail"> + <properties> + <help> Show system CPU details</help> + </properties> + <command>cat /proc/cpuinfo</command> + </node> + <node name="summary"> + <properties> + <help>Show CPU's on system</help> + </properties> + <command>${vyatta_bindir}/vyatta-cpu-summary.pl</command> + </node> + </children> + </node> + + <node name="dmi"> + <properties> + <help>Show system DMI details</help> + </properties> + <command>${vyatta_bindir}/vyatta-show-dmi</command> + </node> + + <node name="mem"> + <properties> + <help>Show system RAM details</help> + </properties> + <command>cat /proc/meminfo</command> + </node> + + <node name="pci"> + <properties> + <help>Show system PCI bus details</help> + </properties> + <command>lspci</command> + <children> + <node name="detail"> + <properties> + <help>Show verbose system PCI bus details</help> + </properties> + <command>lspci -vvv</command> + </node> + </children> + </node> + + + <node name="scsi"> + <properties> + <help>Show SCSI device information</help> + </properties> + <command>lsscsi</command> + <children> + <node name="detail"> + <properties> + <help>Show detailed SCSI device information</help> + </properties> + <command>lsscsi -vvv</command> + </node> + </children> + </node> + + <node name="usb"> + <properties> + <help>Show peripherals connected to the USB bus</help> + </properties> + <command>lsusb</command> + <children> + <node name="detail"> + <properties> + <help>Show detailed USB bus information</help> + </properties> + <command>lsusb -v</command> + </node> + </children> + </node> + + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-raid.xml b/op-mode-definitions/show-raid.xml new file mode 100644 index 000000000..b0930742a --- /dev/null +++ b/op-mode-definitions/show-raid.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <tagNode name="raid"> + <properties> + <help>Show statis of RAID set</help> + <completionHelp> + <script>${vyos_completion_dir}/list_raidset.sh</script> + </completionHelp> + </properties> + <command>${vyos_op_scripts_dir}/show_raid.sh $3</command> + + </tagNode> + + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-users.xml b/op-mode-definitions/show-users.xml new file mode 100644 index 000000000..a026e47e7 --- /dev/null +++ b/op-mode-definitions/show-users.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="users"> + <properties> + <help>Show user information</help> + </properties> + <command>who -H</command> + <children> + <node name="recent"> + <properties> + <help>Show 10 recently logged in users</help> + </properties> + <command>last -aF -n 10 | sed -e 's/^wtmp begins/Displaying logins since/'</command> + </node> + <tagNode name="recent"> + <properties> + <help>Show specified number of recently logged in users</help> + <completionHelp> + <list>NUMBER</list> + </completionHelp> + </properties> + <command>last -aF -n $4 | sed -e 's/^wtmp begins/Displaying logins since/'</command> + </tagNode> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/src/completion/list_disks.sh b/src/completion/list_disks.sh new file mode 100755 index 000000000..f32e558fd --- /dev/null +++ b/src/completion/list_disks.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Completion script used by show disks to collect physical disk + +awk 'NR > 2 && $4 !~ /[0-9]$/ { print $4 }' </proc/partitions diff --git a/src/completion/list_raidset.sh b/src/completion/list_raidset.sh new file mode 100755 index 000000000..9ff3523aa --- /dev/null +++ b/src/completion/list_raidset.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo -n `cat /proc/partitions | grep md | awk '{ print $4 }'` diff --git a/src/op_mode/show-configuration-files.sh b/src/op_mode/show-configuration-files.sh new file mode 100755 index 000000000..ad8e0747c --- /dev/null +++ b/src/op_mode/show-configuration-files.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Wrapper script for the show configuration files command +find ${vyatta_sysconfdir}/config/ \ + -type f \ + -not -name ".*" \ + -not -name "config.boot.*" \ + -printf "%f\t(%Tc)\t%T@\n" \ + | sort -r -k3 \ + | awk -F"\t" '{printf ("%-20s\t%s\n", $1,$2) ;}' diff --git a/src/op_mode/show-disk-format.sh b/src/op_mode/show-disk-format.sh new file mode 100755 index 000000000..61b15a52b --- /dev/null +++ b/src/op_mode/show-disk-format.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +disk_dev="/dev/$1" +if [ ! -b "$disk_dev" ];then + echo "$3 is not a disk device" + exit 1 +fi +sudo /sbin/fdisk -l "$disk_dev" diff --git a/src/op_mode/show-raid.sh b/src/op_mode/show-raid.sh new file mode 100755 index 000000000..ba4174692 --- /dev/null +++ b/src/op_mode/show-raid.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +raid_set_name=$1 +raid_sets=`cat /proc/partitions | grep md | awk '{ print $4 }'` +valid_set=`echo $raid_sets | grep $raid_set_name` +if [ -z $valid_set ]; then + echo "$raid_set_name is not a RAID set" +else + if [ -r /dev/${raid_set_name} ]; then + # This should work without sudo because we have read + # access to the dev, but for some reason mdadm must be + # run as root in order to succeed. + sudo /sbin/mdadm --detail /dev/${raid_set_name} + else + echo "Must be administrator or root to display RAID status" + fi +fi |