Centos System Initialization Management script

Source: Internet
Author: User
Tags ssh port

System initialization script can be unified, automatic configuration, reduce manpower.

Here is a brief talk about Yum installation and source code compilation and installation, please correct me. I have been insisting on Yum installation for the following reasons

First, easy to install, do not need to spend more energy to consider the problem of dependency

Second, the configuration is unified, convenient later maintenance, automation and so on

Third, convenient upgrade

Four, okay, I'm a vegetable chicken, I admit it. 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0039.gif "alt=" J_0039.gif "style=" Padding:0px;margin : 0px;vertical-align:top;border:none; "/>

#!/bin/sh# determine user identity username= ' whoami ';if [  $username  !=  "root"  ]then     echo  "Insufficient current user rights, will exit script";     exit 2;fi# verify user Network echo  "detect network ...";/bin/ping  www.baidu.com -c 2 >> /dev/nullif [ $? != 0 ]then     echo  "Network does not communicate properly, please check the network configuration";    exit 3;fiecho  "Network normal"; sleep 1; #安装yum  remi php Source if rpm -qa|grep remi-release >> /dev/ null;then    echo  "remi resource is installed"; elseyum_changes= "a"; version= ' cat /etc/issue|head -n 1|awk {' print $3 '}|tr  '. "   "\ n" |head -n 1 ' if [  $version  == 5 ]then    rpm  -uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm http:// rpms.famillecollet.com/enterprise/remi-release-5.rpm 2>&1 >> /tmp/sys_log.txt    elif [  $version  == 6  ]then    rpm -uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/ Epel-release-6-8.noarch.rpm http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 2>&1  >> /tmp/sys_log.txtfiif [ $? != 0 ]then    echo   "Failed to install yum  source, please check the log under TMP";else    echo  "yum source has been installed, please configure the Remi Source configuration file, choose PHP Version"; Fifi# asks the user whether to close selinuxselinux_st= ' sestatus | awk {' print $3 '} ' if [  $selinux _st  !=  "Disabled"  ]then    se_changes= "a";     until [   $se _changes ==  "yes"  ] && [  $se _changes ==  "no"  ]     do        read -p  "The current SELinux status is open, Whether to close (enter Yes to close, enter no not to close): "Se_changes    done    if [  $se _changes ==  "yes"  ]     then        sed -i  ' s/^selinux= Enforcing$/selinux=disables/'  /etc/selinux/config 2>&1 >> /tmp/sys_log.txt         if [$? != 0]         then            echo  " To close the SELinux error, please check the log under TMP ";         fi    elif [   $se _changes ==  "No"  ]    then         echo  "You have chosen not to turn off SELinux";    fielse    echo  " The selinux was detected to be closed "; fi




Let's say the script's business logic:

    1. Determine user identity [non-root exit script]

    2. Detect if the server network is healthy [error exit script]

    3. Installing the Remi Yum Source

    4. Turn off SELinux

    5. Close Iptables

    6. Change the SSH port

    7. Changing Linux network kernel parameters


#其中关闭iptables, change the SSH port, change the Linux network kernel parameters, temporarily do not write logic code, the weekend will be updated on

This article is from the "Linux operation and Maintenance" blog, reproduced please contact the author!

Centos System Initialization Management script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.