1. 运行脚本可以显示出本机的ip地址
2. 如果ip地址中有3这个数字,那么就打印出当前的系统时间
3. 如果ip地址中不含3这个数字,就批量建立用户magedu_00, magedu_01, ... magedu_100并且所有用户同属于magedu组
4. 打印出/etc/passwd这个文件中可以登陆的用户(非/usr/sbin/nologin)
5. yum安装nginx服务,并且启动该服务
6. 一个脚本完成
#!/bin/bash
IP () {
IPADDR=` hostname -I | cut -d' ' -f1`
echo "IPADDR: $IPADDR "
if $IPADDR | grep '3' ;then
echo "time: `date +%F%n%T`"
else groupadd magedu;
for i in {00..100};do
useradd mage_$i -g magedu ; echo mage_$i is created;
done
fi
echo -e "`grep -v '/sbin/nologin'$ /etc/passwd`";
}&
nginx () {
yum -y install nginx;
systemctl start nginx
systemctl status nginx
}&
IP
nginx