#!/bin/bash #---Sysinit script by yxs--- #---email: [email protected] if [[ "$(whoami)" != "root" ]]; then echo "please run this script as root ." >&2 exit 1 fi #yum source config yum_config(){ yum install wget epel-release -y cd /etc/yum.repos.d/ && mkdir bak && mv -f *.repo bak/ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo yum clean all && yum makecache yum -y groupinstall ‘Development Tools‘ yum -y install python-pip man lsof iotop iftop net-tools 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 bash-completion } #firewalld config iptables_config(){ systemctl stop firewalld.service systemctl disable firewalld.service ifconfig | grep -q inet6 if [ $? == 0 ] then echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf sed -i ‘s/::1/#::1/‘ /etc/hosts fi } #system config system_config(){ yum update -y hostnamectl set-hostname yxs sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config timedatectl set-local-rtc 1 && timedatectl set-timezone Asia/Shanghai yum -y install chrony && systemctl start chronyd.service && systemctl enable chronyd.service } #app_config app_config(){ mkdir -p /usr/download/ && cd /usr/download wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz tar -xvf Python-3.6.4.tgz -C /usr/local cd /usr/local/Python-3.6.4 ./configure --prefix=/usr/local/python-3.6.4 --enable-shared make && make install ln -sv /usr/local/python-3.6.4/bin/python3 /usr/bin/python3 ln -sv /usr/local/python-3.6.4/bin/pip3 /usr/bin/pip3 pip install --upgrade pip echo /usr/local/python-3.6.4/lib >> /etc/ld.so.conf /sbin/ldconfig -v mkdir -p /home/envs virtualenv -p /usr/bin/python3 /home/envs/py3env ln -s /home/envs/py3env/bin/activate /root/py3 } main(){ yum_config iptables_config system_config app_config } main reboot