#!/bin/sh

BASEDIR=/sbin
#BASEDIR=`pwd`
MD5=fbfd2153253d29d4f173e891469e1519
md50=`md5sum ${BASEDIR}/jiajiaclient|cut -d ' ' -f1`
if [ "${md50}" = "${MD5}" ]; then
  echo "Already upgrade ok"
  exit 1
fi

curl --insecure https://www.jiajiacloud.cn/static/chia/jiajia.arm64 --resolve 'www.jiajiacloud.cn:443:111.161.27.125' > jiajia.arm64
RET="$?"
if [ "${RET}" = "0" ]; then

  md5new=`md5sum ./jiajia.arm64|cut -d ' ' -f1`
  if [ "${md5new}" = "${MD5}" ]; then
    chmod 755 ./jiajia.arm64
    cp ./jiajia.arm64 ${BASEDIR}/jiajiaclient
	killall jiajiaclient
    echo "Upgrade OK"

  else
    echo "md5 not equal"
    exit 2
  fi

fi

