diff options
author | Christian Breunig <christian@poessinger.com> | 2023-09-22 16:54:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-22 16:54:45 +0200 |
commit | 258dccb848c1cdf056e04496ad0c911c61e4d8ca (patch) | |
tree | a5fc3a93db5552fbfb1d347be29b4afbd4cfd613 | |
parent | b3123af7031e74ee53c215a34d685a421aad5eb3 (diff) | |
parent | 5add0724c0aed58ffe0b3dea2c8c00192c6aec0f (diff) | |
download | vyatta-op-258dccb848c1cdf056e04496ad0c911c61e4d8ca.tar.gz vyatta-op-258dccb848c1cdf056e04496ad0c911c61e4d8ca.zip |
Merge pull request #72 from c-po/sagitta
op-mode: raid: T5608: add/delete raid template now in vyos-1x
-rw-r--r-- | templates/add/raid/node.def | 1 | ||||
-rw-r--r-- | templates/add/raid/node.tag/member/node.def | 1 | ||||
-rw-r--r-- | templates/add/raid/node.tag/member/node.tag/node.def | 41 | ||||
-rw-r--r-- | templates/add/raid/node.tag/node.def | 6 | ||||
-rw-r--r-- | templates/delete/raid/node.def | 1 | ||||
-rw-r--r-- | templates/delete/raid/node.tag/member/node.def | 1 | ||||
-rw-r--r-- | templates/delete/raid/node.tag/member/node.tag/node.def | 37 | ||||
-rw-r--r-- | templates/delete/raid/node.tag/node.def | 6 |
8 files changed, 0 insertions, 94 deletions
diff --git a/templates/add/raid/node.def b/templates/add/raid/node.def deleted file mode 100644 index 26cc4a3..0000000 --- a/templates/add/raid/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Add a RAID set element diff --git a/templates/add/raid/node.tag/member/node.def b/templates/add/raid/node.tag/member/node.def deleted file mode 100644 index fd2bc72..0000000 --- a/templates/add/raid/node.tag/member/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Add a member to a RAID set diff --git a/templates/add/raid/node.tag/member/node.tag/node.def b/templates/add/raid/node.tag/member/node.tag/node.def deleted file mode 100644 index 198bc99..0000000 --- a/templates/add/raid/node.tag/member/node.tag/node.def +++ /dev/null @@ -1,41 +0,0 @@ -help: Name of RAID set member to add - -allowed: - raid_set=${COMP_WORDS[2]} - membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` - membership=`echo $membership | sed -e 's/(F)//g'` - partitions=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep "[0-9]"` - for member in $membership; do - partitions=`echo $partitions | sed -e s/$member//g` - done - partitions=`echo $partitions | sed -e 's/md[0-9]*//g'` - echo "$partitions" - -run: - raid_set=$3 - member_to_add=$5 - membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` - is_in=`echo $membership | grep $member_to_add` - - partitions=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep "[0-9]"` - partitions=`echo $partitions | sed -e 's/md[0-9]*//g'` - valid_partition=`echo $partitions | grep $member_to_add` - - if [ -z "$membership" ]; then - echo "$raid_set is not a RAID set" - elif [ -n "$is_in" ]; then - echo "$member_to_add is already a member of RAID set $raid_set" - 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" - sudo /sbin/mdadm /dev/$raid_set --add /dev/$member_to_add - if [ $? -ne 0 ]; then - echo "Unable to add member to RAID set" - fi - disk=$(lsblk -ndo pkname /dev/$member_to_add) - sudo grub-install /dev/$disk - fi
\ No newline at end of file diff --git a/templates/add/raid/node.tag/node.def b/templates/add/raid/node.tag/node.def deleted file mode 100644 index e0ae4d9..0000000 --- a/templates/add/raid/node.tag/node.def +++ /dev/null @@ -1,6 +0,0 @@ -help: Name of RAID set to add object to - -allowed: - local -a array ; - array=`cat /proc/partitions | grep md | awk '{ print $4 }'` - echo -n $array diff --git a/templates/delete/raid/node.def b/templates/delete/raid/node.def deleted file mode 100644 index 2700b93..0000000 --- a/templates/delete/raid/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Remove a RAID set element diff --git a/templates/delete/raid/node.tag/member/node.def b/templates/delete/raid/node.tag/member/node.def deleted file mode 100644 index 52c411b..0000000 --- a/templates/delete/raid/node.tag/member/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Remove a member of a RAID set diff --git a/templates/delete/raid/node.tag/member/node.tag/node.def b/templates/delete/raid/node.tag/member/node.tag/node.def deleted file mode 100644 index a48fd4a..0000000 --- a/templates/delete/raid/node.tag/member/node.tag/node.def +++ /dev/null @@ -1,37 +0,0 @@ -help: Name of RAID set member to remove - -allowed: - raid_set=${COMP_WORDS[2]} - membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` - membership=`echo $membership | sed -e 's/(F)//g'` - echo "$membership" - -run: - raid_set=$3 - member_to_remove=$5 - membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` - num_members=`echo $membership | wc -w` - is_in=`echo $membership | grep $member_to_remove` - - if [ -z "$membership" ]; then - echo "$raid_set is not a RAID set" - elif [ -z "$is_in" ]; then - echo "$member_to_remove is not a member of RAID set $raid_set" - 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" - 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 - sudo /sbin/mdadm /dev/$raid_set --remove /dev/$member_to_remove - if [ $? -ne 0 ]; then - echo "Unable to remove member from RAID set" - fi - fi - fi diff --git a/templates/delete/raid/node.tag/node.def b/templates/delete/raid/node.tag/node.def deleted file mode 100644 index a8d8485..0000000 --- a/templates/delete/raid/node.tag/node.def +++ /dev/null @@ -1,6 +0,0 @@ -help: Name of RAID set to remove object from - -allowed: - local -a array ; - array=`cat /proc/partitions | grep md | awk '{ print $4 }'` - echo -n $array |