## Gotty 环境配置及安装
# installGotty.sh
cmd_exist() {
type $1 >/dev/null 2>&1 && echo 0 || echo 1
}
get_ip() {
ifconfig -a| awk -F':' '{ if(NR==2){ print $2 } }'| cut -d' ' -f1
}
GOPKG="http://xxxx/gotty/go1.7.3.linux-amd64.tar.gz"
GOTTYPKG="http://xxxx/gotty/gotty-master.zip"
INSTALLDIR="/home/dev/install"
test `cmd_exist "unzip"` -eq 0 || sudo yum install -y unzip
test `cmd_exist "tar"` -eq 0 || sudo yum install -y tar
## 创建目录、拷贝文件,安装go语言, 配置go环境变量
mkdir -p $INSTALLDIR/prog
mkdir -p $INSTALLDIR/prog/go_projects/bin
mkdir -p $INSTALLDIR/prog/go_projects/src
mkdir -p $INSTALLDIR/prog/go_projects/pkg
cd $INSTALLDIR/prog
curl -o go1.7.3.linux-amd64.tar.gz $GOPKG
sudo tar -C /usr/local -xvzf go1.7.3.linux-amd64.tar.gz
BASHF=/home/dev/.bash_profile
grep "go\/bin" $BASHF>/dev/null 2>&1 || echo "export PATH=\$PATH:/usr/local/go/bin">>$BASHF
grep "GOROOT" $BASHF>/dev/null 2>&1 || echo "export GOROOT=\"/usr/local/go\"">>$BASHF
grep "GOPATH" $BASHF>/dev/null 2>&1 || echo "export GOPATH=\"\$HOME/install/prog/go_projects\"">>$BASHF
grep "GOBIN" $BASHF>/dev/null 2>&1 || echo "export GOBIN=\"\$GOPATH/bin\"">>$BASHF
source /home/dev/.bash_profile
rm -rf go1.7.3.linux-amd64.tar.gz
## 安装、启动gotty
## go get github.com/yudai/gotty
mkdir -p $INSTALLDIR/prog/go_projects/src/
cd /home/dev/
#nohup $GOPATH/bin/gotty -p "8018" -w bash &
echo "[INFO]: Gotty service has been installed."