#!/bin/bash #set -x #Usage: rule="" wwpn="" targetwwpn="" vtl="" print_usage() { echo "Usage:" echo "deletefcrules.sh -w will delete rules for the specified wwpn" echo "deletefcrules.sh -t will delete rules for the specified target wwpn" echo "deletefcrules.sh -v will delete rules for the specified VTL" echo "deletefcrules.sh -a will delete all rules" } export PATH="/quadstorvtl/bin:/quadstorvtl/quadstor/scctl:$PATH" while getopts "v:w:r:t:ah" opt; do case $opt in w) wwpn="$OPTARG" rule="All" targetwwpn="All" vtl="All" ;; t) targetwwpn="$OPTARG" rule="All" wwpn="All" vtl="All" ;; v) vtl="$OPTARG" rule="All" wwpn="All" targetwwpn="All" ;; r) rule="$OPTARG" wwpn="All" targetwwpn="All" vtl="All" ;; a) rule="All" wwpn="All" targetwwpn="All" vtl="All" ;; h) print_usage exit 0 esac done if [ "$rule" = "" ]; then print_usage exit 1 fi if [ "$rule" = "Deny" ]; then rule="Disallow" fi rules=`fcconfig -l | sed -n '1!p'` while read -r line; do _wwpn=`echo $line | awk '{print $1}'` _targetwwpn=`echo $line | awk '{print $2}'` _rule=`echo $line | awk '{print $3}'` _vtl=`echo $line | awk '{print $4}'` _drive=`echo $line | awk '{print $5}'` if [ "$_rule" = "Deny" ]; then _rule="Disallow" fi if [ "$wwpn" != "All" ]; then if [ "$_wwpn" != "$wwpn" ]; then continue fi elif [ "$targetwwpn" != "All" ]; then if [ "$_targetwwpn" != "$targetwwpn" ]; then continue fi elif [ "$vtl" != "All" ]; then if [ "$_vtl" != "$vtl" ]; then continue fi elif [ "$rule" != "All" ]; then if [ "$_rule" != "$rule" ]; then continue fi fi str="fcconfig -x -r $_rule" if [ "$_wwpn" != "All" ]; then str="$str -w $_wwpn" fi if [ "$_targetwwpn" != "All" ]; then str="$str -t $_targetwwpn" fi if [ "$_vtl" != "All" ]; then str="$str -v $_vtl" fi if [ "$_drive" != "0" ]; then str="$str -d $_drive" fi echo "Exec $str" $str done <<< "$rules"