博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos系统初始化脚本
阅读量:6717 次
发布时间:2019-06-25

本文共 4143 字,大约阅读时间需要 13 分钟。

#!/bin/bash   #========================================================================== #   FILE: Init.sh #  #   DESCRIPTION: This script is used to install usual libs, #   close unnecessary services,optimize kernel parameters and so on #  #   REVISION: 1.0  #==========================================================================set -o nounset                          # Treat unset variables as an error# VARIABLES DEFINED# SRV_ON="acpid crond iptables kdump messagebus network ntpd readahead_early rsyslog sshd sysstat salt-minion"SRV_ON="acpid crond kdump messagebus network ntpd readahead_early rsyslog sshd sysstat salt-minion"SRV_TEMP="/tmp/chkconfig_list.tmp" INSTALL_LIBS="gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel libxslt-devel libevent-devel libtool-ltdl bison libtool vim-enhanced salt-minion"DONE="\e[0;32m\033[1mdone\e[m" # check os versionplatform=`uname -i`if [ $platform != "x86_64" ];then	echo "this script is only for 64bit Operating System!"exit 1ficat << EOF+---------------------------------------+|   your system is CentOS 6 x86_64      ||      start optimizing.......          |+---------------------------------------EOF# add the third-party epel reporpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm# lock userpasswd -l dbuspasswd -l vcsapasswd -l gamespasswd -l nobodypasswd -l avahipasswd -l haldaemonpasswd -l gopherpasswd -l ftppasswd -l mailnullpasswd -l pcappasswd -l mailpasswd -l shutdownpasswd -l haltpasswd -l uucppasswd -l operatorpasswd -l syncpasswd -l admpasswd -l lp# install usual libsyum -y install ${INSTALL_LIBS} 1>/dev/null echo -e "Install the usual libs ${DONE}." #echo "* 4 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1" >> /var/spool/cron/rootsed -i 's/#master: salt/master: salt.enai.corp/' /etc/salt/minionservice salt-minion restart# directory pathmkdir -p /data/scripts/shell# set static route# mount share# set the file limitecho "ulimit -SHn 65535" >> /etc/rc.localcat >> /etc/security/limits.conf << EOF*           soft   nofile       65535*           hard   nofile       65535*           soft   nproc        65535*           hard   nproc        65535EOF# set sshsed -i 's/#Port 22/Port 28290/' /etc/ssh/sshd_configsed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_configservice sshd restart# tune kernel parametrescat >> /etc/sysctl.conf << EOFnet.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_fin_timeout = 1EOF/sbin/sysctl -p# stop some crontabmkdir /etc/cron.daily.bakmv /etc/cron.daily/makewhatis.cron /etc/cron.daily.bak# close all services and set necessary services on  chkconfig  --list | awk '{print $1}' > ${SRV_TEMP}  # close all services  while read SERVICE do     chkconfig --level 345 ${SERVICE} off 1>/dev/null  done < ${SRV_TEMP}  # open necessary services  for SRVS in ${SRV_ON} do     if [ -e /etc/init.d/${SRVS} ]     then          chkconfig --level 345 ${SRVS} on 1>/dev/null     else         echo -e "Service ${SRVS} is \e[0;31m\033[1mnot exits\e[m."     fi      done # disable the ipv6cat > /etc/modprobe.d/ipv6.conf << EOFIalias net-pf-10 offoptions ipv6 disable=1EOFIecho "NETWORKING_IPV6=off" >> /etc/sysconfig/networkcat << EOF+-------------------------------------------------+|               optimizer is done                 ||   it's recommond to restart this server !       |+-------------------------------------------------+EOF# init done,and reboot system  echo -e "Do you want to \e[0;31m\033[1mreboot\e[m system now? [Y/N]:\t " read REPLY case $REPLY in      Y|y)         echo "The system will reboot now ..."         shutdown -r now          ;;     N|n)         echo "You must reboot later..."         source /etc/profile          ;;     *)         echo "You must input [Y/N]."         source /etc/profile          ;; esac ====cat > /etc/resolv.conf <

转载于:https://www.cnblogs.com/reblue520/p/6239741.html

你可能感兴趣的文章
2D Rotated Rectangle Collision
查看>>
PHP error_reporting() 函数
查看>>
SpringBoot(十)-- 整合MyBatis
查看>>
查看三种MySQL字符集的方法
查看>>
django -- 多对多关系的实现
查看>>
with revoked permission android.permission.CAMERA
查看>>
Python在函数中使用*和**接收元组和列表
查看>>
115. Distinct Subsequences
查看>>
C++ 指针(不论什么一个指针本身的类型都是unsigned long int型)
查看>>
[PHP] 通用网关接口CGI 的运行原理
查看>>
phoenixframe自己主动化平台在Linux环境下运行用例的说明
查看>>
Linux:sheel脚本for的用法,及日期参数+1day用法
查看>>
GetKeyState(), GetAsyncKeystate(), GetKeyboardSlate()
查看>>
函数式编程
查看>>
spring boot mybatis没有扫描jar中的Mapper接口
查看>>
ijkPlayer 集成
查看>>
Python 文件 writelines() 方法
查看>>
背水一战 Windows 10 (76) - 控件(控件基类): Control - 基础知识, 焦点相关, 运行时获取 ControlTemplate 和 DataTemplate 中的元素...
查看>>
比特币的区块结构解析
查看>>
图像滤镜艺术---Glow Filter发光滤镜
查看>>