#!/bin/bash # #Filename:postinstall_init.sh #Description:系統安裝完成后,對系統進行一些配置,以符合自己的試驗環境 #Author:renpingsheng #Email:995883352@qq.com #Version:1.0 #Date:2017.5.5 setenforce 0 #更改selinux的配置文件,禁用selinux,成功則打印“配置完成” sed -i.bak '1,$s@SELINUX=enforcing@SELINUX=disabled@g' /etc/selinux/config && echo "SElinux is setting OK!" #定義一些常用的別名 cat <<EOF >>/root/.bashrc && echo "The file bashrc is setting ok!" alias "cdnet"="cd /etc/sysconfig/network-scripts/" alias "grep"="grep --color=auto" alias "renet"="service network restart" EOF #備份系統已有的repo文件 cd /etc/yum.repos.d/ [ -d repo_bak ] || mkdir repo_bak mv *.repo repo_bak echo "The old repo file is backup ok!" #配置內網的yum源 cat <<EOF > CentOS-base.repo [CentOS-base] name=CentOS-base baseurl=http://172.16.0.1/cobbler/ks_mirror/CentOS-6.8-x86_64/ enabled=1 gpgcheck=0 [epel] name=CentOS-epel baseurl=http://172.16.0.1/fedora-epel/6/x86_64/ enabled=1 gpgcheck=0 EOF echo "The repository is setting ok!" #清空yum緩存,生成新的yum緩存 yum clean all && yum makecache &> /dev/null #安裝一些常用的軟件 for software in vim createrepo psmisc tree lftp htop lrzsz nmap wget traceroute; do rpm -q $software #判斷軟件是否已經安裝 if [ $? == 1 ]; then yum install -y $software >> /dev/null && echo "The package $software is install OK!" else echo "The Package $software is already installed!" fi done #釋放定義的變量 unset software #安裝系統開發組件 yum groupinstall -y "Development tools" >> /dev/null && echo "Development tools suite is installed ok!" #配置vim別名 echo "alias vi=vim" >> /root/.bashrc #配置vim環境 cat <<EOF >> /root/.vimrc && echo "The vimrc file is setting ok!" set hlsearch set nu set ai set ic set sm syntax on set fileformat=unix EOF #使.bashrc文件立即生效 source /root/.bashrc #使.vimrc文件立即生效 source /root/.vimrc #重啟系統 shutdown -r now
原創文章,作者:renpingsheng,如若轉載,請注明出處:http://www.www58058.com/74868