51 lines
1.1 KiB
Bash
Executable File
51 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# get real path of softlink
|
|
get_real_path() {
|
|
local f="$1"
|
|
while [ -h "$f" ]; do
|
|
ls=`ls -ld "$f"`
|
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
if expr "$link" : '/.*' > /dev/null; then
|
|
f="$link"
|
|
else
|
|
f=`dirname "$f"`/"$link"
|
|
fi
|
|
done
|
|
echo "$f"
|
|
}
|
|
|
|
install_server() {
|
|
SERVER="$1"
|
|
APP="$2"
|
|
TARGET_DIR="/data/program/$APP"
|
|
LOGS_DIR="/data/program/logs/$APP"
|
|
ssh "$SERVER" "mkdir -p $TARGET_DIR"
|
|
ssh "$SERVER" "tar -xzv -C $TARGET_DIR" < springboot-app.tar.gz
|
|
ssh "$SERVER" "mkdir -p $LOGS_DIR && ln -sf $LOGS_DIR $TARGET_DIR/logs"
|
|
}
|
|
|
|
|
|
prg_path=$(get_real_path "$0")
|
|
echo "Script path [$prg_path]"
|
|
|
|
# Service Home
|
|
pushd $(dirname "$prg_path") > /dev/null
|
|
WORK_DIR=$(pwd)
|
|
echo "Work dir [$WORK_DIR]"
|
|
|
|
if [ -z "$1" ] || [ -z "$2" ] ; then
|
|
echo 'Usage: ./install-springboot-app.sh test|prod cms|fsagent'
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$1" == "test" ]; then
|
|
echo "Install test."
|
|
install_server 'appweb@118.24.251.131' cms
|
|
elif ["$1" == "prod" ]; then
|
|
echo "Deploy prod."
|
|
fi
|
|
|
|
popd > /dev/null
|
|
|