티스토리 뷰

#!/bin/bash

HOMEPATH=$(pwd)
CURRENT_USER="$(whoami)"

#JAVA HOME 설정
JAVA_HOME="/sw/sol/java/java1.8"
#고유값 APP 이름 설정
APP_NM="jenkins_agent"
#APP 사용자 설정
APP_USER="root"
#JAVA 실행 명령어
APP_SCRIPT="-jar agent.jar -jnlpUrl http://172.30.0.3:8081/jenkins/computer/ftapp/slave-agent.jnlp -secret @secret-file -workDir /sw/sol/jenkins"

if [ $CURRENT_USER = $APP_USER ]
then
    # ---------------------------------------------------------------------------
    # JVM argument
    # ---------------------------------------------------------------------------
    JVM_ARGS="-DappName=$APP_NM"
    JVM_ARGS="$JVM_ARGS -Djava.security.egd=file:///dev/urandom"

    # ---------------------------------------------------------------------------
    # memory argument
    # ---------------------------------------------------------------------------
    MEM_ARGS="-Xms256m -Xmx256m"

    # ---------------------------------------------------------------------------
    #
    # ---------------------------------------------------------------------------
    case $1 in
            start)
                    XPID=`pgrep -f $APP_NM`
                    if [ "$XPID" !=  "" ]
                    then
                            kill -9 $XPID
                            echo "Current pid "$XPID" killed..................."
                    fi
                    echo "Start"
                    $JAVA_HOME/bin/java $JVM_ARGS $MEM_ARGS $APP_SCRIPT &
                    ;;
            stop)
                    echo "Stop"
                    XPID=`pgrep -f $APP_NM`
                    if [ "$XPID" !=  "" ]
                    then
                            kill -9 $XPID
                            echo "Current pid $XPID killed..................."
                    fi
                    ;;
            *)
                     echo "Usage  start | stop"
                    ;;
    esac
else
        echo "invalid user"
fi

 

반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함