码迷,mamicode.com
首页 > 系统相关 > 详细

Linux系统环境自动化配置~init.sh分享

时间:2018-04-03 14:36:44      阅读:1133      评论:0      收藏:0      [点我收藏+]

标签:conf   .com   etc   /etc/   class   $?   pos   ade   load   

#!/bin/bash

#---Sysinit script by yxs---
#---email: yexuesong218@gmail.com---


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

 

Linux系统环境自动化配置~init.sh分享

标签:conf   .com   etc   /etc/   class   $?   pos   ade   load   

原文地址:https://www.cnblogs.com/yexuesong/p/8707648.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!