安装脚本

#!/bin/bash
#need sudo -s first
VER="1.4.2"
############## linux setting ###################
mkdir  /data0/soft

/usr/sbin/adduser nginx
mkdir -m755 /data0/nginx
mkdir -m755 /data0/testlog
chown nginx /data0/testlog

echo ‘append /etc/sysctl.conf‘
echo ‘fs.file-max = 1048576‘>>/etc/sysctl.conf

echo ‘        ‘
/sbin/sysctl -p
echo ‘        ‘

echo ‘nginx    soft   nofile   20480‘>>/etc/security/limits.conf
echo ‘nginx    hard   nofile   20480‘>>/etc/security/limits.conf 

echo ‘session required pam_limits.so‘>>/etc/pam.d/login

su nginx -c ‘ulimit -n‘
/sbin/ifconfig|head -n2

############   install and config the nginx ##############

\cd /data0/soft
rsync 10.210.208.48::temp/suda_web/nginx-$VER/*.tar.gz .
rsync 10.210.208.48::temp/suda_web/nginx-$VER/*.zip .
#wait

tar -xvf nginx-$VER.tar.gz  &&
unzip -u nginx-suda-patch-$VER.zip &&
unzip -u headers-more-nginx-module-0.19rc1.zip &&
tar -xvf pcre-8.32.tar.gz &&
tar -xvf zlib-1.2.7.tar.gz &&

cd /data0/soft/nginx-$VER 

./configure --prefix=/data0/nginx --user=nginx--with-pcre=/data0/soft/pcre-8.32  --with-zlib=/data0/soft/zlib-1.2.7 --with-http_stub_status_module --with-http_realip_module --add-module=/data0/soft/headers --add-module=/data0/soft/missub --add-module=/data0/soft/misetag --add-module=/data0/soft/mistime --add-module=/data0/soft/miscookie   &&

make && make install
################ conf ################################

cd /data0/soft &&
unzip -o nginx-conf-pack-$VER.zip &&

cd /data0/soft/nginx-conf-pack &&
chmod 755 nginx-auto-conf.py &&

cat nginx.conf.prd | /usr/bin/python nginx-auto-conf.py 1 >nginx.conf&&
cat nginx.conf.test | /usr/bin/python nginx-auto-conf.py 1 >nginx.conf.test&&

rm -rf /data0/nginx/html/*  &&
\cp -ru /data0/soft/nginx-conf-pack/htdocs/* /data0/nginx/html

################ start nginx #######################

#!/bin/bash
cd /data0/nginx
\cp /data0/soft/nginx-conf-pack/nginx.conf /data0/nginx/conf/nginx.conf 

mkdir -p /data0/logs/clickstream/
chgrp -R nginx /data0/logs/clickstream/
chmod -R 775 /data0/logs/clickstream/ 

/data0/nginx/sbin/nginx

############### other setting ########################
curl -I http://127.0.0.1/a.gif
tail /data0/logs/clickstream/clickstream*
############### other setting ########################

cd /data0/soft
\cp /etc/rc.local  /data0/nginx/conf/rc.local.bak

echo ‘‘>> /etc/rc.local
echo ‘#nginx‘>> /etc/rc.local
echo ‘/data0/nginx/sbin/nginx‘>> /etc/rc.local

crontab -l>tmpcron.txt
echo ‘‘>>tmpcron.txt
echo ‘#nginx clean log‘>>tmpcron.txt
echo ‘1 10 *  *  *   echo>/data0/nginx/logs/access.log‘>>tmpcron.txt
crontab tmpcron.txt

crontab -l
cat /etc/rc.local

## temp ckctl update
rsync 10.210.208.48::temp/suda_web/nginx-$VER/ckctl.html /data0/nginx/html/ckctl.html

# rm -rf /data0/soft/headers
# rm -rf /data0/soft/headers-more-nginx-module-0.19rc1.zip
# rm -rf /data0/soft/nginx-1.2.5
# rm -rf /data0/soft/nginx-1.2.5.tar.gz
# rm -rf /data0/soft/nginx-conf-pack
# rm -rf /data0/soft/nginx-conf-pack.zip
# rm -rf /data0/soft/nginx-suda-patch
# rm -rf /data0/soft/nginx-suda-patch.tar.gz
# rm -rf /data0/soft/openssl-1.0.1c
# rm -rf /data0/soft/openssl-1.0.1c.tar.gz
# rm -rf /data0/soft/pcre-8.32
# rm -rf /data0/soft/pcre-8.32.tar.gz
# rm -rf /data0/soft/zlib-1.2.7
# rm -rf /data0/soft/zlib-1.2.7.tar.gz

install_nginx.sh

#!/bin/sh

#ftp
cd /data0/soft
rsync 10.210.208.48::temp/suda_web/proftpd-1.3.1rc3.tar.gz .
tar -zxf proftpd-1.3.1rc3.tar.gz
cd proftpd-1.3.1rc3
./configure
make
make install

#config
cd /data0/soft
rsync 10.210.208.48::temp/suda_web/proftpd.conf .
\cp proftpd.conf /usr/local/etc

#user
mkdir -p /data0/suds_autoftp
/usr/sbin/adduser -d /data0/suds_autoftp/ftp_out/ -s /sbin/nologin suds_autoftp_001
echo "sudsautoftppswd001" |passwd --stdin suds_autoftp_001

#start
/usr/local/sbin/proftpd &
echo "" >> /etc/rc.local
echo "#ftp" >> /etc/rc.local
echo "/usr/local/sbin/proftpd &" >> /etc/rc.local

#clear
rm -rf proftpd-1.3.1rc3.tar.gz proftpd-1.3.1rc3

install_ftp.sh

#!/bin/sh

#clicklog
cd /data0/soft
rsync 10.210.208.48::temp/suda_web/suds_autoftp/autoftp_clicklog.sh .
rsync 10.210.208.48::temp/suda_web/suds_autoftp/data_bak.conf .
mkdir -p /data0/suds_autoftp/ftp_out
mv autoftp_clicklog.sh /data0/suds_autoftp
mv data_bak.conf /data0/suds_autoftp

#heartbeat
cd /data0/soft
rsync 10.210.208.48::temp/suda_web/heartbeat.sh .
mkdir -p /data0/heartbeat
mv heartbeat.sh /data0/heartbeat
chmod a+x /data0/heartbeat/heartbeat.sh

#databak
mkdir /data0/suds_autoftp/ftp_out/data_bak
mkdir /data0/auto_databak
cd /data0/auto_databak
rsync -avz 10.210.208.48::temp/suda_web/auto_databak/ .
data1=`df -h|grep data1`
if [ "$data1" == "" ]
then
    mkdir -p /data0/data_bak
    mount --bind /data0/data_bak /data0/suds_autoftp/ftp_out/data_bak
    echo "" >> /etc/rc.local
    echo "#mount" >> /etc/rc.local
    echo "mount --bind /data0/data_bak /data0/suds_autoftp/ftp_out/data_bak" >> /etc/rc.local
else
    mkdir -p /data1/data_bak
    mount --bind /data1/data_bak /data0/suds_autoftp/ftp_out/data_bak
    echo "/data1/data_bak    10" > /data0/auto_databak/path.conf
    echo "/data1/data_bak" > /data0/suds_autoftp/data_bak.conf
    echo "" >> /etc/rc.local
    echo "#mount" >> /etc/rc.local
    echo "mount --bind /data1/data_bak /data0/suds_autoftp/ftp_out/data_bak" >> /etc/rc.local
fi

crontab -l>tmpcron.txt

echo ‘#for standard time‘>>tmpcron.txt
echo ‘0 */3 * * * /usr/sbin/ntpdate tiger.sina.com.cn  202.106.184.186 > /dev/null‘>>tmpcron.txt
echo ‘‘>>tmpcron.txt
echo ‘#for suda log‘>>tmpcron.txt
echo ‘1,31      *       *       *       *       /data0/suds_autoftp/autoftp_clicklog.sh > /dev/null‘>>tmpcron.txt
echo ‘‘>>tmpcron.txt
echo ‘# for heartbeat check‘>>tmpcron.txt
echo ‘*/10    *       *       *       *       /data0/heartbeat/heartbeat.sh   > /dev/null‘>>tmpcron.txt
echo ‘‘>>tmpcron.txt
echo ‘#logclear‘>>tmpcron.txt
echo ‘20      4       *       *       *       /data0/auto_databak/auto_logclear.sh > /dev/null‘>>tmpcron.txt

