Tomcat Publishing Script

Source: Internet
Author: User

#!/bin/bash

#发布相关目录
tomcat_log= '/home/codepub/tomcatlog '
Dev_package= '/home/codepub/package '
Old_package= '/home/codepub/oldpackage '
Tomcat_dir= '/home/zoumi/youximao/tomcat ' #修改
Tomcat_start_dir= '/home/zoumi/youximao/tomcat/bin ' #修改
mysqllog= '/home/codepub/mysqllogs '
mysqlbackup= '/home/codepub/mysqlbackup '

Cd/home #可能需要更改
If [-D codepub];then
if [!-D Tomcatlog]
Then
mkdir Tomcatlog
chmod 775 Tomcatlog
Fi

if [!-D Package]
Then
mkdir Package
Chmod 775 Package
Fi

if [!-D Oldpackage]
Then
mkdir Oldpackage
chmod 775
Fi

if [!-D Mysqllogs]
Then
mkdir Mysqllogs
chmod 775 Mysqllogs
Fi
Else
mkdir codepub
chmod 775 Codepub
Cd/home/codepub #可能需要更改
mkdir Tomcatlog Package Oldpackage mysqllogs
chmod 775 Tomcatlog Package Oldpackage Mysqllogs
Fi

#用户需要修改的参数 Database Connection Parameters
User= ' Root '
Port= ' 3306 '
Passwd= ' 123456 '
Time= "$ (date +"%y%m%d%h%m%s ")"


echo "Please input update or return"
echo "Update Input 1"
echo "Return input 2"
Read-p "Please input release type:" Type

Update () {
$tomcat _start_dir/shutdown.sh &>/dev/null;sleep 5
Process= "$ (ps aux | grep tomcat | grep" $tomcat _start_dir "| awk ' {print $} ')"
For PS in $process
Do
If [-N "$ps"];then
Kill-9 $ps
Fi
Done
Redis= "$ (ps aux | grep redis | grep"/usr/local/bin/"| awk ' {print $} ')"
For RD in $redis
Do
Kill-9 $RD
Done

CD $tomcat _dir
TAR-ZCPVPF $old _package/$Time. tar.gz $tomcat _dir/webapps/* >> $Tomcat _log/tomcat-tar-$Time. Log
echo "Input New Develop package"
Read-p "Please input package_name:" Package_name
echo "Input New Database Script"
Read-p "Please input script_name:" Script_name
If [-N "$script _name"]
Then
echo "----------start executing the database script file----------"
Mysql-u $User-P $Port-p$passwd-bse ' source/home/zoumi/' $script _name ' > $Mysqllog/mysql-$Time. Log
echo "-----------intercept tomcat boot log 50S-----------"
Fi
Yes | cp-fr/home/zoumi/$package _name $tomcat _dir/webapps/#发布包目录位置 and may need to be modified
$tomcat _start_dir/startup.sh
Tail-f $tomcat _dir/logs/catalina.out > $Tomcat _log/tomcat-up-$Time. Log &
Sleep 50
Taps= "$ (ps aux | grep tail | grep" $tomcat _dir/logs/catalina.out "| awk ' {print $} ')"
If [-N "$taps"];then
Kill-9 $taps
Fi

/usr/local/bin/redis-server--port 6379 &
/usr/local/bin/redis-server--port 8888 &
# cat $Tomcat _log/tomcat-up-$Time. Log | grep "Error"
}


Return () {
$tomcat _start_dir/shutdown.sh &>/dev/null
Read-p "Please input this Yasuo oldpackage" Ago_package
TAR-ZXPF $old _package/$ago _package-c/home/zoumi/youximao/tomcat/webapps/
/home/zoumi/youximao/tomcat/bin/startup.sh >>/home/tomcat-oldup-$Time. Log
Cat $Tomcat _log/tomcat-oldup-$Time. Log | grep "Error"
}

Case ' $type ' in
"1")
Update
;;

"2")
Return
;;

*)
echo "Input error!"
Esac
Exit 0

Tomcat Publishing Script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.