#!/bin/bash
#Eren by 2020-06-30
#修改hosts文件
HostName=$HOSTNAME
HostIP=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep -v 192.168 |awk '{print $2}'|tr -d "addr:"`
echo "$HostIP" " " "$HostName" >> /etc/hosts
#文件系统配置
pvcreate /dev/vdb
if [ $? -eq 0 ];then
echo -e "逻辑卷创建完成" "\033[32m Success\033[0m"
else
echo -e "未添加数据盘" "\033[31m Failure\033[0m"
echo ""
sleep 5
exit
fi
echo ""
vgcreate appvg /dev/vdb
lvcreate -n edsplv -L 5G appvg
mkfs.ext4 /dev/appvg/edsplv
mkdir -p /home/edsp
mount /dev/appvg/edsplv /home/edsp
lvcreate -n boccfclv -L 5G appvg
mkfs.ext4 /dev/appvg/boccfclv
mkdir -p /home/boccfc
mount /dev/appvg/boccfclv /home/boccfc
lvcreate -n applv -l 100%free appvg
mkfs.ext4 /dev/appvg/applv
mkdir -p /app
mount /dev/appvg/applv /app
if [ $? -eq 0 ];then
echo -e "文件系统创建完成" "\033[32m Success\033[0m"
else
echo -e "文件系统创建失败" "\033[31m Failure\033[0m"
sleep 3
exit
fi
echo "/dev/appvg/edsplv /home/edsp ext4 defaults 0 0 " >> /etc/fstab
echo "/dev/appvg/boccfclv /home/boccfc ext4 defaults 0 0 " >> /etc/fstab
echo "/dev/appvg/applv /app ext4 defaults 0 0 " >> /etc/fstab
#添加普通用户
groupadd -g 300 edsp
useradd -g 300 -u 300 -d /home/edsp -m -G edsp edsp
cp -av /etc/skel/\.[[:alpha:]]* /home/edsp
echo "123456" | passwd --stdin edsp
chage -d 0 edsp
groupadd -g 310 boccfc
useradd -g 310 -u 310 -d /home/boccfc -m -G boccfc boccfc
cp -av /etc/skel/\.[[:alpha:]]* /home/boccfc
echo "123456" | passwd --stdin boccfc
chage -d 0 boccfc
chown -R edsp:edsp /home/edsp
chown -R boccfc:boccfc /home/boccfc
chown -R boccfc:boccfc /app
#修改时间服务地址
sed -i "s/server 10.82.200.81 iburst/server 10.82.100.81 iburst/g" /etc/chrony.conf
timedatectl set-timezone Asia/Shanghai
systemctl restart chronyd.service
hwclock -w
chronyc tracking
chronyc -a makestep
#普通用户禁用定时任务
touch /etc/cron.allow
#
sed -i 's|GSSAPIAuthentication yes|#GSSAPIAuthentication yes|' /etc/ssh/ssh_config
#检查文件系统挂载
mount -a
df -Th
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep -v 192.168 |awk '{print $2}'
cat /etc/hosts