#!/bin/bash
basepath=$ (CD ' DirName $ '; 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_forward\s\+=\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, and save
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 $process 01_dir];then
Mkdir-p $process 01_dir
Fi
RM-RF $process 01_dir/*
Cp-r $basepath/package/process01-beta $process 01_dir
Cp-r $basepath/package/process02anal $process 01_dir
chmod +x $process 01_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 $} '
If ["$process 01pid"];then
Kill-9 $process 01pid
echo "Old Process01 is killed"
Fi
Process02pid= ' PS aux|grep process02anal|grep-v "grep" |awk ' {print $} '
If ["$process 02pid"];then
Kill-9 $process 02pid
echo "Old Process02anal is killed"
Fi
Jiankongpid= ' PS aux|grep jiankong|grep-v "grep" |awk ' {print $} '
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 $} '
If ["$process 01pid"];then
echo "success! PROCESS01 is running Now "
Fi
Process02pid= ' PS aux|grep process02anal|grep-v "grep" |awk ' {print $} '
If ["$process 02pid"];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 $} '
If ["$rpcbindpid"];then
echo "Success! Rpcbind is running Now "
Fi
Nfspid= ' PS aux|grep nfs|grep-v "grep" |awk ' {print $} '
If ["$nfspid"];then
echo "Success! Nfs-server is running Now "
Fi
A client-side shell script that installs the environment and services in one click