if [[ $# -lt 2 ]];then echo "请输入2个位置参数..." exit 1 else num=$# while(($#>=1));do case ${num} in 2) if ! echo "${1}" | grep -qP "\d+\.\d+\.\d+\.\d+";then echo "中心机IP输入格式不对..." exit 1 fi SALT_MASTER_IP=${1} ;; 1) if ! echo "${1}" | grep -qP "AAAA_\w+_(ENGINE|COMMON|WEB)_\d+\.\d+\.\d+\.\d+";then echo "salt-minion主机名不对..." exit 1 fi SALT_MINION_LOCAL=${1} ;; *) echo "输入超过2个位置参数无效..." echo "salt-minion.sh 中心机IP 本地主机名" exit 1 ;; esac num=`expr ${num} - 1` shift done fi