81 lines
2.2 KiB
Bash
Executable File
81 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
SO_PATH="/home/smart/SmartOrganizer"
|
|
TASK_FILE="${SO_PATH}/tasks/upgrade_tms_to_last.conf"
|
|
|
|
get_current_verion_from_local()
|
|
{
|
|
url="http://127.0.0.1:8080/SmartTMS_S3/VersionController/version.do"
|
|
ret=`curl -s ${url}`
|
|
echo ${ret} | awk -F '"version":"' '{print $2}' | awk -F '"' '{print $1}'
|
|
}
|
|
|
|
get_last_version_from_remote()
|
|
{
|
|
url="http://c.baobaot.com/api/war/get_last_version"
|
|
ret=`curl -s ${url}`
|
|
echo ${ret}
|
|
}
|
|
|
|
CURRENT_VERSION=$(get_current_verion_from_local)
|
|
echo "Get CURRENT_VERSION [ ${CURRENT_VERSION} ] from local."
|
|
TARGET_VERSION=$(get_last_version_from_remote)
|
|
echo "Get TARGET_VERSION [ ${TARGET_VERSION} ] from remote."
|
|
|
|
UN=""
|
|
|
|
while getopts "s:t:p:" arg
|
|
do
|
|
case $arg in
|
|
s)
|
|
if [[ -n ${OPTARG} ]]; then
|
|
C=${CURRENT_VERSION}
|
|
CURRENT_VERSION=${OPTARG}
|
|
echo "Set CURRENT_VERSION [ ${C} => ${CURRENT_VERSION} ] from argument -s"
|
|
fi
|
|
;;
|
|
t)
|
|
if [[ -n ${OPTARG} ]]; then
|
|
T=${TARGET_VERSION}
|
|
TARGET_VERSION=${OPTARG}
|
|
echo "Set TARGET_VERSION [ ${T} => ${TARGET_VERSION} ] from argument -t"
|
|
fi
|
|
;;
|
|
p)
|
|
if [[ -n ${OPTARG} ]]; then
|
|
UN=${OPTARG}
|
|
fi
|
|
;;
|
|
?)
|
|
echo "Unkonw argument!"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z ${UN} ]]; then
|
|
echo "Password from argument -p mast given !!!"
|
|
exit 2
|
|
fi
|
|
|
|
if [[ -z ${CURRENT_VERSION} || -z ${TARGET_VERSION} ]]; then
|
|
echo "CURRENT_VERSION: ${CURRENT_VERSION}"
|
|
echo "TARGET_VERSION: ${TARGET_VERSION}"
|
|
echo "Can not get current or target version automatically, please give it use arguments."
|
|
echo " eg: xxx.sh -s current_version -t target_version"
|
|
exit 2
|
|
fi
|
|
|
|
echo "CURRENT_VERSION=\"${CURRENT_VERSION}\"
|
|
TARGET_VERSION=\"${TARGET_VERSION}\"
|
|
|
|
CFG_NAME=\"SmartTMS_S3\"
|
|
CFG_VERSION=\"\${TARGET_VERSION}\"
|
|
CFG_URL=\"https://static.baobaot.com/tms_war/\${TARGET_VERSION}.zip\"
|
|
CFG_FORMAT=\"zip\"
|
|
CFG_DIR=\"\${TARGET_VERSION}\"
|
|
CFG_UN=\"${UN}\"
|
|
CFG_OUTPUT_PATH=\"/home/smart/.tms3/repo/versions/\${TARGET_VERSION}\"
|
|
CFG_EXECUTE=\"upgrade.sh\"
|
|
CFG_ARGS=\"\${CURRENT_VERSION} \${TARGET_VERSION}\"
|
|
" > ${TASK_FILE} |