tserverSetup.sh 3.24 KB
#!/bin/bash
#安装 javajdk
rpm -q java-1.8.0-openjdk-devel
if [ $? -eq 0 ];then
	echo "[`date`] [DEBUG] tserverSetup.sh java-1.8.0-openjdk-devel already exist." >> ${ucswitchSetupLogFile}	
else
	yum install -y java-1.8.0-openjdk-devel
	if [ $? -eq 0 ];then
		echo "[`date`] [DEBUG] tserverSetup.sh install java-1.8.0-openjdk-devel success." >> ${ucswitchSetupLogFile}	
	else
		echo "[`date`] [DEBUG] tserverSetup.sh Failed to java-1.8.0-openjdk-devel." >> ${ucswitchSetupLogFile}	
		exit 1
	fi
fi
#下载tserver 源码
cd ${autoDirectory}
wget $jarUrl
if [ $? -eq 0 ];then
	echo "[`date`] [DEBUG] tserverSetup.sh down ${jarName} success." >> ${ucswitchSetupLogFile}	
else
	echo "[`date`] [DEBUG] tserverSetup.sh Failed to down ${jarName}." >> ${ucswitchSetupLogFile}	
fi

tar -xzvf ${jarUrl##*/} -C "/opt/"
if [ $? -eq 0 ];then
	echo "[`date`] [DEBUG] tserverSetup.sh tar -xzvf ${jarName} success." >> ${ucswitchSetupLogFile}	
else
	echo "[`date`] [DEBUG] tserverSetup.sh Failed to tar -xzvf  ${jarName}." >> ${ucswitchSetupLogFile}	
fi
#做成服务
if [ -f "/etc/init.d/cti-tserver" ]; then
  	rm -f "/etc/init.d/cti-tserver"
fi
ln -s "${jarPath}/${jarName}" "/etc/init.d/cti-tserver"
chkconfig --add cti-tserver 
chkconfig --level 35 cti-tserver  on
#修改配置
sed -i "s%jingle.cc.activemq.url=.*%jingle.cc.activemq.url=$jarQueueUrl%g" /opt/cti/properties/cti-tserver.properties 
if [ $? -eq 0 ];then
        echo "[`date`] [DEBUG] tserverSetup.sh config queue success" >> ${ucswitchSetupLogFile}
else
        echo "[`date`] [ERROR] tserverSetup.sh Failed to config queue" >> ${ucswitchSetupLogFile}
        exit 1
fi
sed -i "s%freeswitch.ip=.*%freeswitch.ip=$jarFsIp%g" /opt/cti/properties/cti-tserver.properties
if [ $? -eq 0 ];then
        echo "[`date`] [DEBUG] tserverSetup.sh config freeswitch ip success" >> ${ucswitchSetupLogFile}
else
        echo "[`date`] [ERROR] tserverSetup.sh Failed to config freeswitch ip" >> ${ucswitchSetupLogFile}
        exit 1
fi
sed -i "s%jingle.cc.fs.consumer=.*%jingle.cc.fs.consumer=$jarFsConsumer%g" /opt/cti/properties/cti-tserver.properties
if [ $? -eq 0 ];then
        echo "[`date`] [DEBUG] tserverSetup.sh config fsConsumer success" >> ${ucswitchSetupLogFile}
else
        echo "[`date`] [ERROR] tserverSetup.sh Failed to conig fsConsumer" >> ${ucswitchSetupLogFile}
        exit 1
fi
sed -i "s%spring.datasource.url=.*%spring.datasource.url=$jarDbUrl%g" /opt/cti/properties/cti-tserver.properties
if [ $? -eq 0 ];then
        echo "[`date`] [DEBUG] tserverSetup.sh config database url" >> ${ucswitchSetupLogFile}
else
        echo "[`date`] [ERROR] tserverSetup.sh Failed to config database url" >> ${ucswitchSetupLogFile}
        exit 1
fi
sed -i "s%spring.redis.host=.*%spring.redis.host=$jarRedisHost%g" /opt/cti/properties/cti-tserver.properties
if [ $? -eq 0 ];then
        echo "[`date`] [DEBUG] tserverSetup.sh config redisHost success" >> ${ucswitchSetupLogFile}
else
        echo "[`date`] [ERROR] tserverSetup.sh Failed to config redisHost" >> ${ucswitchSetupLogFile}
        exit 1
fi
/etc/init.d/cti-tserver start
if [ $? -eq 0 ];then
        echo "[`date`] [DEBUG] tserverSetup.sh tserver start success" >> ${ucswitchSetupLogFile}
else
        echo "[`date`] [ERROR] tserverSetup.sh Failed to tserver start" >> ${ucswitchSetupLogFile}
        exit 1
fi