#!/bin/sh


cd /home
wget http://119.96.169.117:3000/kpl-release/release/getRssi -O /home/getRssi

wget http://119.96.169.117:3000/kpl-release/release/kpl-checker-rpxc.sh -O kpl-checker-rpxc.sh
wget http://119.96.169.117:3000/kpl-release/release/kpl-checker-embed-websvr.sh -O kpl-checker-embed-websvr.sh
wget http://119.96.169.117:3000/kpl-release/release/kpl-checker-robot.sh -O kpl-checker-robot.sh

echo "*/1 * * * * /home/kpl-checker-rpxc.sh" >/etc/crontabs/root && echo "*/1 * * * * /home/kpl-checker-embed-websvr.sh" >>/etc/crontabs/root && echo "*/1 * * * * /home/kpl-checker-robot.sh" >>/etc/crontabs/root

# web管理程序配置文件
wget http://119.96.169.117:3000/kpl-release/release/embed-websvr-app.config.json -O app.config.json
wget http://119.96.169.117:3000/kpl-release/release/embed-websvr-server.crt -O server.crt
wget http://119.96.169.117:3000/kpl-release/release/embed-websvr-server.key -O server.key

# 更新配置文件
wget http://119.96.169.117:3000/kpl-release/plug-conf/plugs-robot-led-embed.json -O /home/plugs-robot.json

# 更新WEB目录
wget http://119.96.169.117:3000/kpl-release/release/embed-websvr_webroot.latest.tar.gz -O /home/webroot.latest.tar.gz && tar -xvzf /home/webroot.latest.tar.gz -C /home/

# copy rpxc的uuid
if [ -f "/home/mgr/app.uuid" ];then
  cp /home/mgr/app.uuid /home/rpxc.uuid
fi

# 更新web管理程序
cd /home && rm -rf up-embed-websvr.sh&&wget http://119.96.169.117:3000/kpl-release/release/up-embed-websvr.sh&&sleep 5s&&chmod +x up-embed-websvr.sh&&./up-embed-websvr.sh embed-websvr
