From d06c44a4e4ea495a88804554a9e11acb0e656206 Mon Sep 17 00:00:00 2001 From: limju Date: Wed, 18 Oct 2023 12:14:28 +0900 Subject: [PATCH] build: shell script add --- shell/backupApi.sh | 17 +++++++++++++++++ shell/deployApi.sh | 18 ++++++++++++++++++ shell/deployEnsApi.sh | 3 --- shell/startApi.sh | 22 ++++++++++++++++++++++ shell/startEnsApi.sh | 7 ------- shell/stopApi.sh | 20 ++++++++++++++++++++ shell/stopEnsApi.sh | 13 ------------- 7 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 shell/backupApi.sh create mode 100644 shell/deployApi.sh delete mode 100644 shell/deployEnsApi.sh create mode 100644 shell/startApi.sh delete mode 100644 shell/startEnsApi.sh create mode 100644 shell/stopApi.sh delete mode 100644 shell/stopEnsApi.sh diff --git a/shell/backupApi.sh b/shell/backupApi.sh new file mode 100644 index 0000000..944de25 --- /dev/null +++ b/shell/backupApi.sh @@ -0,0 +1,17 @@ +#!/bin/sh +if [ $# -ne 1 ]; then + echo "-----------------------------------" + echo " Undefined parameter" + echo "./backupApi.sh [application name]" + echo "-----------------------------------" + exit 1 +fi + +if [ ! -f "$1.jar" ]; then + echo "===================================" + echo " $1.jar file not exist" + echo "===================================" + exit 1 +fi +mv /applications/mens/$1.jar /applications/mens/$1.jar_backup +#cp /var/lib/jenkins/workspace/MENS-API/mens-api/target/mens-api.jar /applications/mens/ens-api.jar diff --git a/shell/deployApi.sh b/shell/deployApi.sh new file mode 100644 index 0000000..2fd1c22 --- /dev/null +++ b/shell/deployApi.sh @@ -0,0 +1,18 @@ +#!/bin/sh +if [ $# -ne 1 ]; then + echo "-----------------------------------" + echo " Undefined parameter" + echo "./deployApi.sh [application name]" + echo "-----------------------------------" + exit 1 +fi + +if [ ! -f "$1.jar" ]; then + echo "===================================" + echo " $1.jar file not exist" + echo "===================================" + exit 1 +fi + +mv /applications/mens/$1.jar /applications/mens/$1.jar_backup +cp /var/lib/jenkins/workspace/MENS-API/mens-api/target/$1.jar /applications/mens/$1.jar diff --git a/shell/deployEnsApi.sh b/shell/deployEnsApi.sh deleted file mode 100644 index 5295ad7..0000000 --- a/shell/deployEnsApi.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -mv /applications/mens/mens-api.jar /applications/mens/mens-api.jar_backup -cp /var/lib/jenkins/workspace/MENS-API/mens-api/target/mens-api.jar /applications/mens/ens-api.jar diff --git a/shell/startApi.sh b/shell/startApi.sh new file mode 100644 index 0000000..c5d72d0 --- /dev/null +++ b/shell/startApi.sh @@ -0,0 +1,22 @@ +#!/bin/sh +if [ $# -ne 1 ]; then + echo "-----------------------------------" + echo " Undefined parameter" + echo "./startApi.sh [application name]" + echo "-----------------------------------" + exit 1 +fi + +if [ ! -f "$1.jar" ]; then + echo "===================================" + echo " $1.jar file not exist" + echo "===================================" + exit 1 +fi + +echo "================================" +echo " $1 deamon start" +echo "================================" +JAVA_HOME=/lib/jvm/java-17-openjdk +export JAVA_HOME +nohup $JAVA_HOME/bin/java -Dspring.profiles.active=prod -jar /applications/mens/$1.jar > /dev/null & diff --git a/shell/startEnsApi.sh b/shell/startEnsApi.sh deleted file mode 100644 index 37c6bdd..0000000 --- a/shell/startEnsApi.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -echo "======================" -echo "ens-api deamon start" -echo "======================" -JAVA_HOME=/lib/jvm/java-17-openjdk -export JAVA_HOME -nohup $JAVA_HOME/bin/java -Dspring.profiles.active=dev -jar /applications/mens/mens-api.jar > /dev/null & diff --git a/shell/stopApi.sh b/shell/stopApi.sh new file mode 100644 index 0000000..a81d57e --- /dev/null +++ b/shell/stopApi.sh @@ -0,0 +1,20 @@ +#!/bin/sh +if [ $# -ne 1 ]; then + echo "-----------------------------------" + echo " Undefined parameter" + echo "./stopApi.sh [application name]" + echo "-----------------------------------" + exit 1 +fi + +PID=`ps -ef | grep java | grep $1- | awk '{print $2}'` +echo "Process ID: $PID" +if [ -z $PID ]; then + echo "No process is running" +else + echo "Kill process" + kill $PID + echo "=========================" + echo "mens-api deamon stop" + echo "=========================" +fi diff --git a/shell/stopEnsApi.sh b/shell/stopEnsApi.sh deleted file mode 100644 index c08a9c3..0000000 --- a/shell/stopEnsApi.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -PID=`ps -ef | grep java | grep ens-api- | awk '{print $2}'` -echo "Process ID: $PID" -if [ -z $PID ]; then - echo "No process is running" -else - echo "Kill process" - kill $PID - echo "=========================" - echo "mens-api deamon stop" - echo "=========================" -fi -