#!/bin/bash

# Please put this setup script to tpe02:/srv/www/htdocs/OneKeyInstall/setup4njn/setup.sh
# Usage: bash <(curl -s http://onekeyinstall.truetel.com/setup4njn/setup.sh)

unzipFolder=~/tassetup

echo "Download setup script..."
# Download setup script and unzip
if [ ! -d ${unzipFolder} ]; then
	mkdir -p ${unzipFolder}
fi
cd $unzipFolder
curl -Os http://onekeyinstall.truetel.com/setup4njn/tasdev.tar.gz
tar zxf tasdev.tar.gz

# Log setting
LOG_LOC="${unzipFolder}/logs"
if [ ! -d ${LOG_LOC} ]; then
	mkdir -p ${LOG_LOC}
fi
logName="$(date "+%Y%m%d-%H%M%S").log"
logFilePath="${LOG_LOC}/${logName}"
touch "${logFilePath}"

# Execute script
#echo "Setup environment... Maybe need password."
cd ./tasdev
. setup.sh | tee -a ${logFilePath}