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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #!/bin/bash
JAR_NAME="thingstream.jar" JAR_PATH="/eventCenter" NEW_JAR_PATH="/tmp/${JAR_NAME}"
echo "Checking for running JAR process..." PID=$(ps aux | grep "${JAR_NAME}" | grep -v grep | awk '{print $2}') if [ -n "$PID" ]; then echo "Found running JAR process with PID: ${PID}. Killing it..." kill -9 $PID sleep 2 else echo "No running JAR process found." fi
if [ -f "${JAR_PATH}/${JAR_NAME}" ]; then echo "Removing old JAR file..." rm -f "${JAR_PATH}/${JAR_NAME}" fi
if [ -f "${NEW_JAR_PATH}" ]; then echo "Moving new JAR file to ${JAR_PATH}..." mv "${NEW_JAR_PATH}" "${JAR_PATH}/" else echo "New JAR file not found at ${NEW_JAR_PATH}. Exiting..." exit 1 fi
LOG_FILE="$SCRIPT_PATH/log.txt"
"$JAR_PATH/eventCenter.sh" > "$LOG_FILE" 2>&1
if [ $? -eq 0 ]; then echo "Script executed successfully." else echo "Error occurred while executing script." fi
echo "Deployment completed."
|