#!/bin/bash


echo "Please input board ip:"
read bip

echo Stopping services...
ssh root@$bip "ps -ef | grep camera | awk -e '{print \$2}' | xargs kill -9"

echo Copying ffmpeg...
scp ffmpeg.tar.gz root@$bip:/home/root/
ssh root@$bip "mkdir -p /usr/local/ && rm -rf ffmpeg && tar -mzxf /home/root/ffmpeg.tar.gz -C /usr/local/"

echo Copying qt...
scp qt5.tar.gz root@$bip:/home/root/
ssh root@$bip "rm -rf qt5 && tar -mzxf /home/root/qt5.tar.gz -C /home/root/"

echo Copying tslib...
scp tslib.tar.gz root@$bip:/home/root/
ssh root@$bip "rm -rf tslib && tar -mzxf /home/root/tslib.tar.gz -C /home/root/"

echo Copying camera...
scp camera.tar.gz root@$bip:/home/root/
ssh root@$bip "mkdir -p /home/root/camera && tar -mzxf /home/root/camera.tar.gz -C /home/root/camera/ && mv /home/root/camera/rc.local /etc/rc.local && mv /home/root/camera/ntpdate /etc/default/ntpdate && mv /home/root/camera/crontab /etc/crontab && cp -f /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime"

echo Done


