2 read -p "输入你要创建的用户名:" USER
3 id $USER >/dev/null
4 A=`echo $?`
5 while [ $A -eq 0 ]; do
6 read -p "请重新输入用户:" USER
7 id $USER >/dev/null
8 A=`echo $?`
9 done
10 read -p "请输入用户的用户号:" U
11 cut -d: -f3 /etc/passwd | grep $U
12 B=`echo $?`
13 while [ $B -eq 0 ]; do
14 read -p "请重新输入用户的用户号:" U
15 cut -d: -f3 /etc/passwd |grep $U
16 B=`echo $?`
17 done
18 read -p "请输入用户的组名:" GP
19 cut -d: -f1 /etc/group | grep "\b$GP\b"
20 D=`echo $?`
21 while [ $D -eq 0 ]; do
22 read -p "请重新输入用户的组名:" GP
23 cut -d: -f1 /etc/group | grep "\b$GP\b"
24 D=`echo $?`
25 done
26 read -p "请输入用户的组号:" GID
27 cut -d: -f4 /etc/passwd | grep $GID
28 C=`echo $?`
29 while [ $C -eq 0 ]; do
30 read -p "请重新输入用户的组号:" GID
31 cut -d: -f4 /etc/passwd | grep $GId
32 C=`echo $?`
33 done
34 read -p "输入用户默认的shell:" SH
35 read -p "输入用户密码:" PS
36 F=`openssl passwd -1 -salt qwesdrtf $PS`
37 E=$[`date '+%s'`/86400]
38 echo "$GP:x:$GID:" >>/etc/group
39 echo "$USER:x:$U:$GID::/home/$USER:$SH" >>/etc/passwd
40 echo "$USER:$F:$E:0:99999:7:::" >>/etc/shadow
41 mkdir /home/$USER
42 cp -r /etc/skel/.* /home/$USER
43 chown -R $USER:$GP /home/$USER
44 chmod -R 700 /home/$USER
2 IFCFG="/etc/sysconfig/network-scripts/"
3 I="ifcfg-"
4 read -p "请输入你要设置的网卡:" ETH
5 while [ -z $ETH ]; do
6 read -p "请重新输入网卡:" ETH
7 done
8 ls $IFCFG | grep "$I$ETH$" >>/dev/null
9 H=`echo $?`
10 while [ $H -ne 0 ]; do
11 echo "您输入网卡有误!!"
12 read -p "请重新输入你要设置的网卡:" ETH
13 ls $IFCFG | grep "$I$ETH$" >>/dev/null
14 H=`echo $?`
15 done
16 read -p "请输入网卡的BOOPROTO值dhcp|static:" BOOPROTO
17 if [ $BOOPROTO == "dhcp" ];then
18 cat > $IFCFG$I$ETH << end
19 #Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
20 DEVICE=$ETH
21 BOOTPROTO=dhcp
22 DHCPCLASS=
23 ONBOOT=yes
24 end
25 echo "请稍后......"
26 ifdown $ETH && ifup $ETH >/dev/null
27 echo "你选择的配置信息是:"
28 cat $IFCFG$I$ETH
29 elif [ $BOOPROTO == "static" ];then
30 read -p "输入ip地址:" IP
31 while [ -z $IP ]; do
32 read -p "请重新输入ip地址:" IP
33 done
34 read -p "输入子网掩码:" MASK
35 while [ -z $MASK ]; do
36 read -p "请重新输入子网掩码:" MASK
37 done
38 read -p"输入默认网关:" GW
39 cat > $IFCFG$I$ETH << end
40 #Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
41 DEVICE=$ETH
42 BOOTPROTO=static
43 IPADDR=$IP
44 NETMASK=$MASK
45 GETWAY=$GW
46 ONBOOT=yes
47 end
48 echo "请稍后....."
49 ifdown $ETH && ifup $ETH
50 echo "您配置的信息是:"
51 cat $IFCFG$I$ETH
52 fi