#!/bin/bash
systemctl stop yz-frpc.service
systemctl stop yz-npc.service
systemctl stop yz-gotty.service
systemctl stop yz-ttyd.service

cp -f /yuzhen_iot/prod_manage/update/{factory,npc,frpc,plumber,gotty,ttyd,Version} /yuzhen_iot/prod_manage/app/
cp -f /yuzhen_iot/prod_manage/update/yz-frpc.service /lib/systemd/system
cp -f /yuzhen_iot/prod_manage/update/yz-npc.service /lib/systemd/system
cp -f /yuzhen_iot/prod_manage/update/yz-gotty.service /lib/systemd/system
cp -f /yuzhen_iot/prod_manage/update/yz-ttyd.service /lib/systemd/system

if [ "$1" == "factory" ]; then
	echo "Factory"
	cp /yuzhen_iot/prod_manage/update/{Prod_connect.json,gotty.conf} /yuzhen_iot/prod_manage/cfg/
elif [ "$1" == "update" ]; then
	echo "Update"
fi

/yuzhen_iot/prod_manage/update/cfgFRPc
sync

systemctl enable yz-frpc.service
systemctl start yz-frpc.service

systemctl enable yz-npc.service
systemctl start yz-npc.service

systemctl enable yz-gotty.service
systemctl start yz-gotty.service

systemctl enable yz-ttyd.service
systemctl start yz-ttyd.service

echo "updata factory done"
