################################################### CentOS6.5 ## initialize the Linux system to deploy lnmp ## 2016/10/30 22:58 ## author:kangjie #
# original article ####################################################!/bin/sh#向自動化運(yùn)維邁進(jìn)#定義文件位置LOG_PATH=/server/initlogLOG_FILE=$LOG_PATH/init.logi=0#如果文件夾不存在,則創(chuàng)建[ ! -d /server/tools ] && mkdir -p /server/tools[ ! -d $LOG_PATH ] && mkdir -p $LOG_PATH #判斷命令執(zhí)行是否成功#check status then wirite to logfunction check(){if [ $? != 0 ] thenecho "××××-operate $1 Failed!!!-×××" >> $LOG_FILE else echo "√√√-operate $1 Success-√√√" >> $LOG_FILEfi} #關(guān)閉防火墻,禁止開機(jī)啟動(僅限于沒有公網(wǎng)的情況)#iptablesfunction iptable(){/etc/init.d/iptables stopcheck iptables chkconfig iptables off check chkconfig-iptables((i++))} #關(guān)閉selinux,修改配置文件后,同時設(shè)置臨時生效#selinux disable the selinuxfunction selinux(){status=`grep SELINUX= /etc/selinux/config | tail -1 | awk -F '=' '{print $2}'`if [ $status != disabled ]thensed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/configstatus=`grep SELINUX= /etc/selinux/config | tail -1 | awk -F '=' '{print $2}'`if [ $status == disabled ]thenecho "√√√-Modify selinux config success-√√√-" >> $LOG_FILEelseecho "××××-Modify selinux config Failed!!!-××××" >> $LOG_FILEfielseecho &qu