install_beacon.sh

#!/bin/sh

#clicklog
cd /data0/soft
rsync 10.210.208.48::temp/suda_web/suds_autoftp/autoftp_clicklog.sh .
rsync 10.210.208.48::temp/suda_web/suds_autoftp/data_bak.conf .
mkdir -p /data0/suds_autoftp/ftp_out
mv autoftp_clicklog.sh /data0/suds_autoftp
mv data_bak.conf /data0/suds_autoftp

#heartbeat
cd /data0/soft
rsync 10.210.208.48::temp/suda_web/heartbeat.sh .
mkdir -p /data0/heartbeat
mv heartbeat.sh /data0/heartbeat
chmod a+x /data0/heartbeat/heartbeat.sh

#databak
mkdir /data0/suds_autoftp/ftp_out/data_bak
mkdir /data0/auto_databak
cd /data0/auto_databak
rsync -avz 10.210.208.48::temp/suda_web/auto_databak/ .
data1=`df -h|grep data1`
if [ "$data1" != "not use data1" ]
then
    mkdir -p /data0/data_bak
    mount --bind /data0/data_bak /data0/suds_autoftp/ftp_out/data_bak
    echo "" >> /etc/rc.local
    echo "#mount" >> /etc/rc.local
    echo "mount --bind /data0/data_bak /data0/suds_autoftp/ftp_out/data_bak" >> /etc/rc.local
