#!/bin/bash

DATE=$(date +"%Y%m%d%H%M%S")
tsikill.sh
rm /root/TSIRUN/INSTALL/*
#mkdir -p ./backup/
#tar czf backup/$DATE.tgz /root /home /usr/bin/tsi* /etc/apt/sources.list.d /etc/init/tsiupload.conf /etc/envionment /usr/bin/tsiinstall /usr/bin/fancontrol_3 /usr/bin/fancontrol /etc/fancontrol
mkdir /home/TSILOG/fancontrol
mkdir /root/TSIRUN/INSTALL
#dpkg -i tsi-libhiredis-0.13.deb
#dpkg -i libevent-2.0-5_2.0.16-stable-1ubuntu0.2_amd64.deb
dpkg -i tsi-upgrade-2.3.deb
#dpkg -i libc-bin_2.17-93ubuntu4_amd64.deb
#dpkg -i libc6_2.17-93ubuntu4_amd64.deb
dpkg -i tsi-libuwsc-1.0.deb
dpkg -i tsi-librosskeys-1.0.deb
dpkg -i tsi-libwebsockets-1.0.19.deb
#AN: we need to call tsiinstall here
tsiinstall
chmod 777 ./TSI40V1.NEW
dest="/root/TSIRUN/INSTALL"
file="./firmware_installer.zip"
if [ -f "$file" ]
then
	cp "$file" "$dest"
fi
dest="/root"
file="./TSI40V1.NEW"
if [ -f "$file" ]
then
	cp "$file" "$dest"
fi
dest="/root/TSISYS"
file="./TSIARG.TXT"
if [ -f "$file" ]
then
	cp "$file" "$dest"
fi
file="./UIPPGM.BIN"
if [ -f "$file" ]
then
	cp "$file" "$dest"
fi
file="./ACOPGM.BIN"
if [ -f "$file" ]
then
	cp "$file" "$dest"
fi
dest="/usr/sbin"
file="./fancontrol"
if [ -f "$file" ]
then
	cp "$file" "$dest"
	chmod 777 "$dest"/"$file"
fi
file="./fancontrol_3"
if [ -f "$file" ]
then
	cp "$file" "$dest"
	chmod 777 "$dest"/"$file"
fi
dest="/etc"
sfile="./etc_fancontrol"
dfile="./fancontrol"
if [ -f "$file" ]
then
	cp "$sfile" "$dest"/"$dfile"
	chmod 777 "$dest"/"$dfile"
fi
tsiinstall
/root/TSIBASH/tsisysinfo -i