• 一个客户端一键安装环境和服务的shell脚本


    #!/bin/bash

    basepath=$(cd `dirname $0`; pwd)
    SHELL_DIR="${basepath}/shell"
    PACKAGE_DIR="${basepath}/package"


    ##############################install rpm##########################
    #关闭不必要的软件并禁止开机启动
    systemctl stop firewalld
    systemctl disable firewalld

    #关闭selinux
    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

    #开启转发
    if [ `grep -v '^s*#' /etc/sysctl.conf |grep -c 'net.ipv4.ip_forwards+=s+1'` -eq 0 ];then
    echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
    sysctl -p
    fi

    echo "start install RPMs"

    rpm -ivh $PACKAGE_DIR/autossh-1.4e-1.el7.x86_64.rpm
    rpm -ivh $PACKAGE_DIR/net-tools-2.0-0.17.20131004git.el7.x86_64.rpm
    rpm -ivh $PACKAGE_DIR/sysstat-10.1.5-7.el7.x86_64.rpm
    rpm -ivh $PACKAGE_DIR/traceroute-2.0.19-5.el7.x86_64.rpm
    rpm -ivh $PACKAGE_DIR/telnet-0.17-59.el7.x86_64.rpm
    rpm -ivh $PACKAGE_DIR/tcpdump-4.5.1-3.el7.x86_64.rpm
    rpm -ivh $PACKAGE_DIR/lrzsz-0.12.20-36.el7.x86_64.rpm
    rpm -ivh $PACKAGE_DIR/iptables-services-1.4.21-16.el7.x86_64.rpm
    rpm -ivh $PACKAGE_DIR/ntpdate-4.2.6p5-22.el7.centos.x86_64.rpm
    yum install -y nfs-utils rpcbind

    #校准系统时间
    ntpdate "time1.aliyun.com"

    #ssh登陆时不提示yes/no
    echo 'StrictHostKeyChecking no' > /root/.ssh/config

    #清空iptables,并保存
    iptables -F
    iptables -F -t nat
    iptables-save > /etc/sysconfig/iptables
    systemctl enable iptables

    echo "success!"
    ##############################Deploy process01########################
    echo "start deploy process01"

    process01_DIR="/data/website"


    if [ ! -e $process01_DIR ];then
    mkdir -p $process01_DIR
    fi


    rm -rf $process01_DIR/*
    cp -r $basepath/package/process01-beta $process01_DIR
    cp -r $basepath/package/process02Anal $process01_DIR
    chmod +x $process01_DIR/*

    if [ ! -e /data/socket/ ];then
    mkdir -p /data/socket/
    fi

    rm -rf /data/socket/*
    cp -r $basepath/package/jiankong_start.sh /data/socket/
    chmod +x /data/socket/jiankong_start.sh

    cat $basepath/package/rc.local > /etc/rc.local
    chmod +x /etc/rc.d/rc.local

    process01pid=`ps aux|grep process01|grep -v "grep"|awk '{print $2}'`

    if [ "$process01pid" ];then

    kill -9 $process01pid
    echo "old process01 is killed"
    fi


    process02pid=`ps aux|grep process02Anal|grep -v "grep"|awk '{print $2}'`

    if [ "$process02pid" ];then
    kill -9 $process02pid
    echo "old process02Anal is killed"
    fi

    jiankongpid=`ps aux|grep jiankong|grep -v "grep"|awk '{print $2}'`

    if [ "$jiankongpid" ];then
    kill -9 $jiankongpid
    echo "jiankong process is killed"
    fi


    nohup /data/socket/jiankong_start.sh &

    if [ $? -ne 0 ]; then
    echo "new jiankong process starting failed"
    exit 1
    fi


    sleep 5
    process01pid=`ps aux|grep process01|grep -v "grep"|awk '{print $2}'`

    if [ "$process01pid" ];then
    echo "success! process01 is running now"
    fi

    process02pid=`ps aux|grep process02Anal|grep -v "grep"|awk '{print $2}'`

    if [ "$process02pid" ];then
    echo "success ! process02Anal is running now"
    fi

    rm -rf /data/socket/public/
    cp -r $basepath/package/public /data/socket/
    chmod +x /data/socket/public/*
    ##############################Deploy nfs########################
    echo "start deploy nfs-server"

    cat $basepath/package/exports > /etc/exports

    systemctl restart rpcbind
    systemctl enable rpcbind

    systemctl restart nfs
    systemctl enable nfs

    rm -rf /root/wendang/
    cp -r $basepath/package/wendang /root/
    cd /root/wendang/
    chmod 777 Private/
    chmod +x Program/
    chmod +x Program/*

    rpcbindpid=`ps aux|grep rpcbind|grep -v "grep"|awk '{print $2}'`

    if [ "$rpcbindpid" ];then
    echo "success ! rpcbind is running now"
    fi

    nfspid=`ps aux|grep nfs|grep -v "grep"|awk '{print $2}'`

    if [ "$nfspid" ];then
    echo "success ! nfs-server is running now"
    fi

  • 相关阅读:
    java学习day02---Spring Boot综合运用---活动模块
    java学习day01---GC
    课程学习总结报告
    结合中断上下文切换和进程上下文切换分析Linux内核的一般执行过程
    深入理解系统调用
    基于mykernel 2.0编写一个操作系统内核
    超码 候选码 主码 替换码 数据库 定义
    如何评测软件工程知识技能水平?
    创新产品的需求分析:未来的图书会是什么样子?
    案例分析:设计模式与代码的结构特性(桥接模式)
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/7700078.html
Copyright © 2020-2023  润新知