#!/bin/bash echo "创建成功的用户" > /root/user_name read -ep "输入要创建的用户:" num for i in `seq 1 $num` do pw=`cat /dev/null/uradom | head -1 | md5sum | head -c 5` id wg$i > /dev/null 2&1 if [ $? -eq 0 ];then echo "该用户存在" read -ep "是否删除此用户(y/n):" select case $select in y|Y) userdel -rf wg$i > /dev/null echo "wg$i删除成功" ;; n|N) continue ;; *) echo "输入字符有误,重新输入" esac else useradd wg$i > /dev/null 2>&1 if [ $? -eq 0 ];then echo "wg$i用户创建成功" echo "wg$ipw" | passwd --stdin wg$i echo "wg$i $pw" >> /root/user_name else echo "用户创建失败" fi fi done