summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorRick Balocca <rbalocca@vyatta.com>2008-10-30 14:22:01 -0700
committerRick Balocca <rbalocca@vyatta.com>2008-10-30 14:22:01 -0700
commit098d792ab2680aefd2d3a3d0a680b39e5a2787ba (patch)
treecfff2cc9711395b9a96cfe44a77184022be7b845 /templates
parente987d4d534ea2f1873658c08501fa21b4d3960bb (diff)
parent78e41fb517a63c4a9cc225975e4714f84918149d (diff)
downloadvyatta-op-098d792ab2680aefd2d3a3d0a680b39e5a2787ba.tar.gz
vyatta-op-098d792ab2680aefd2d3a3d0a680b39e5a2787ba.zip
Merge branch 'islavista' into jenner
Diffstat (limited to 'templates')
-rw-r--r--templates/add/raid/node.tag/member/node.tag/node.def4
-rw-r--r--templates/format/disk/node.tag/like/node.tag/node.def12
-rw-r--r--templates/remove/raid/node.tag/member/node.tag/node.def6
-rw-r--r--templates/show/disk/node.tag/format/node.def4
-rw-r--r--templates/show/history/node.tag/node.def4
-rw-r--r--templates/show/raid/node.tag/node.def9
6 files changed, 27 insertions, 12 deletions
diff --git a/templates/add/raid/node.tag/member/node.tag/node.def b/templates/add/raid/node.tag/member/node.tag/node.def
index 293b4ea..b30c313 100644
--- a/templates/add/raid/node.tag/member/node.tag/node.def
+++ b/templates/add/raid/node.tag/member/node.tag/node.def
@@ -28,9 +28,11 @@ run:
echo "actual members are: $membership"
elif [ -z "$valid_partition" ]; then
echo "$member_to_add is not a valid disk partition"
+ elif [ ! -r /dev/$raid_set ]; then
+ echo "Must be admin or root to add RAID set member"
else
echo "adding member $member_to_add to RAID set $raid_set"
- mdadm /dev/$raid_set --add /dev/$member_to_add
+ sudo /sbin/mdadm /dev/$raid_set --add /dev/$member_to_add
if [ $? -ne 0 ]; then
echo "Unable to add member to RAID set"
fi
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."
diff --git a/templates/remove/raid/node.tag/member/node.tag/node.def b/templates/remove/raid/node.tag/member/node.tag/node.def
index d384fd3..a48fd4a 100644
--- a/templates/remove/raid/node.tag/member/node.tag/node.def
+++ b/templates/remove/raid/node.tag/member/node.tag/node.def
@@ -20,14 +20,16 @@ run:
echo "actual members are: $membership"
elif [ "$num_members" -eq "1" ]; then
echo "Can't remove last member of a RAID set"
+ elif [ ! -r /dev/$raid_set ]; then
+ echo "Must be admin or root to remove RAID set member"
else
echo "removing member $member from RAID set $raid_set"
- mdadm /dev/$raid_set --fail /dev/$member_to_remove
+ sudo /sbin/mdadm /dev/$raid_set --fail /dev/$member_to_remove
if [ $? -ne 0 ]; then
echo "Unable to mark member as failed"
else
sleep 1
- mdadm /dev/$raid_set --remove /dev/$member_to_remove
+ sudo /sbin/mdadm /dev/$raid_set --remove /dev/$member_to_remove
if [ $? -ne 0 ]; then
echo "Unable to remove member from RAID set"
fi
diff --git a/templates/show/disk/node.tag/format/node.def b/templates/show/disk/node.tag/format/node.def
index e05b4ad..e5829ca 100644
--- a/templates/show/disk/node.tag/format/node.def
+++ b/templates/show/disk/node.tag/format/node.def
@@ -7,6 +7,8 @@ run:
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
- fdisk -l /dev/${disk_dev}
+ /sbin/fdisk -l /dev/${disk_dev}
fi
diff --git a/templates/show/history/node.tag/node.def b/templates/show/history/node.tag/node.def
index 2c77a35..a8c3755 100644
--- a/templates/show/history/node.tag/node.def
+++ b/templates/show/history/node.tag/node.def
@@ -1,3 +1,3 @@
-help: Display last commands in history
+help: Display last N commands in history
allowed: echo -n '<NUMBER>'
-run: HISTTIMEFORMAT='%FT%T%z ' history
+run: HISTTIMEFORMAT='%FT%T%z ' history $3
diff --git a/templates/show/raid/node.tag/node.def b/templates/show/raid/node.tag/node.def
index bc83a73..4f9928d 100644
--- a/templates/show/raid/node.tag/node.def
+++ b/templates/show/raid/node.tag/node.def
@@ -12,5 +12,12 @@ run:
if [ -z $valid_set ]; then
echo "$raid_set_name is not a RAID set"
else
- mdadm --detail /dev/${raid_set_name}
+ 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 \ No newline at end of file