首页 > 其他分享 >openEuler22.09初始化脚本

openEuler22.09初始化脚本

时间:2023-02-26 11:01:20浏览次数:44  
标签:iptables 初始化 systemctl 脚本 openEuler22.09 etc sed yum install

#!/bin/bash
s=`nmcli d | grep "已断开" | awk '{print $1}'`
echo /etc/sysconfig/network-scripts/ifcfg-$s
sed -i "s/^ONBOOT=.*$/ONBOOT=yes/" /etc/sysconfig/network-scripts/ifcfg-$s
cat /etc/sysconfig/network-scripts/ifcfg-$s
systemctl restart NetworkManager

sed -ri 's/^.*(UseDNS) .*$/\1 no/' /etc/ssh/sshd_config && sed -rn '/UseDNS/p' /etc/ssh/sshd_config
sed -ri 's/^.*(GSSAPIAuthentication ).*$/\1no/' /etc/ssh/sshd_config && sed -rn '/GSSAPIAuthentication/p' /etc/ssh/sshd_config
setenforce 0
sed -ri.bak 's/^(SELINUX=).*$/\1disabled/' /etc/selinux/config
systemctl stop firewalld.service 
systemctl disable firewalld.service
sleep 10
yum clean all
yum makecache
yum install ukui -y
yum install iptables-services -y
systemctl enable iptables.service

iptables -P FORWARD ACCEPT
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F
iptables -X
service iptables save
iptables-save > /etc/sysconfig/iptables
yum -y install chrony

sed -ri "s/^(pool.*)$/#\1/" /etc/chrony.conf
c=`cat /etc/chrony.conf | grep 'aliyun'|wc -l`
echo $c

if [[ $c -eq 0 ]];then
cat << EOF >> /etc/chrony.conf 
server ntp.aliyun.com iburst
server ntp.tuna.tsinghua.edu.cn iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
EOF
systemctl restart chronyd
#开机自启
systemctl enable chronyd
else
echo "时间同步已经配置"
fi
chronyc sources
u=`cat /etc/security/limits.conf | grep 20480`
echo $u
if [[ $u -eq 0 ]];then
cat << EOF >> /etc/security/limits.conf
*        soft    nproc           20480
*        hard    nproc           20480
*        soft    nofile          45536
*        hard    nofile          45536
*        soft    memlock         unlimited
*        hard    memlock         unlimited
EOF
else
echo "ulimit已经配置"
fi
p=`cat /etc/profile | grep PS1 |wc -l`
echo $p
if [[ $p -eq 0 ]];then
cat << EOF >> /etc/profile
PS1="\[\e[1;32m\][\[\e[0m\]\t \[\e[1;33m\]\u\[\e[36m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\\\$"
EOF
else
echo "PS1已经配置"
fi
systemctl set-default multi-user.target
yum install tree -y
yum -y install bash-completion
yum groups install "Development Tools" -y
yum install yum-utils.noarch -y
yum install lrzsz -y
sed -ri "s/RSYSLOG_TraditionalFileFormat/RSYSLOG_FileFormat/" /etc/rsyslog.conf && systemctl restart rsyslog.service
sed -ri "s/^weekly/monthly/" /etc/logrotate.conf
yum install -y yum-utils device-mapper-persistent-data lvm2 wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel wget vim ncurses-devel autoconf automake zlib-devel  python-devel epel-release openssh-server socat  ipvsadm conntrack ntpdate telnet ipvsadm
reboot

标签:iptables,初始化,systemctl,脚本,openEuler22.09,etc,sed,yum,install
From: https://www.cnblogs.com/guangdelw/p/17156280.html

相关文章