#!/bin/bash release=`grep -o "<[[:digit:]]>" /etc/centos-release | head -1` # 1、shutdown selinux [ -e "/etc/selinux/config" ] && sed -i 's@^SELINUX=.*@SELINUX=disabled@' /etc/selinux/config setenforce 0 &> /dev/null # 2、shudown firewall [ $release = "6" ] && service iptables stop && chkconfig iptables off [ $release = "7" ] && systemctl stop firewalld && systemctl disable firewalld # 3、set own alias echo "alias cdnet='cd /etc/sysconfig/network-scripts/'" >> /etc/profile.d/myalias.sh source /etc/profile.d/myalias.sh # 4、set evironment "PS1 color" # 30:black, 31:red, 32:green, 33:yellow, 34:blue, 35:pink, 36:cyan, 37:white ps1_color=35 echo 'PS1="[e[1;'''${ps1_color}'''m][u@h w]$[e[0m]"' >> /etc/profile.d/evironment.sh source /etc/profile.d/myalias.sh # 5、set aliyun repo rpm -q wget &> /dev/null || yum -y install wget mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup [ $release = "6" ] && wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo [ $release = "7" ] && wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum makecache &> /dev/null
注意:请使用source命令执行此脚本。为什么?
1、source执行某个脚本,会影响当前bash的参数,所以要调用某些变量的时候可以采用此方法
2、/bin/bash执行某个脚本,脚本会在子shell中运行,当前bash参数