else
    mkdir -p /data1/data_bak
    mount --bind /data1/data_bak /data0/suds_autoftp/ftp_out/data_bak
    echo "/data1/data_bak    10" > /data0/auto_databak/path.conf
    echo "/data1/data_bak" > /data0/suds_autoftp/data_bak.conf
    echo "" >> /etc/rc.local
    echo "#mount" >> /etc/rc.local
    echo "mount --bind /data1/data_bak /data0/suds_autoftp/ftp_out/data_bak" >> /etc/rc.local
fi

crontab -l>tmpcron.txt

echo ‘#for standard time‘>>tmpcron.txt
echo ‘0 */3 * * * /usr/sbin/ntpdate tiger.sina.com.cn  202.106.184.186 > /dev/null‘>>tmpcron.txt
echo ‘‘>>tmpcron.txt
echo ‘#for suda log‘>>tmpcron.txt
echo ‘1,31      *       *       *       *       /data0/suds_autoftp/autoftp_clicklog.sh > /dev/null‘>>tmpcron.txt
echo ‘‘>>tmpcron.txt
echo ‘# for heartbeat check‘>>tmpcron.txt
echo ‘*/10    *       *       *       *       /data0/heartbeat/heartbeat.sh   > /dev/null‘>>tmpcron.txt
echo ‘‘>>tmpcron.txt
echo ‘#logclear‘>>tmpcron.txt
echo ‘20      4       *       *       *       /data0/auto_databak/auto_logclear.sh > /dev/null‘>>tmpcron.txt

install_beacon_data0.sh

#!/bin/bash
RSYNC=‘10.39.2.120::wenhui/database/install‘
CMAKE=‘cmake-2.8.6.tar.gz‘
MYSQL=‘mysql-5.5.24.tar.gz‘
MYSQL_DIR=‘/usr/local/mysql55‘
MYSQL_DATADIR=‘/data1/mysqldata/mysql3306‘

