diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-03-11 17:21:08 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-03-11 17:46:40 -0700 |
commit | afa4740db04c68dd31a999e05fd2ceca84b88c5d (patch) | |
tree | 21815a3593bfa06d08da0b0545240d69326077af /templates/show/disk | |
parent | 502696da2f17891ae46742f4ffb8d85fef476e7c (diff) | |
download | vyatta-op-afa4740db04c68dd31a999e05fd2ceca84b88c5d.tar.gz vyatta-op-afa4740db04c68dd31a999e05fd2ceca84b88c5d.zip |
Cleanup show disk format
Allow non-root to use 'show disk format'
Check for block device.
Use awk more effectivedly in finding disk names
Diffstat (limited to 'templates/show/disk')
-rw-r--r-- | templates/show/disk/node.tag/format/node.def | 18 | ||||
-rw-r--r-- | templates/show/disk/node.tag/node.def | 5 |
2 files changed, 6 insertions, 17 deletions
diff --git a/templates/show/disk/node.tag/format/node.def b/templates/show/disk/node.tag/format/node.def index e5829ca..4b09369 100644 --- a/templates/show/disk/node.tag/format/node.def +++ b/templates/show/disk/node.tag/format/node.def @@ -1,14 +1,6 @@ help: Show disk drive formatting - -run: - disk_dev=$3 - valid_disks=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` - is_a_disk=`echo $valid_disks | grep $disk_dev` - - if [ -z "$is_a_disk" ]; then - echo "$disk_dev is not a disk device" - elif [ ! -r /dev/${disk_dev} ]; then - echo "Must be admin or root to display disk formating" - else - /sbin/fdisk -l /dev/${disk_dev} - fi +run: dev=/dev/$3 + if [ ! -b $dev ] + then echo "$3 is not a disk device"; exit 1 + fi + /sbin/fdisk -l /dev/${disk_dev} diff --git a/templates/show/disk/node.tag/node.def b/templates/show/disk/node.tag/node.def index 7e4fe05..8690008 100644 --- a/templates/show/disk/node.tag/node.def +++ b/templates/show/disk/node.tag/node.def @@ -1,7 +1,4 @@ help: Disk device name +allowed: awk 'NR > 2 && $4 !~ /[0-9]$/ { print $4 }' </proc/partitions -allowed: - local -a array ; - array=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` - echo -n $array |