Ver código fonte

Backup the shell script

sunyj 8 anos atrás
pai
commit
2d89682513
1 arquivos alterados com 121 adições e 0 exclusões
  1. 121 0
      kanban-console/kanban

+ 121 - 0
kanban-console/kanban

@@ -0,0 +1,121 @@
+#!/bin/sh
+#
+# Tomcat For UAS control script
+# 
+# chkconfig: 2345 61 61 
+# description: The Kanban Application Server 
+# 
+# Source function library. 
+
+source /etc/profile
+#. /etc/rc.d/init.d/functions
+#export LANG="zh_CN.UTF-8"
+
+#JAVA_HOME=/usr/local/jdk1.7.0_55
+#export JAVA_HOME=$JAVA_HOME
+
+BASE_DIR=/home/uas/program/kanban
+BACKUP_DIR=$BASE_DIR
+PROFILE=test
+MAVEN_URI=http://maven.ubtob.com
+
+CONTEXT_NAME=kanban-console
+VERSION=0.0.1-SNAPSHOT
+WF=$CONTEXT_NAME-$VERSION.war
+PID_CMD="ps aux | grep $WF | grep -v 'grep' | awk '{print \$2}'"
+cd $BASE_DIR
+ 
+start(){
+    if [ ! "`eval ${PID_CMD}`" ]; then
+        echo "Starting service..."
+        cd $BASE_DIR/node0
+        startWithPort 8063
+        cd $BASE_DIR/node1
+        startWithPort 8064
+        cd $BASE_DIR
+        status
+    else
+        echo "Service is already running."
+    fi
+}
+
+startWithPort(){
+    nohup java -Dserver.port=$1 -Dspring.profiles.active=$PROFILE -Dserver.context-path=/kanban -server -XX:PermSize=128M -XX:MaxPermSize=256m -jar $BASE_DIR/$WF 1>log.log 2>nohup.log &
+}
+
+stop(){
+    if [ "`eval ${PID_CMD}`" ]; then
+        echo "Stopping service..."
+        eval ${PID_CMD} | xargs kill -9
+    else
+        echo "Service is not running."
+    fi
+}
+
+restart(){
+    if [ "`eval ${PID_CMD}`" ]; then
+        stop
+    fi
+    start
+}
+
+status(){
+    if [ "`eval ${PID_CMD}`" ]; then
+        ps aux | grep $WF | grep -v 'grep'
+    else
+        echo "Service is not running."
+    fi
+}
+
+update(){
+    metadata_last=maven-metadata-last.xml
+    metadata=maven-metadata.xml
+    wget -q -O $metadata $MAVEN_URI/artifactory/libs-snapshot-local/com/uas/kanban/$CONTEXT_NAME/maven-metadata.xml
+    time_last="0"
+    if [ -f $metadata_last ]; then
+        time_last=`cat $metadata_last|grep lastUpdated|awk '{print substr($1,14,14)}'`
+    fi
+    time=`cat $metadata|grep lastUpdated|awk '{print substr($1,14,14)}'`
+    if [ "$time_last" -ne "$time" ]; then
+        rm -rf $metadata_last
+        mv $metadata $metadata_last
+        install
+    fi
+}
+
+function install() {
+    stop
+    rm -rf $WF.bak
+    if [ -f $WF ]; then
+        mv -f $WF $WF.bak
+    fi
+    echo 'Downloading war file...'
+    wget $MAVEN_URI/artifactory/libs-snapshot-local/com/uas/kanban/$CONTEXT_NAME/$VERSION/$WF
+    echo 'Download succeeded'
+    start
+}
+
+case $1 in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    restart)
+        restart
+        ;;
+    status)
+        status
+        ;;
+    update)
+        update
+        ;;
+    install)
+        install
+        ;;
+    *)
+        echo "Usage: $0 {start|stop|restart|status|update|install}"
+        exit 1
+        ;;
+esac