function main(){
    user=`whoami`
    if [ "$user" != "root" ]; then
        echo "please use root to execute this script"
        exit 1
    fi

    module=$1
    module_type=$2
    case "$1" in
        cmake)
            install_cmake
            ;;
        mysql)
            install_mysql $module_type
            ;;
        *)
            echo "USAGE: $0 MODULE[cmake|mysql] MODULE_TYPE[full|libmysql|mysqlclient]"
    esac
}

#install cmake
function install_cmake(){
    echo "begin install cmake"; sleep 1
    echo "get tar from $RSYNC"
    eval "rsync -avzP $RSYNC/$CMAKE ./"
    dir=`echo $CMAKE | perl -pe ‘s/\Q.tar.gz\E$//g‘`
    eval "test -e $dir && rm -rf $dir"
    eval "tar -zxvf $CMAKE"
    echo "cd to $dir"
    eval "cd $dir"
    ./configure
    make && make install
    cd ..
}

#install mysql
function install_mysql(){
    LD_PATH=‘/etc/ld.so.conf.d/mysql.conf‘
    INSTALL_TYPE=‘full‘
    if [ "$1" != "" ]; then
        INSTALL_TYPE=$1
    fi

    echo "begin install mysql $INSTALL_TYPE"; sleep 1
    echo "get tar from $RSYNC"
    eval "rsync -avzP $RSYNC/$MYSQL ./"
    dir=`echo $MYSQL | perl -pe ‘s/\Q.tar.gz\E$//g‘`
    eval "test -d $dir && rm -rf $dir"
    eval "tar -zxvf $MYSQL"
    echo "cd to $dir"
    eval "cd $dir"
    if [ "$INSTALL_TYPE" == "full" ]; then
        eval "useradd mysql -s /sbin/nologin"
        eval "cmake     -DCMAKE_INSTALL_PREFIX=$MYSQL_DIR \
                        -DMYSQL_UNIX_ADDR=/tmp/mysql.sock                         -DDEFAULT_CHARSET=utf8                         -DDEFAULT_COLLATION=utf8_general_ci                         -DWITH_MYISAM_STORAGE_ENGINE=1                         -DWITH_INNOBASE_STORAGE_ENGINE=1                         -DWITH_MEMORY_STORAGE_ENGINE=1                         -DWITH_READLINE=1                         -DENABLED_LOCAL_INFILE=1                         -DMYSQL_DATADIR==$MYSQL_DATADIR                         -DMYSQL_USER=mysql                         -DMYSQL_TCP_PORT=3306                         -DWITH_PARTITION_STORAGE_ENGINE=1                         -DEXTRA_CHARSETS=all                         -DWITH_EXTRA_CHARSETS=all              "
        make && make install

        #copy configure file
        SCRIPT_DIR="$MYSQL_DIR/start"
        test -d $SCRIPT_DIR || mkdir -p $SCRIPT_DIR
        eval "rsync -avzp $RSYNC/my.cnf $SCRIPT_DIR"
        eval "rsync -avzp $RSYNC/init.sh $SCRIPT_DIR"

    elif [ "$INSTALL_TYPE" == "libmysql" ]; then
        eval "cmake     -DCMAKE_INSTALL_PREFIX=$MYSQL_DIR \
                        -DWITHOUT_SERVER=ON
             "
        make && make install

    elif [ "$INSTALL_TYPE" == "mysqlclient" ]; then
        eval "cmake     -DCMAKE_INSTALL_PREFIX=$MYSQL_DIR \
             "
        make mysqlclient libmysql && make install
    fi

    echo "add bin path to /etc/bashrc"
    echo "" >> /etc/bashrc
    echo "#mysql envirment" >> /etc/bashrc
    echo "export PATH=\$PATH:$MYSQL_DIR/bin" >> /etc/bashrc
    echo "add ld path to $LD_PATH"
    echo "$MYSQL_DIR/lib" > $LD_PATH
    ldconfig
}

main $1 $2

