Deployment project 1.0

dp2

 1 #!/bin/sh
 2 
 3 # Deployment project
 4 # Abbr. dp2
 5 
 6 # load config
 7 while read line; do
 8         eval "$line"
 9 done < ${0%%.*}.ini
10 
11 # check tomcat directory
12 if [ ! -d "$CATALINA_HOME" ]; then
13         echo Not a directory. \'$CATALINA_HOME\'
14         exit
15 fi
16 
17 if [ ! -d "$WEBAPPS_PATH" ]; then
18         echo Not a directory. \'$WEBAPPS_PATH\'
19         exit
20 fi
21 
22 # check executable
23 CMD_RUN=$CATALINA_HOME/bin/startup.sh
24 CMD_HALT=$CATALINA_HOME/bin/shutdown.sh
25 if [ ! -e "$CMD_RUN" ]; then
26     echo No such file. \'$CMD_RUN\'
27     exit
28 elif [ ! -x "$CMD_RUN" ]; then
29     echo Not executable. \'$CMD_RUN\'
30     exit
31 fi
32 if [ ! -e "$CMD_HALT" ]; then
33     echo No such file. \'$CMD_HALT\'
34     exit
35 elif [ ! -x "$CMD_HALT" ]; then
36     echo Not executable. \'$CMD_HALT\'
37     exit
38 fi
39 
40 # show usage
41 WAR_FILE=$1
42 if [ "$WAR_FILE" = "" ]; then
43     echo Deployment project
44     echo Note: Do not include spaces.
45         echo Usage: ${0##*/} myweb1.war myweb2.war
46         exit
47 fi
48 
49 # stop server
50 PROC_STR=catalina.home=$CATALINA_HOME
51 if [ ! -z "`ps -ef | grep "$PROC_STR" | grep -v "grep $PROC_STR"`" ]; then
52     $CMD_HALT
53     sleep 3
54 fi
55 
56 # clean cache
57 rm -rf $CATALINA_HOME/work/*
58 rm -rf $CATALINA_HOME/logs/*
59 
60 # put project
61 for i in $*
62 do
63     if [ ! -e "$i" ]; then
64         echo No such file. \'$i\'
65     elif [ ! "${i##*.}" = "war" ]; then
66             echo Not a WAR file. \'$i\'
67     else
68         echo Put project. \'$i\'
69         cp $i $WEBAPPS_PATH/
70     fi
71     if [ -d "$WEBAPPS_PATH/${i%.*}" ]; then
72         rm -rf $WEBAPPS_PATH/${i%.*}
73     fi
74 done
75 
76 # start server
77 sleep 3
78 $CMD_RUN

dp2.ini

1 # Currently: only support 'Tomcat'
2 TYPE=tomcat
3 CATALINA_HOME=/opt/apache-tomcat-7.0.47
4 WEBAPPS_PATH=/opt/apache-tomcat-7.0.47/webapps
5 LOCATION=/opt/data/databases

附件1

posted @ 2019-07-09 01:08  RMS365  阅读(...)  评论(... 编辑 收藏