作者:admin,发布日期:2017-06-24
阅读:2091;评论:0
function Colorset() { #颜色配置 echo=echo for cmd in echo /bin/echo; do $cmd >/dev/null 2>&1 || continue if ! $cmd -e "" | grep -qE '^-e'; then echo=$cmd break fi done CSI=$($echo -e "\033[") CEND="${CSI}0m" CDGREEN="${CSI}32m" CRED="${CSI}1;31m" CGREEN="${CSI}1;32m" CYELLOW="${CSI}1;33m" CBLUE="${CSI}1;34m" CMAGENTA="${CSI}1;35m" CCYAN="${CSI}1;36m" CSUCCESS="$CDGREEN" CFAILURE="$CRED" CQUESTION="$CMAGENTA" CWARNING="$CYELLOW" CMSG="$CCYAN" }
function Checksystem() { cd Logprefix;echo ${CMSG}'[Info]检查系统'${CEND} #检查系统 if [[ $(id -u) != '0' ]]; then Logprefix;echo ${CWARNING}'[Error]请使用root用户安装!'${CEND} exit fi if grep -Eqii "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then DISTRO='CentOS' else DISTRO='unknow' fi if [[ ${DISTRO} == 'unknow' ]]; then Logprefix;echo ${CWARNING}'[Error]请使用Centos系统安装!'${CEND} exit fi if grep -Eqi "release 5." /etc/redhat-release; then RHEL_Version='5' elif grep -Eqi "release 6." /etc/redhat-release; then RHEL_Version='6' elif grep -Eqi "release 7." /etc/redhat-release; then RHEL_Version='7' fi if [[ ${RHEL_Version} != '7' ]]; then Logprefix;echo ${CWARNING}'[Error]请使用Centos7安装!'${CEND} exit fi if [[ `getconf WORD_BIT` = '32' && `getconf LONG_BIT` = '64' ]] ; then OS_Bit='64' else OS_Bit='32' fi if [[ ${OS_Bit} == '32' ]]; then Logprefix;echo ${CWARNING}'[Error]请使用64位Centos7!'${CEND} exit fi }
function Closefirewalld() { #关闭防火墙 Logprefix;echo ${CMSG}'[Info]关闭防火墙'${CEND} systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 } function Coloseselinux() { #关闭selinux Logprefix;echo ${CMSG}'[Info]关闭Selinux'${CEND} [ -s /etc/selinux/config ] && sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config setenforce 0 >/dev/null 2>&1 } function Settimezone() { #设置时区并同步时间 Logprefix;echo ${CMSG}'[Info]设置服务器时区'${CEND} rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime Logprefix;echo ${CMSG}'[Info]同步服务器时间'${CEND} ntpdate cn.ntp.org.cn } function Setlocale() { #设置语言 Logprefix;echo ${CMSG}'[Info]设置服务器语言(重新登录生效)'${CEND} localectl set-locale.utf8 }