Created
July 4, 2015 15:29
-
-
Save nkcoder/6117e47eab850f1431c0 to your computer and use it in GitHub Desktop.
jetty自动部署的脚本,仅供参考
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
################################################################# | |
# deploy timediff project | |
# author: daniel | |
# last update: 2015-07-04 | |
################################################################ | |
readonly timediff_dir="/opt/web/timediff" | |
readonly timediff_backup="/opt/web/backup" | |
readonly war_backup="/opt/web/backup/war" | |
readonly new_war_dir="/opt/web/new_war" | |
readonly now_time=`date '+%Y%m%d-%H%M'` | |
readonly jetty_dir="/usr/local/jetty-9.3" | |
readonly jetty_pid="/var/run/jetty.pid" | |
# stop jetty | |
stop_jetty() { | |
if [ -e $jetty_pid ]; then | |
echo "=======================stopping jetty==========================" | |
$jetty_dir/bin/jetty.sh stop | |
else | |
echo "=======================jetty not running=======================" | |
fi | |
if [ -e $jetty_pid ]; then | |
echo "=======================stop jetty again========================" | |
sleep 2 | |
$jetty_dir/bin/jetty.sh stop | |
fi | |
} | |
# backup and unzip project | |
backup_and_unzip() { | |
echo "===================backup/unzip start===============================" | |
# backup timediff and timediff.war | |
mv -f $timediff_dir $timediff_backup/timediff.$now_time | |
mv -f $war_backup/timediff.war $war_backup/timediff.war.$now_time | |
# unzip the war to deploy | |
unzip $new_war_dir/timediff.war -d $timediff_dir | |
# mv timediff.war to backupo dir | |
mv $new_war_dir/timediff.war $war_backup | |
echo "==================backup/unzip end=================================" | |
} | |
# start jetty | |
start_jetty() { | |
echo "=================starting jetty===========================" | |
$jetty_dir/bin/jetty.sh start | |
if [ -e $jetty_pid ]; then | |
echo "==============jetty is running========================" | |
fi | |
} | |
stop_jetty | |
backup_and_unzip | |
start_jetty | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment