#!/bin/bash

ping -c 2 local.vrmaker.vip:1443
cd /home/pi/ipc

#获取最新版本号
curl -o latest https://local.vrmaker.vip:1443/ipc/version
latest=`cat ./latest`
echo "latest: ${latest}"

# 获取当前版本
if [ -e ./version ];then
	version=`cat ./version`
else
	version="-1"
fi

echo "current version: ${version}"

if [ "$latest" != "$version" ];then
	curl -O "https://local.vrmaker.vip:1443/ipc/IPC-${latest}-SNAPSHOT.jar"
	cp ./latest ./version
fi


JAVA_HOME=/opt/jdk1.8.0_152
export PATH=$PATH:$JAVA_HOME/bin

java \
	-jar \
	-Dspring.profiles.active=pro \
	-Dfile.encoding=utf-8 \
	-Duser.timezone=GMT+08 \
	-Duser.language=zh \
	-Xmx1024m \
	-XX:MaxDirectMemorySize=512m \
	"/home/pi/ipc/IPC-${latest}-SNAPSHOT.jar"

