Sdp入参预检测

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#判断入参及入参要求是否符合。
if [ "$#" = 5 ]; then
  #判断用户是否存在
  if [ -d ${INIT_HOME}/$1 ]; then
    echo -e "\033[31mThe user already exists\033[0m" 2>&1
    echo "${PreciseTime} $1 $5 ErrAction:\"The user already exists\"" >> $Errlog
        exit 1
  fi
  #判断时间格式
  if [[ "$2" =~ ^[0-9]+$ ]]; then
    :
  else
    echo "第二个参数要求为正整数,单位为月!"
    echo "${PreciseTime} $1 $5 ErrAction:\"使用时间参数错误\" " >> $Errlog
    exit 1;
  fi
  #判断服务类型
  if echo "${services[@]}" | grep -w $3 &> /dev/null ;then
    :
  else
    echo -e "\033[31m不支持的服务类型\033[0m" 2>&1
    echo "${PreciseTime} $1 $5 ErrAction:\"不支持的服务类型\"" >> $Errlog
        exit 1
  fi
  #判断文件代码类型
  if [ $4 = "svn" ] || [ $4 = "ftp" ] || [ $4 = "-" ] || [ $4 = "null" ];then
    :
  else
    echo -e "\033[31m不支持的代码类型\033[0m" 2>&1
    echo "${PreciseTime} $1 $5 ErrAction:\"不支持的代码类型\"" >> $Errlog
        exit 1
  fi
  #判断邮箱格式
  if [[ `echo $5 | sed -r '/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/!d'` == "" ]]; then
    echo "邮箱格式不正确!"
    echo "${PreciseTime} ${init_user} ${user_email} ErrAction:\"邮箱格式不正确\" " >> $Errlog
    exit 1;
  fi