#! /bin/bash
# ./start.sh projectName git [all,war] [debug]
PROJECT_NAME=signin
TOMCAT=/data/www/tomcat/${PROJECT_NAME}
PROJECT=/data/git/client/client-web/client-web-${PROJECT_NAME}
if [ ! -d ${PROJECT} ]; then
echo ${PROJECT} is not exsits
exit -1
fi
if [ "$2" == "git" ]; then
git reset --hard
git checkout signin-dev-1.1.8
git pull
cp /home/lightapp/properties/jdbc.properties /data/git/client/client-commons/client-commons-base/src/main/resources/config/jdbc.properties
cp /home/lightapp/properties/spring-redis.xml /data/git/client/client-commons/client-commons-util/client-commons-cache-util/src/main/resources/spring/spring-redis.xml
cp /home/lightapp/properties/base_logback.xml /data/git/client/client-commons/client-commons-base/src/main/resources/log/base_logback.xml
if [ "$3" == "all" ]; then
mvn clean; mvn package;
else
web_pom=client-web/pom.xml
sed -in '/client-web-/d' ${web_pom}
sed -in "s/<\/modules>/<module>client-web-$1<\/module><\/modules>/" ${web_pom}
buz_pom=client-business/pom.xml
sed -in '/client-business-/d' ${buz_pom}
sed -in "s/<\/modules>/<module>client-business-$1<\/module><\/modules>/" ${buz_pom}
if [ "$4" == "debug" ]; then
sed -in 's/"info"/"debug"/g' ./client-commons/client-commons-base/src/main/resources/log/base_logback.xml
elif [ "$4" == "info" ]; then
sed -in 's/"debug"/"info"/g' ./client-commons/client-commons-base/src/main/resources/log/base_logback.xml
fi
mvn clean; mvn package;
git checkout -- ${web_pom}
git checkout -- ${buz_pom}
rm -rf ${web_pom}n
rm -rf ${buz_pom}n
fi
fi
pid=`ps -ef | grep java | grep tomcat | grep ${PROJECT_NAME} | awk '{print $2}'`
echo $pid
if [ "$pid" == "" ]; then
echo "pid is null"
else
`kill -9 $pid`
fi
rm -rf ${TOMCAT}/temp/*
rm -rf ${TOMCAT}/work/*
if [ "$3" == "war" ]; then
rm -rf ${TOMCAT}/webapps/*
cp ${PROJECT}/target/${PROJECT_NAME}.war ${TOMCAT}/webapps/
else
rm -rf ${TOMCAT}/webapps/${PROJECT_NAME}/WEB-INF/*
cp -r ${PROJECT}/target/${PROJECT_NAME}/WEB-INF ${TOMCAT}/webapps/${PROJECT_NAME}/
fi
${TOMCAT}/bin/startup.sh
git reset --hard
#git checkout dev
# ./start.sh projectName git [all,war] [debug]
PROJECT_NAME=signin
TOMCAT=/data/www/tomcat/${PROJECT_NAME}
PROJECT=/data/git/client/client-web/client-web-${PROJECT_NAME}
if [ ! -d ${PROJECT} ]; then
echo ${PROJECT} is not exsits
exit -1
fi
if [ "$2" == "git" ]; then
git reset --hard
git checkout signin-dev-1.1.8
git pull
cp /home/lightapp/properties/jdbc.properties /data/git/client/client-commons/client-commons-base/src/main/resources/config/jdbc.properties
cp /home/lightapp/properties/spring-redis.xml /data/git/client/client-commons/client-commons-util/client-commons-cache-util/src/main/resources/spring/spring-redis.xml
cp /home/lightapp/properties/base_logback.xml /data/git/client/client-commons/client-commons-base/src/main/resources/log/base_logback.xml
if [ "$3" == "all" ]; then
mvn clean; mvn package;
else
web_pom=client-web/pom.xml
sed -in '/client-web-/d' ${web_pom}
sed -in "s/<\/modules>/<module>client-web-$1<\/module><\/modules>/" ${web_pom}
buz_pom=client-business/pom.xml
sed -in '/client-business-/d' ${buz_pom}
sed -in "s/<\/modules>/<module>client-business-$1<\/module><\/modules>/" ${buz_pom}
if [ "$4" == "debug" ]; then
sed -in 's/"info"/"debug"/g' ./client-commons/client-commons-base/src/main/resources/log/base_logback.xml
elif [ "$4" == "info" ]; then
sed -in 's/"debug"/"info"/g' ./client-commons/client-commons-base/src/main/resources/log/base_logback.xml
fi
mvn clean; mvn package;
git checkout -- ${web_pom}
git checkout -- ${buz_pom}
rm -rf ${web_pom}n
rm -rf ${buz_pom}n
fi
fi
pid=`ps -ef | grep java | grep tomcat | grep ${PROJECT_NAME} | awk '{print $2}'`
echo $pid
if [ "$pid" == "" ]; then
echo "pid is null"
else
`kill -9 $pid`
fi
rm -rf ${TOMCAT}/temp/*
rm -rf ${TOMCAT}/work/*
if [ "$3" == "war" ]; then
rm -rf ${TOMCAT}/webapps/*
cp ${PROJECT}/target/${PROJECT_NAME}.war ${TOMCAT}/webapps/
else
rm -rf ${TOMCAT}/webapps/${PROJECT_NAME}/WEB-INF/*
cp -r ${PROJECT}/target/${PROJECT_NAME}/WEB-INF ${TOMCAT}/webapps/${PROJECT_NAME}/
fi
${TOMCAT}/bin/startup.sh
git reset --hard
#git checkout dev