diff options
author | Bob Gilligan <gilligan@vyatta.com> | 2008-10-29 16:32:30 -0700 |
---|---|---|
committer | Bob Gilligan <gilligan@vyatta.com> | 2008-10-29 16:32:30 -0700 |
commit | 78e41fb517a63c4a9cc225975e4714f84918149d (patch) | |
tree | 5a490f5f62b8be03c18b230e50bb1f7c327d86a5 /templates/format | |
parent | 5304fabe0b0eb212936ca1f47e4cf98d73fd6b81 (diff) | |
download | vyatta-op-78e41fb517a63c4a9cc225975e4714f84918149d.tar.gz vyatta-op-78e41fb517a63c4a9cc225975e4714f84918149d.zip |
Bugfix: 3841: Allow admin level users to run the RAID op mode commands.
Diffstat (limited to 'templates/format')
-rw-r--r-- | templates/format/disk/node.tag/like/node.tag/node.def | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/templates/format/disk/node.tag/like/node.tag/node.def b/templates/format/disk/node.tag/like/node.tag/node.def index 8927dc8..588e633 100644 --- a/templates/format/disk/node.tag/like/node.tag/node.def +++ b/templates/format/disk/node.tag/like/node.tag/node.def @@ -10,12 +10,12 @@ allowed: run: proto_disk=$5 format_disk=$3 - backup_dir=/var/log/vyatta + backup_dir=/var/tmp eligible_format_disks=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` eligible_proto_disks=`echo $eligible_format_disks | sed -e s/$format_disk//g` proto_eligible=`echo $eligible_proto_disks | grep $proto_disk` format_eligible=`echo $eligible_format_disks | grep $format_disk` - busy_check=`sfdisk -R /dev/$format_disk 2>&1` + busy_check=`sudo /sbin/sfdisk -R /dev/$format_disk 2>&1` if [ $proto_disk = $format_disk ]; then echo "The two disk drives must be different." @@ -29,6 +29,8 @@ run: echo "Device $proto_disk can not be used as a prototype for $format_disk" elif [ -n "$busy_check" ]; then echo "Disk device $format_disk is busy. Can't format it now." + elif [ ! -r /dev/$format_disk ]; then + echo "Must be admin or root to format disk" else echo "This will re-format disk $format_disk so that it has the same disk" echo "partion sizes and offsets as $proto_disk. This will not copy" @@ -40,18 +42,18 @@ run: if [ "$response" = "yes" ]; then echo "OK. Re-formating disk drive $format_disk..." echo "Making backup copy of partitions..." - sfdisk -d /dev/$format_disk > $backup_dir/backup_$format_disk.`date +%F-%R` + sudo /sbin/sfdisk -d /dev/$format_disk > $backup_dir/backup_$format_disk.`date +%F-%R` sleep 1 partitions=`cat /proc/partitions | grep $format_disk'[0-9]' | awk '{ print $4 }' | sed 's/[a-z]//g'` if [ -n "$partitions" ]; then echo -n "Deleting old partitions..." for part in $partitions ; do - parted /dev/$format_disk rm $part + sudo /sbin/parted /dev/$format_disk rm $part done echo "" fi echo "Creating new partitions on $format_disk based on $proto_disk..." - sfdisk -d /dev/$proto_disk | sfdisk --force /dev/$format_disk + sudo /sbin/sfdisk -d /dev/$proto_disk | sudo /sbin/sfdisk --force /dev/$format_disk echo "Done." else echo "OK. Disk drive $format_drive will not be re-formated." |