CENTOS 6.6初始化SHELL脚本

这个脚本是在刚安装完CENTOS6.6后可能需要进行的操作。在学习CENTOS的时候,可以先运行这个脚本进行一些配置,可以帮助你不会被这些防火墙 yum selinux ip这些困扰。

#!/bin/bash
 
#判断是不是root用户
if [[ "$(whoami)" != "root" ]]; then
 
    echo "please run this script as root ." >&2
    exit 1
fi
 
echo -e "\033[31m 这个是系统初始化脚本,请慎重运行!确定使用请注释指定行 \033[0m"

#请注释下一行
exit 1;

#关闭SELINUX
selinux(){
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/sysconfig/selinux
setenforce 0
}

#设置动态ip
ip(){
     sed -i ‘s/ONBOOT=no/ONBOOT=yes/‘ /etc/sysconfig/network-scripts/ifcfg-eth0
     service network restart > /dev/null
}
 
#设置时间时区同步
zone_time(){
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 
    # 更新时间
    /usr/sbin/ntpdate pool.ntp.org
    echo ‘*/5 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1‘ > /var/spool/cron/root;chmod 600 /var/spool/cron/root
    /sbin/service crond restart
}

#配置yum源
yum_update(){
    yum -y install wget
    cd /etc/yum.repos.d/
    mkdir bak
    mv ./*.repo bak
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

}
 
# 清空iptables规则并关闭
iptables(){
    iptables -F
    iptables -P INPUT ACCEPT
    iptables -P OUTPUT ACCEPT
    service iptables save
}

other(){
# 可以在这里定制你想做的something
}
 
main(){
    ip
    yum_update
    selinux
    zone_time
    iptables
    other
}

main
时间: 2024-08-11 09:48:00

CENTOS 6.6初始化SHELL脚本的相关文章

CentOS 6.5初始化优化脚本

#!/bin/bash echo "这个是系统初始化脚本,请慎重运行!" input_fun() {     OUTPUT_VAR=$1     INPUT_VAR=""     while [ -z $INPUT_VAR ];do         read -p "$OUTPUT_VAR" INPUT_VAR     done     echo $INPUT_VAR } input_again() { MYHOSTNAME=$(input_fu

Centos开机自动执行shell脚本启动tomcat服务器

有时候需要在Centos系统启动之后自动完成项目的启动,项目部署在tomcat中时,如果Centos关机后开机,各个项目也就已经被停掉了,然后需要自己一个一个的手动去开启各个项目对应的tomcat服务器,想想都比较麻烦,那么如何才能实现,当Centos启动之后,项目就自动也跟着启动了呢? 下面就介绍下Centos如何开机是自动启动shell脚本,通过shell脚本的命令来启动项目对应的tomcat服务器. 一.切换到/etc/init.d目录下 cd /etc/init.d 二.制作sh脚本:v

linux (centos) 安装tomcat (用shell脚本安装为服务)

1.下载tomcat 从http://tomcat.apache.org/download-70.cgi链接下载linux版本(tar.gz) 2.解压,上传及赋权限 解压,用WinSCP把解压的安装文件上传到/home/software/tomcat目录 并用   chmod -R 755 /home/software/tomcat命令账权限. 3.编写安装为服务的脚本并运行 shell脚本如下: #! /bin/sh #shell script takes care of starting

CentOS 6.9使用Shell脚本实现FTP自动上传和下载文件

一.安装配置FTP: # yum -y install vsftpd # service vsftpd start # ss -tunlp | grep 21 //添加本地FTP登录用户ftpuser # useradd ftpuser # echo 123456 | passwd --stdin ftpuser # cd /etc/vsftpd/ # cp vsftpd.conf vsftpd.conf.bak # vim vsftpd.conf //允许本地用户登录FTP且对FTP具有写权限

CentOS 6一键系统优化 Shell 脚本

脚本的内容如下: #!/bin/bash#author suzezhi#this script is only for CentOS 6#check the OS platform=`uname -i`if [ $platform != "x86_64" ];then echo "this script is only for 64bit Operating System !"exit 1fiecho "the platform is ok"ve

centos)安装tomcat (用shell脚本安装为服务)

#! /bin/sh #shell script takes care of starting and stopping # the glassfish DAS and glassfish instance. # # chkconfig: - 64 36 # description: Tomcat auto start # /etc/init.d/tomcatd # Tomcat auto-start # Source function library. #. /etc/init.d/funct

centos7 一键初始化shell脚本

#!/bin/bash -#关闭selinux,这个必须关闭,不然会出现各种各样的账号权限问题sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/configsetenforce 0 #安装常用工具vim-编辑器 wget-下载工具 tree-目录树 net-tools-网络工具套装 curl-文件传输 ntpdate-时间同步yum -y install vim wget tree net-tools curl curl-d

Centos下初始化系统的shell脚本

根据参考网上的一些文章,总结出来一个系统初始化的shell脚本 #!/bin/bash cat << EOF +---------------------------------------------------------------------------+ | Initialize for the CentOS 6_installed. | +------------------------------------------------------------------------

centos分配IP脚本--写的第一个shell脚本

IDC小菜鸟一枚,非科班出身.常常有客户的centos服务器需要分配15个IP甚至30个IP.每次需要手动分配十分麻烦,于是花了一天时间学了shell脚本,写了这个脚本. #!/bin/bash read -p "The IP numbers: " num while [[ $num -gt 0 ]] do read -p "Please enter IP Address :" ipaddr touch /etc/sysconfig/network-scripts/