summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--debian/control4
-rw-r--r--op-mode-definitions/poweroff.xml40
-rw-r--r--op-mode-definitions/reboot.xml40
-rw-r--r--op-mode-definitions/show-arp.xml25
-rw-r--r--op-mode-definitions/show-bridge.xml37
-rw-r--r--op-mode-definitions/show-configuration.xml39
-rw-r--r--op-mode-definitions/show-date.xml30
-rw-r--r--op-mode-definitions/show-disk.xml24
-rw-r--r--op-mode-definitions/show-hardware.xml95
-rw-r--r--op-mode-definitions/show-raid.xml18
-rw-r--r--op-mode-definitions/show-users.xml30
-rwxr-xr-xsrc/completion/list_disks.sh5
-rwxr-xr-xsrc/completion/list_raidset.sh3
-rwxr-xr-xsrc/op_mode/maya_date.py209
-rwxr-xr-xsrc/op_mode/show-configuration-files.sh10
-rwxr-xr-xsrc/op_mode/show-disk-format.sh8
-rwxr-xr-xsrc/op_mode/show-raid.sh17
18 files changed, 634 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 05695705a..143eebbac 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ clean:
.PHONY: test
test:
- python3 -m "nose" --with-xunit src --with-coverage --cover-erase --cover-xml --cover-package src/conf_mode,src/op_mode,src/completion,src/helpers,src/validators --verbose
+ PYTHONPATH=python/ python3 -m "nose" --with-xunit src --with-coverage --cover-erase --cover-xml --cover-package src/conf_mode,src/op_mode,src/completion,src/helpers,src/validators --verbose
.PHONY: sonar
sonar:
diff --git a/debian/control b/debian/control
index 21d8c4263..6919c7d4c 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,9 @@ Build-Depends: debhelper (>= 9),
python3,
python3-setuptools,
quilt,
- python3-lxml
+ python3-lxml,
+ python3-nose,
+ python3-coverage
Standards-Version: 3.9.6
Package: vyos-1x
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..92c231c6f
--- /dev/null
+++ b/op-mode-definitions/show-arp.xml
@@ -0,0 +1,25 @@
+<?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>${vyos_completion_dir}/list_interfaces.py -b</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..a3241951a
--- /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>${vyos_completion_dir}/list_interfaces.py --type 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..0b1507ba4
--- /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>cli-shell-api showCfg --show-active-only | vyos-config-to-commands</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..705172b39
--- /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>${vyos_op_scripts_dir}/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..6cd912aea
--- /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>${vyos_op_scripts_dir}/cpu_summary.py</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/maya_date.py b/src/op_mode/maya_date.py
new file mode 100755
index 000000000..7d8aefc91
--- /dev/null
+++ b/src/op_mode/maya_date.py
@@ -0,0 +1,209 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2013, 2018 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import sys
+
+class MayaDate(object):
+ """ Converts number of days since UNIX epoch
+ to the Maya calendar date.
+
+ Ancient Maya people used three independent calendars for
+ different purposes.
+
+ The long count calendar is for recording historical events.
+ It represents the number of days passed
+ since some date in the past the Maya believed is the day
+ our world was created.
+
+ Tzolkin calendar is for religious purposes, it has
+ two independent cycles of 13 and 20 days, where 13 day
+ cycle days are numbered, and 20 day cycle days are named.
+
+ Haab calendar is for agriculture and daily life, it's a
+ 365 day calendar with 18 months 20 days each, and 5
+ nameless days.
+
+ The smallest unit of the long count calendar is one day (kin).
+
+ """
+
+ """ The long count calendar uses five different base 18 or base 20
+ cycles. Modern scholars write long count calendar dates in a dot separated format
+ from longest to shortest cycle,
+ <baktun>.<katun>.<tun>.<winal>.<kin>
+ for example, "13.0.0.9.2".
+
+ Classic version actually used by the ancient Maya wraps around
+ every 13th baktun, but modern historians often use longer cycles
+ such as piktun = 20 baktun.
+
+ """
+ kin = 1
+ winal = 20 # 20 kin
+ tun = 360 # 18 winal
+ katun = 7200 # 20 tun
+ baktun = 144000 # 20 katun
+
+ """ Tzolk'in date is composed of two independent cycles.
+ Dates repeat every 260 days, 13 Ajaw is considered the end
+ of tzolk'in.
+
+ Every day of the 20 day cycle has unique name, we number
+ them from zero so it's easier to map the remainder to day:
+ """
+ tzolkin_days = { 0: "Imix'",
+ 1: "Ik'",
+ 2: "Ak'b'al",
+ 3: "K'an",
+ 4: "Chikchan",
+ 5: "Kimi",
+ 6: "Manik'",
+ 7: "Lamat",
+ 8: "Muluk",
+ 9: "Ok",
+ 10: "Chuwen",
+ 11: "Eb'",
+ 12: "B'en",
+ 13: "Ix",
+ 14: "Men",
+ 15: "Kib'",
+ 16: "Kab'an",
+ 17: "Etz'nab'",
+ 18: "Kawak",
+ 19: "Ajaw" }
+
+ """ As said above, haab (year) has 19 months. Only 18 are
+ true months of 20 days each, the remaining 5 days called "wayeb"
+ do not really belong to any month, but we think of them as a pseudo-month
+ for convenience.
+
+ Also, note that days of the month are actually numbered from 0, not from 1,
+ it's not for technical reasons.
+ """
+ haab_months = { 0: "Pop",
+ 1: "Wo'",
+ 2: "Sip",
+ 3: "Sotz'",
+ 4: "Sek",
+ 5: "Xul",
+ 6: "Yaxk'in'",
+ 7: "Mol",
+ 8: "Ch'en",
+ 9: "Yax",
+ 10: "Sak'",
+ 11: "Keh",
+ 12: "Mak",
+ 13: "K'ank'in",
+ 14: "Muwan'",
+ 15: "Pax",
+ 16: "K'ayab",
+ 17: "Kumk'u",
+ 18: "Wayeb'" }
+
+ """ Now we need to map the beginning of UNIX epoch
+ (Jan 1 1970 00:00 UTC) to the beginning of the long count
+ calendar (0.0.0.0.0, 4 Ajaw, 8 Kumk'u).
+
+ The problem with mapping the long count calendar to
+ any other is that its start date is not known exactly.
+
+ The most widely accepted hypothesis suggests it was
+ August 11, 3114 BC gregorian date. In this case UNIX epoch
+ starts on 12.17.16.7.5, 13 Chikchan, 3 K'ank'in
+
+ It's known as Goodman-Martinez-Thompson (GMT) correlation
+ constant.
+ """
+ start_days = 1856305
+
+ """ Seconds in day, for conversion from timestamp """
+ seconds_in_day = 60 * 60 * 24
+
+ def __init__(self, timestamp):
+ if timestamp is None:
+ self.days = self.start_days
+ else:
+ self.days = self.start_days + (int(timestamp) // self.seconds_in_day)
+
+ def long_count_date(self):
+ """ Returns long count date string """
+ days = self.days
+
+ cur_baktun = days // self.baktun
+ days = days % self.baktun
+
+ cur_katun = days // self.katun
+ days = days % self.katun
+
+ cur_tun = days // self.tun
+ days = days % self.tun
+
+ cur_winal = days // self.winal
+ days = days % self.winal
+
+ cur_kin = days
+
+ longcount_string = "{0}.{1}.{2}.{3}.{4}".format( cur_baktun,
+ cur_katun,
+ cur_tun,
+ cur_winal,
+ cur_kin )
+ return(longcount_string)
+
+ def tzolkin_date(self):
+ """ Returns tzolkin date string """
+ days = self.days
+
+ """ The start date is not the beginning of both cycles,
+ it's 4 Ajaw. So we need to add 4 to the 13 days cycle day,
+ and substract 1 from the 20 day cycle to get correct result.
+ """
+ tzolkin_13 = (days + 4) % 13
+ tzolkin_20 = (days - 1) % 20
+
+ tzolkin_string = "{0} {1}".format(tzolkin_13, self.tzolkin_days[tzolkin_20])
+
+ return(tzolkin_string)
+
+ def haab_date(self):
+ """ Returns haab date string.
+
+ The time start on 8 Kumk'u rather than 0 Pop, which is
+ 17 days before the new haab, so we need to substract 17
+ from the current date to get correct result.
+ """
+ days = self.days
+
+ haab_day = (days - 17) % 365
+ haab_month = haab_day // 20
+ haab_day_of_month = haab_day % 20
+
+ haab_string = "{0} {1}".format(haab_day_of_month, self.haab_months[haab_month])
+
+ return(haab_string)
+
+ def date(self):
+ return("{0}, {1}, {2}".format( self.long_count_date(), self.tzolkin_date(), self.haab_date() ))
+
+if __name__ == '__main__':
+ try:
+ timestamp = sys.argv[1]
+ except:
+ print("Please specify timestamp in the argument")
+ sys.exit(1)
+
+ maya_date = MayaDate(timestamp)
+ print(maya_date.date())
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