install_mysql.sh

[[email protected] ~]# mysqladmin -S /tmp/mysql3306.sock shutdown  #停止
[[email protected] ~]# sh /usr/local/mysql55/start/my3306.sh     #启动
时间: 2024-11-10 00:53:35

安装脚本的相关文章

mysql自动安装脚本

为适应自己工作习惯和需要,花一点时间写了一个mysql自动安装脚本,供大家参考学习. 注意: 1.需要先安装cmake 2.数据库版本需要在第二步安装mysql时修改 3.该脚本是以root用户安装并启动 脚本内容如下: ######################################################################## #mysql自动安装脚本,其中变量/mysql_v_dir/和/port/可根据实际需要修改    # #执行脚本命令:sh mys

lnmp源码安装-脚本执行

lnmp 源码安装- 脚本执行 源码包版本: nginx1.9 mysql5.6.4 php5.6 使用: 将lnmp.tar.gz 解压至 根目录下,进入/lnmp/install/目录下,执行install.sh脚本即可.选择性安装! 安装过程中会有些警告信息显示,不影响. 整合包地址:http://pan.baidu.com/s/1dFp7gqP =======================代码============================= #!/bin/bash #####

lnmp安装脚本

lnmp安装脚本.一起学习.有更好的建议请留言. #!/bin/bash # # describe: linux nginx mysql php install FileS=/updatefile mkdir -p $FileS # 安装lrzsz 方便后续文件上传 wget http://vault.centos.org/6.5/os/x86_64/Packages/lrzsz-0.12.20-27.1.el6.x86_64.rpm -P $FileS &>/dev/null rpm -v

mongodb安装脚本/启动脚本/配置文件

安装脚本 #!/bin/bash  #author: QingFeng #qq: 530035210 #blog: http://my.oschina.net/pwd/blog  #自动安装mongodb和初始化配置 #缺省的配置如下   logdir=/data/log/shell          #日志路径 log=$logdir/shell.log            #日志文件  is_font=1                #终端是否打印日志: 1打印 0不打印  is_log

ipvsadm+keepalived+inotify-tools自动安装脚本

#!/bin/bash # # #this is install keepalived+lvs-DR # # tar_dir=/usr/src configure_yum() { echo "[rhel-local]">/etc/yum.repos.d/rhel-local.repo echo "baseurl=file:///media/Server">>/etc/yum.repos.d/rhel-local.repo echo "en

【shell】oracle安装脚本 - 未完成

自动安装oracle所需要的rpm包(需要访问外网): #! /bin/sh rpmpack=" binutils compat-libstdc++* elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libg

Ubuntu Or Debian L2TP VPN 一键安装脚本

#!/bin/bash if [ $(id -u) != "0" ]; then printf "Error: You must be root to run this tool!\n" exit 1 fi clear printf " #################################################### # # # This is a Shell-Based tool of l2tp installation # #

Centos7搭建pptp VPN一键安装脚本

Centos7搭建pptp一键安装脚本 废话不多说,先上脚本地址:Centos7一键pptp 使用: wget https://raw.githubusercontent.com/DanylZhang/VPS/master/CentOS7-pptp-host1plus.sh chmod +x ./CentOS7-pptp-host1plus.sh ./CentOS7-pptp-host1plus.sh -u your_username -p your_password 1 2 3 可在-u.-p

L2TP/IPSec一键安装脚本

本脚本适用环境:系统支持:CentOS6+,Debian7+,Ubuntu12+内存要求:≥128M更新日期:2017 年 05 月 28 日 关于本脚本:名词解释如下L2TP(Layer 2 Tunneling Protocol)IPSec(Internet Protocol Security)IKEv2 (Internet Key Exchange v2)能实现 IPsec 的目前总体上有 openswan,libreswan,strongswan 这3种.libreswan 是基于 ope

centos shell编程5LANMP一键安装脚本 第三十九节课

centos shell编程5LANMP一键安装脚本  第三十九节课 上半节课 下半节课 f