1. #!/bin/bash
    2. #Eren by 2020-06-30
    3. #修改hosts文件
    4. HostName=$HOSTNAME
    5. HostIP=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep -v 192.168 |awk '{print $2}'|tr -d "addr:"`
    6. echo "$HostIP" " " "$HostName" >> /etc/hosts
    7. #文件系统配置
    8. pvcreate /dev/vdb
    9. if [ $? -eq 0 ];then
    10. echo -e "逻辑卷创建完成" "\033[32m Success\033[0m"
    11. else
    12. echo -e "未添加数据盘" "\033[31m Failure\033[0m"
    13. echo ""
    14. sleep 5
    15. exit
    16. fi
    17. echo ""
    18. vgcreate appvg /dev/vdb
    19. lvcreate -n edsplv -L 5G appvg
    20. mkfs.ext4 /dev/appvg/edsplv
    21. mkdir -p /home/edsp
    22. mount /dev/appvg/edsplv /home/edsp
    23. lvcreate -n boccfclv -L 5G appvg
    24. mkfs.ext4 /dev/appvg/boccfclv
    25. mkdir -p /home/boccfc
    26. mount /dev/appvg/boccfclv /home/boccfc
    27. lvcreate -n applv -l 100%free appvg
    28. mkfs.ext4 /dev/appvg/applv
    29. mkdir -p /app
    30. mount /dev/appvg/applv /app
    31. if [ $? -eq 0 ];then
    32. echo -e "文件系统创建完成" "\033[32m Success\033[0m"
    33. else
    34. echo -e "文件系统创建失败" "\033[31m Failure\033[0m"
    35. sleep 3
    36. exit
    37. fi
    38. echo "/dev/appvg/edsplv /home/edsp ext4 defaults 0 0 " >> /etc/fstab
    39. echo "/dev/appvg/boccfclv /home/boccfc ext4 defaults 0 0 " >> /etc/fstab
    40. echo "/dev/appvg/applv /app ext4 defaults 0 0 " >> /etc/fstab
    41. #添加普通用户
    42. groupadd -g 300 edsp
    43. useradd -g 300 -u 300 -d /home/edsp -m -G edsp edsp
    44. cp -av /etc/skel/\.[[:alpha:]]* /home/edsp
    45. echo "123456" | passwd --stdin edsp
    46. chage -d 0 edsp
    47. groupadd -g 310 boccfc
    48. useradd -g 310 -u 310 -d /home/boccfc -m -G boccfc boccfc
    49. cp -av /etc/skel/\.[[:alpha:]]* /home/boccfc
    50. echo "123456" | passwd --stdin boccfc
    51. chage -d 0 boccfc
    52. chown -R edsp:edsp /home/edsp
    53. chown -R boccfc:boccfc /home/boccfc
    54. chown -R boccfc:boccfc /app
    55. #修改时间服务地址
    56. sed -i "s/server 10.82.200.81 iburst/server 10.82.100.81 iburst/g" /etc/chrony.conf
    57. timedatectl set-timezone Asia/Shanghai
    58. systemctl restart chronyd.service
    59. hwclock -w
    60. chronyc tracking
    61. chronyc -a makestep
    62. #普通用户禁用定时任务
    63. touch /etc/cron.allow
    64. #
    65. sed -i 's|GSSAPIAuthentication yes|#GSSAPIAuthentication yes|' /etc/ssh/ssh_config
    66. #检查文件系统挂载
    67. mount -a
    68. df -Th
    69. ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep -v 192.168 |awk '{print $2}'
    70. cat /etc/hosts