diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index c029b1871a..337407f8d2 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -57,9 +57,9 @@ else arch=$cpuType fi -echo "${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r ${arch} -e taoskeeper" +echo "${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r ${arch} -e taoskeeper -t ver-${tdengine_ver}" echo "$top_dir=${top_dir}" -taoskeeper_binary=`${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r $arch -e taoskeeper` +taoskeeper_binary=`${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r $arch -e taoskeeper -t ver-${tdengine_ver}` echo "taoskeeper_binary: ${taoskeeper_binary}" # copy config files @@ -76,6 +76,13 @@ if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then cp ${compile_dir}/test/cfg/taosadapter.service ${pkg_dir}${install_home_path}/cfg || : fi +if [ -f "%{_compiledir}/../../../explorer/target/taos-explorer.service" ]; then + cp %{_compiledir}/../../../explorer/target/taos-explorer.service ${pkg_dir}${install_home_path}/cfg || : +fi +if [ -f "%{_compiledir}/../../../explorer/server/example/explorer.toml" ]; then + cp %{_compiledir}/../../../explorer/server/example/explorer.toml ${pkg_dir}${install_home_path}/cfg || : +fi + cp ${taoskeeper_binary} ${pkg_dir}${install_home_path}/bin #cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script @@ -93,6 +100,10 @@ if [ -f "${compile_dir}/build/bin/taosadapter" ]; then cp ${compile_dir}/build/bin/taosadapter ${pkg_dir}${install_home_path}/bin ||: fi +if [ -f "${compile_dir}/../../../explorer/target/release/taos-explorer" ]; then + cp ${compile_dir}/../../../explorer/target/release/taos-explorer ${pkg_dir}${install_home_path}/bin ||: +fi + cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver [ -f ${compile_dir}/build/lib/${wslibfile} ] && cp ${compile_dir}/build/lib/${wslibfile} ${pkg_dir}${install_home_path}/driver ||: diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index b846cd447b..6b324486b2 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -72,6 +72,14 @@ if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper.service ]; then cp %{_compiledir}/../build-taoskeeper/taoskeeper.service %{buildroot}%{homepath}/cfg ||: fi +if [ -f %{_compiledir}/../../../explorer/target/taos-explorer.service ]; then + cp %{_compiledir}/../../../explorer/target/taos-explorer.service %{buildroot}%{homepath}/cfg ||: +fi + +if [ -f %{_compiledir}/../../../explorer/server/example/explorer.toml ]; then + cp %{_compiledir}/../../../explorer/server/example/explorer.toml %{buildroot}%{homepath}/cfg ||: +fi + #cp %{_compiledir}/../packaging/rpm/taosd %{buildroot}%{homepath}/init.d cp %{_compiledir}/../packaging/tools/post.sh %{buildroot}%{homepath}/script cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/script @@ -84,6 +92,10 @@ cp %{_compiledir}/build/bin/udfd %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin +if [ -f %{_compiledir}/../../../explorer/target/release/taos-explorer ]; then + cp %{_compiledir}/../../../explorer/target/release/taos-explorer %{buildroot}%{homepath}/bin +fi + if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper ]; then cp %{_compiledir}/../build-taoskeeper/taoskeeper %{buildroot}%{homepath}/bin fi diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index ae774a3289..16c95aa2d3 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -16,49 +16,27 @@ serverFqdn="" script_dir=$(dirname $(readlink -f "$0")) # Dynamic directory -clientName="taos" -serverName="taosd" +PREFIX="taos" +clientName="${PREFIX}" +serverName="${PREFIX}d" udfdName="udfd" -configFile="taos.cfg" +configFile="${PREFIX}.cfg" productName="TDengine" emailName="taosdata.com" -uninstallScript="rmtaos" -historyFile="taos_history" +uninstallScript="rm${PREFIX}" +historyFile="${PREFIX}_history" tarName="package.tar.gz" -dataDir="/var/lib/taos" -logDir="/var/log/taos" -configDir="/etc/taos" -installDir="/usr/local/taos" -adapterName="taosadapter" -benchmarkName="taosBenchmark" -dumpName="taosdump" -demoName="taosdemo" -xname="taosx" -keeperName="taoskeeper" - -clientName2="taos" -serverName2="${clientName2}d" -configFile2="${clientName2}.cfg" -productName2="TDengine" -emailName2="taosdata.com" -xname2="${clientName2}x" -adapterName2="${clientName2}adapter" -keeperName2="${clientName2}keeper" - -explorerName="${clientName2}-explorer" -benchmarkName2="${clientName2}Benchmark" -demoName2="${clientName2}demo" -dumpName2="${clientName2}dump" -uninstallScript2="rm${clientName2}" - -historyFile="${clientName2}_history" -logDir="/var/log/${clientName2}" -configDir="/etc/${clientName2}" -installDir="/usr/local/${clientName2}" - -data_dir=${dataDir} -log_dir=${logDir} -cfg_install_dir=${configDir} +dataDir="/var/lib/${PREFIX}" +logDir="/var/log/${PREFIX}" +configDir="/etc/${PREFIX}" +installDir="/usr/local/${PREFIX}" +adapterName="${PREFIX}adapter" +benchmarkName="${PREFIX}Benchmark" +dumpName="${PREFIX}dump" +demoName="${PREFIX}demo" +xname="${PREFIX}x" +explorerName="${PREFIX}-explorer" +keeperName="${PREFIX}keeper" bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" @@ -71,7 +49,6 @@ install_main_dir=${installDir} bin_dir="${installDir}/bin" service_config_dir="/etc/systemd/system" -web_port=6041 # Color setting RED='\033[0;31m' @@ -179,6 +156,26 @@ done #echo "verType=${verType} interactiveFqdn=${interactiveFqdn}" +tools=(${clientName} ${benchmarkName} ${dumpName} ${demoName} remove.sh udfd set_core.sh TDinsight.sh start_pre.sh) +if [ "${verMode}" == "cluster" ]; then + services=(${serverName} ${adapterName} ${xname} ${explorerName} ${keeperName}) +elif [ "${verMode}" == "community" ]; then + if [ "${pagMode}" == "full" ]; then + services=(${serverName} ${adapterName} ${keeperName} ${explorerName}) + else + services=(${serverName}) + tools=(${clientName} ${benchmarkName} remove.sh start_pre.sh) + fi +else + services=(${serverName} ${adapterName} ${xname} ${explorerName} ${keeperName}) +fi + +function install_services() { + for service in "${services[@]}"; do + install_service ${service} + done +} + function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then @@ -196,6 +193,7 @@ function install_main_path() { ${csudo}mkdir -p ${install_main_dir}/driver ${csudo}mkdir -p ${install_main_dir}/examples ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${configDir} # ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then ${csudo}mkdir -p ${install_main_dir}/share @@ -208,44 +206,44 @@ function install_main_path() { function install_bin() { # Remove links - ${csudo}rm -f ${bin_link_dir}/${clientName2} || : - ${csudo}rm -f ${bin_link_dir}/${serverName2} || : - ${csudo}rm -f ${bin_link_dir}/${udfdName} || : - ${csudo}rm -f ${bin_link_dir}/${adapterName} || : - ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : - ${csudo}rm -f ${bin_link_dir}/${demoName2} || : - ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : - ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : - ${csudo}rm -f ${bin_link_dir}/${keeperName2} || : - ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : + for tool in "${tools[@]}"; do + ${csudo}rm -f ${bin_link_dir}/${tool} || : + done - ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* + for service in "${services[@]}"; do + ${csudo}rm -f ${bin_link_dir}/${service} || : + done + + if [ "${verType}" == "client" ]; then + ${csudo}cp -r ${script_dir}/bin/${clientName} ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/bin/${benchmarkName} ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/bin/${dumpName} ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/bin/remove.sh ${install_main_dir}/bin + else + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin + fi + + if [[ "${verMode}" == "cluster" && "${verType}" != "client" ]]; then + if [ -d ${script_dir}/${xname}/bin ]; then + ${csudo}cp -r ${script_dir}/${xname}/bin/* ${install_main_dir}/bin + fi + fi + + ${csudo}chmod 0555 ${install_main_dir}/bin/* + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}mv ${install_main_dir}/bin/remove.sh ${install_main_dir}/uninstall.sh || : #Make link - [ -x ${install_main_dir}/bin/${clientName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${clientName2} ${bin_link_dir}/${clientName2} || : - [ -x ${install_main_dir}/bin/${serverName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${serverName2} ${bin_link_dir}/${serverName2} || : - [ -x ${install_main_dir}/bin/${udfdName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${udfdName} ${bin_link_dir}/${udfdName} || : - [ -x ${install_main_dir}/bin/${adapterName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${adapterName2} ${bin_link_dir}/${adapterName2} || : - [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${demoName2} || : - [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${benchmarkName2} || : - [ -x ${install_main_dir}/bin/${dumpName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${dumpName2} ${bin_link_dir}/${dumpName2} || : - [ -x ${install_main_dir}/bin/${keeperName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${keeperName2} ${bin_link_dir}/${keeperName2} || : - [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -sf ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : - if [ "$clientName2" == "${clientName}" ]; then - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : - fi - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + for tool in "${tools[@]}"; do + if [ "${tool}" == "remove.sh" ]; then + [ -x ${install_main_dir}/uninstall.sh ] && ${csudo}ln -sf ${install_main_dir}/uninstall.sh ${bin_link_dir}/${uninstallScript} || : + else + [ -x ${install_main_dir}/bin/${tool} ] && ${csudo}ln -sf ${install_main_dir}/bin/${tool} ${bin_link_dir}/${tool} || : + fi + done - if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then - ${csudo}rm -f ${bin_link_dir}/${xname2} || : - ${csudo}rm -f ${bin_link_dir}/${explorerName} || : - - #Make link - [ -x ${install_main_dir}/bin/${xname2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${xname2} ${bin_link_dir}/${xname2} || : - [ -x ${install_main_dir}/bin/${explorerName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${explorerName} ${bin_link_dir}/${explorerName} || : - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || : - fi + for service in "${services[@]}"; do + [ -x ${install_main_dir}/bin/${service} ] && ${csudo}ln -sf ${install_main_dir}/bin/${service} ${bin_link_dir}/${service} || : + done } function install_lib() { @@ -356,7 +354,7 @@ function install_header() { ${csudo}ln -sf ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -sf ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h ${csudo}ln -sf ${install_main_dir}/include/tdef.h ${inc_link_dir}/tdef.h - ${csudo}ln -sf ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h + ${csudo}ln -sf ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h [ -f ${install_main_dir}/include/taosws.h ] && ${csudo}ln -sf ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || : } @@ -415,10 +413,10 @@ function set_hostname() { # ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network || : # fi - if [ -f ${cfg_install_dir}/${configFile2} ]; then - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/${configFile2} + if [ -f ${configDir}/${configFile} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${configDir}/${configFile} else - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${script_dir}/cfg/${configFile2} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${script_dir}/cfg/${configFile} fi serverFqdn=$newHostname @@ -453,11 +451,11 @@ function set_ipAsFqdn() { echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}" localFqdn="127.0.0.1" # Write the local FQDN to configuration file - - if [ -f ${cfg_install_dir}/${configFile2} ]; then - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile2} + + if [ -f ${configDir}/${configFile} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${configDir}/${configFile} else - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${script_dir}/cfg/${configFile2} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${script_dir}/cfg/${configFile} fi serverFqdn=$localFqdn echo @@ -479,11 +477,11 @@ function set_ipAsFqdn() { if [[ $retval != 0 ]]; then read -p "Please choose an IP from local IP list:" localFqdn else - # Write the local FQDN to configuration file - if [ -f ${cfg_install_dir}/${configFile2} ]; then - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile2} + # Write the local FQDN to configuration file + if [ -f ${configDir}/${configFile} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${configDir}/${configFile} else - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${script_dir}/cfg/${configFile2} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${script_dir}/cfg/${configFile} fi serverFqdn=$localFqdn break @@ -499,91 +497,120 @@ function local_fqdn_check() { echo echo -e -n "System hostname is: ${GREEN}$serverFqdn${NC}" echo - set_hostname + set_hostname +} + +function install_taosx_config() { + [ ! -z $1 ] && return 0 || : # only install client + + fileName="${script_dir}/${xname}/etc/taos/${xname}.toml" + if [ -f ${fileName} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*=\s*).*/\1\"${serverFqdn}\"/" ${fileName} + + if [ -f "${configDir}/${xname}.toml" ]; then + ${csudo}cp ${fileName} ${configDir}/${xname}.toml.new + else + ${csudo}cp ${fileName} ${configDir}/${xname}.toml + fi + fi +} + + +function install_explorer_config() { + [ ! -z $1 ] && return 0 || : # only install client + + if [ "$verMode" == "cluster" ]; then + fileName="${script_dir}/${xname}/etc/taos/explorer.toml" + else + fileName="${script_dir}/cfg/explorer.toml" + } + if [ -f ${fileName} ]; then + ${csudo}sed -i "s/localhost/${serverFqdn}/g" ${fileName} + + if [ -f "${configDir}/explorer.toml" ]; then + ${csudo}cp ${fileName} ${configDir}/explorer.toml.new + else + ${csudo}cp ${fileName} ${configDir}/explorer.toml + fi + fi } function install_adapter_config() { - if [ -f ${script_dir}/cfg/${adapterName}.toml ]; then - ${csudo}sed -i -r "s/localhost/${serverFqdn}/g" ${script_dir}/cfg/${adapterName}.toml - fi - if [ ! -f "${cfg_install_dir}/${adapterName}.toml" ]; then - ${csudo}mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/${adapterName}.toml ] && ${csudo}cp ${script_dir}/cfg/${adapterName}.toml ${cfg_install_dir} - [ -f ${cfg_install_dir}/${adapterName}.toml ] && ${csudo}chmod 644 ${cfg_install_dir}/${adapterName}.toml - else - [ -f ${script_dir}/cfg/${adapterName}.toml ] && - ${csudo}cp -f ${script_dir}/cfg/${adapterName}.toml ${cfg_install_dir}/${adapterName}.toml.new - fi - - [ -f ${cfg_install_dir}/${adapterName}.toml ] && - ${csudo}ln -sf ${cfg_install_dir}/${adapterName}.toml ${install_main_dir}/cfg/${adapterName}.toml - [ ! -z $1 ] && return 0 || : # only install client + fileName="${script_dir}/cfg/${adapterName}.toml" + if [ -f ${fileName} ]; then + ${csudo}sed -i -r "s/localhost/${serverFqdn}/g" ${fileName} + + if [ -f "${configDir}/${adapterName}.toml" ]; then + ${csudo}cp ${fileName} ${configDir}/${adapterName}.toml.new + else + ${csudo}cp ${fileName} ${configDir}/${adapterName}.toml + fi + fi } function install_keeper_config() { - if [ -f ${script_dir}/cfg/${keeperName2}.toml ]; then - ${csudo}sed -i -r "s/127.0.0.1/${serverFqdn}/g" ${script_dir}/cfg/${keeperName2}.toml - fi - if [ -f "${configDir}/keeper.toml" ]; then - echo "The file keeper.toml will be renamed to ${keeperName2}.toml" - ${csudo}cp ${script_dir}/cfg/${keeperName2}.toml ${configDir}/${keeperName2}.toml.new - ${csudo}mv ${configDir}/keeper.toml ${configDir}/${keeperName2}.toml - elif [ -f "${configDir}/${keeperName2}.toml" ]; then - # "taoskeeper.toml exists,new config is taoskeeper.toml.new" - ${csudo}cp ${script_dir}/cfg/${keeperName2}.toml ${configDir}/${keeperName2}.toml.new - else - ${csudo}cp ${script_dir}/cfg/${keeperName2}.toml ${configDir}/${keeperName2}.toml - fi - command -v systemctl >/dev/null 2>&1 && ${csudo}systemctl daemon-reload >/dev/null 2>&1 || true -} - -function install_config() { - - if [ ! -f "${cfg_install_dir}/${configFile2}" ]; then - ${csudo}mkdir -p ${cfg_install_dir} - if [ -f ${script_dir}/cfg/${configFile2} ]; then - ${csudo} echo "monitor 1" >> ${script_dir}/cfg/${configFile2} - ${csudo} echo "monitorFQDN ${serverFqdn}" >> ${script_dir}/cfg/${configFile2} - ${csudo} echo "audit 1" >> ${script_dir}/cfg/${configFile2} - ${csudo}cp ${script_dir}/cfg/${configFile2} ${cfg_install_dir} - fi - ${csudo}chmod 644 ${cfg_install_dir}/* - else - ${csudo} echo "monitor 1" >> ${script_dir}/cfg/${configFile2} - ${csudo} echo "monitorFQDN ${serverFqdn}" >> ${script_dir}/cfg/${configFile2} - ${csudo} echo "audit 1" >> ${script_dir}/cfg/${configFile2} - ${csudo}cp -f ${script_dir}/cfg/${configFile2} ${cfg_install_dir}/${configFile2}.new - fi - - ${csudo}ln -sf ${cfg_install_dir}/${configFile2} ${install_main_dir}/cfg - [ ! -z $1 ] && return 0 || : # only install client + fileName="${script_dir}/cfg/${keeperName}.toml" + if [ -f ${fileName} ]; then + ${csudo}sed -i -r "s/127.0.0.1/${serverFqdn}/g" ${fileName} + + if [ -f "${configDir}/${keeperName}.toml" ]; then + ${csudo}cp ${fileName} ${configDir}/${keeperName}.toml.new + else + ${csudo}cp ${fileName} ${configDir}/${keeperName}.toml + fi + fi +} + +function install_taosd_config() { + fileName="${script_dir}/cfg/${configFile}" + if [ -f ${fileName} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$serverFqdn/" ${script_dir}/cfg/${configFile} + ${csudo}echo "monitor 1" >>${script_dir}/cfg/${configFile} + ${csudo}echo "monitorFQDN ${serverFqdn}" >>${script_dir}/cfg/${configFile} + ${csudo}echo "audit 1" >>${script_dir}/cfg/${configFile} + + if [ -f "${configDir}/${configFile}" ]; then + ${csudo}cp ${fileName} ${configDir}/${configFile}.new + else + ${csudo}cp ${fileName} ${configDir}/${configFile} + fi + fi + + ${csudo}ln -sf ${configDir}/${configFile} ${install_main_dir}/cfg +} +function install_config() { + + [ ! -z $1 ] && return 0 || : # only install client + if ((${update_flag} == 1)); then return 0 fi if [ "$interactiveFqdn" == "no" ]; then + install_taosd_config return 0 fi local_fqdn_check + install_taosd_config echo - echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName2}:6030) of an existing ${productName2} cluster node to join${NC}" + echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName}:6030) of an existing ${productName} cluster node to join${NC}" echo echo -e -n "${GREEN}OR leave it blank to build one${NC}:" read firstEp while true; do if [ ! -z "$firstEp" ]; then - if [ -f ${cfg_install_dir}/${configFile2} ]; then - ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/${configFile2} + if [ -f ${configDir}/${configFile} ]; then + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${configDir}/${configFile} else - ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${script_dir}/cfg/${configFile2} + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${script_dir}/cfg/${configFile} fi break else @@ -605,37 +632,21 @@ function install_config() { done } -function install_share_etc() { - [ ! -d ${script_dir}/share/etc ] && return - for c in `ls ${script_dir}/share/etc/`; do - if [ -e /etc/${clientName2}/$c ]; then - out=/etc/${clientName2}/$c.new.`date +%F` - ${csudo}cp -f ${script_dir}/share/etc/$c $out ||: - else - ${csudo}mkdir -p /etc/${clientName2} >/dev/null 2>/dev/null ||: - ${csudo}cp -f ${script_dir}/share/etc/$c /etc/${clientName2}/$c ||: - fi - done +function install_log() { + ${csudo}mkdir -p ${logDir} && ${csudo}chmod 777 ${logDir} - [ ! -d ${script_dir}/share/srv ] && return - ${csudo} cp ${script_dir}/share/srv/* ${service_config_dir} ||: -} - -function install_log() { - ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - - ${csudo}ln -sf ${log_dir} ${install_main_dir}/log + ${csudo}ln -sf ${logDir} ${install_main_dir}/log } function install_data() { - ${csudo}mkdir -p ${data_dir} + ${csudo}mkdir -p ${dataDir} - ${csudo}ln -sf ${data_dir} ${install_main_dir}/data + ${csudo}ln -sf ${dataDir} ${install_main_dir}/data } function install_connector() { if [ -d "${script_dir}/connector/" ]; then - ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ || echo "failed to copy connector" + ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ || echo "failed to copy connector" ${csudo}cp ${script_dir}/start-all.sh ${install_main_dir}/ || echo "failed to copy start-all.sh" ${csudo}cp ${script_dir}/stop-all.sh ${install_main_dir}/ || echo "failed to copy stop-all.sh" ${csudo}cp ${script_dir}/README.md ${install_main_dir}/ || echo "failed to copy README.md" @@ -648,55 +659,32 @@ function install_examples() { fi } -function install_web() { - if [ -d "${script_dir}/share" ]; then - ${csudo}cp -rf ${script_dir}/share/* ${install_main_dir}/share > /dev/null 2>&1 ||: - fi -} - -function install_taosx() { - if [ -f "${script_dir}/taosx/install_taosx.sh" ]; then - cd ${script_dir}/taosx - chmod a+x install_taosx.sh - bash install_taosx.sh -e $serverFqdn +function install_plugins() { + if [ -d ${script_dir}/${xname}/plugins ]; then + ${csudo}cp -rf ${script_dir}/${xname}/plugins/ ${install_main_dir}/ || echo "failed to copy taosx plugins" fi } function clean_service_on_sysvinit() { - if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then - ${csudo}service ${serverName2} stop || : - fi - - if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then - ${csudo}service tarbitratord stop || : + if ps aux | grep -v grep | grep $1 &>/dev/null; then + ${csudo}service $1 stop || : fi if ((${initd_mod} == 1)); then - if [ -e ${service_config_dir}/${serverName2} ]; then - ${csudo}chkconfig --del ${serverName2} || : - fi - - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}chkconfig --del tarbitratord || : + if [ -e ${service_config_dir}/$1 ]; then + ${csudo}chkconfig --del $1 || : fi elif ((${initd_mod} == 2)); then - if [ -e ${service_config_dir}/${serverName2} ]; then - ${csudo}insserv -r ${serverName2} || : - fi - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}insserv -r tarbitratord || : + if [ -e ${service_config_dir}/$1 ]; then + ${csudo}insserv -r $1 || : fi elif ((${initd_mod} == 3)); then - if [ -e ${service_config_dir}/${serverName2} ]; then - ${csudo}update-rc.d -f ${serverName2} remove || : - fi - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}update-rc.d -f tarbitratord remove || : + if [ -e ${service_config_dir}/$1 ]; then + ${csudo}update-rc.d -f $1 remove || : fi fi - ${csudo}rm -f ${service_config_dir}/${serverName2} || : - ${csudo}rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/$1 || : if $(which init &>/dev/null); then ${csudo}init q || : @@ -704,96 +692,68 @@ function clean_service_on_sysvinit() { } function install_service_on_sysvinit() { - clean_service_on_sysvinit + if [ "$1" != "${serverName}" ]; then + return + fi + + clean_service_on_sysvinit $1 sleep 1 if ((${os_type} == 1)); then - # ${csudo}cp -f ${script_dir}/init.d/${serverName}.deb ${install_main_dir}/init.d/${serverName} ${csudo}cp ${script_dir}/init.d/${serverName}.deb ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName} elif ((${os_type} == 2)); then - # ${csudo}cp -f ${script_dir}/init.d/${serverName}.rpm ${install_main_dir}/init.d/${serverName} ${csudo}cp ${script_dir}/init.d/${serverName}.rpm ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName} fi if ((${initd_mod} == 1)); then - ${csudo}chkconfig --add ${serverName2} || : - ${csudo}chkconfig --level 2345 ${serverName2} on || : + ${csudo}chkconfig --add $1 || : + ${csudo}chkconfig --level 2345 $1 on || : elif ((${initd_mod} == 2)); then - ${csudo}insserv ${serverName2} || : - ${csudo}insserv -d ${serverName2} || : + ${csudo}insserv $1} || : + ${csudo}insserv -d $1 || : elif ((${initd_mod} == 3)); then - ${csudo}update-rc.d ${serverName2} defaults || : + ${csudo}update-rc.d $1 defaults || : fi } function clean_service_on_systemd() { - service_config="${service_config_dir}/${serverName2}.service" - if systemctl is-active --quiet ${serverName2}; then - echo "${productName} is running, stopping it..." - ${csudo}systemctl stop ${serverName2} &>/dev/null || echo &>/dev/null - fi - ${csudo}systemctl disable ${serverName2} &>/dev/null || echo &>/dev/null - ${csudo}rm -f ${service_config} + service_config="${service_config_dir}/$1.service" - tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - if systemctl is-active --quiet tarbitratord; then - echo "tarbitrator is running, stopping it..." - ${csudo}systemctl stop tarbitratord &>/dev/null || echo &>/dev/null + if systemctl is-active --quiet $1; then + echo "$1 is running, stopping it..." + ${csudo}systemctl stop $1 &>/dev/null || echo &>/dev/null fi - ${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null - ${csudo}rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable $1 &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${service_config} } function install_service_on_systemd() { - clean_service_on_systemd + clean_service_on_systemd $1 - install_share_etc - - [ -f ${script_dir}/cfg/${serverName2}.service ] && - ${csudo}cp ${script_dir}/cfg/${serverName2}.service \ - ${service_config_dir}/ || : - - # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then - # [ -f ${script_dir}/cfg/${serverName2}.service ] && - # ${csudo}cp ${script_dir}/cfg/${serverName2}.service \ - # ${service_config_dir}/${serverName2}.service || : - # fi - - ${csudo}systemctl daemon-reload - - ${csudo}systemctl enable ${serverName2} - ${csudo}systemctl daemon-reload -} - -function install_adapter_service() { - if ((${service_mod} == 0)); then - [ -f ${script_dir}/cfg/${adapterName2}.service ] && - ${csudo}cp ${script_dir}/cfg/${adapterName2}.service \ - ${service_config_dir}/ || : - - ${csudo}systemctl enable ${adapterName2} - ${csudo}systemctl daemon-reload + cfg_source_dir=${script_dir}/cfg + if [[ "$1" == "${xname}" || "$1" == "${explorerName}" ]]; then + if [ "$verMode" == "cluster" ]; then + cfg_source_dir=${script_dir}/${xname}/etc/systemd/system + else + cfg_source_dir=${script_dir}/cfg + fi fi -} -function install_keeper_service() { - if ((${service_mod} == 0)); then - [ -f ${script_dir}/cfg/${clientName2}keeper.service ] && - ${csudo}cp ${script_dir}/cfg/${clientName2}keeper.service \ - ${service_config_dir}/ || : - - ${csudo}systemctl enable ${clientName2}keeper - ${csudo}systemctl daemon-reload + if [ -f ${cfg_source_dir}/$1.service ]; then + ${csudo}cp ${cfg_source_dir}/$1.service ${service_config_dir}/ || : fi + + ${csudo}systemctl enable $1 + ${csudo}systemctl daemon-reload } function install_service() { if ((${service_mod} == 0)); then - install_service_on_systemd + install_service_on_systemd $1 elif ((${service_mod} == 1)); then - install_service_on_sysvinit + install_service_on_sysvinit $1 else - kill_process ${serverName2} + kill_process $1 fi } @@ -830,10 +790,10 @@ function is_version_compatible() { if [ -f ${script_dir}/driver/vercomp.txt ]; then min_compatible_version=$(cat ${script_dir}/driver/vercomp.txt) else - min_compatible_version=$(${script_dir}/bin/${serverName2} -V | head -1 | cut -d ' ' -f 5) + min_compatible_version=$(${script_dir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 5) fi - exist_version=$(${installDir}/bin/${serverName2} -V | head -1 | cut -d ' ' -f 3) + exist_version=$(${installDir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 3) vercomp $exist_version "3.0.0.0" case $? in 2) @@ -857,7 +817,7 @@ deb_erase() { echo -e -n "${RED}Existing TDengine deb is detected, do you want to remove it? [yes|no] ${NC}:" read confirm if [ "yes" == "$confirm" ]; then - ${csudo}dpkg --remove tdengine ||: + ${csudo}dpkg --remove tdengine || : break elif [ "no" == "$confirm" ]; then break @@ -871,7 +831,7 @@ rpm_erase() { echo -e -n "${RED}Existing TDengine rpm is detected, do you want to remove it? [yes|no] ${NC}:" read confirm if [ "yes" == "$confirm" ]; then - ${csudo}rpm -e tdengine ||: + ${csudo}rpm -e tdengine || : break elif [ "no" == "$confirm" ]; then break @@ -893,23 +853,23 @@ function updateProduct() { fi if echo $osinfo | grep -qwi "centos"; then - rpm -q tdengine 2>&1 > /dev/null && rpm_erase tdengine ||: + rpm -q tdengine 2>&1 >/dev/null && rpm_erase tdengine || : elif echo $osinfo | grep -qwi "ubuntu"; then - dpkg -l tdengine 2>&1 | grep ii > /dev/null && deb_erase tdengine ||: + dpkg -l tdengine 2>&1 | grep ii >/dev/null && deb_erase tdengine || : fi tar -zxf ${tarName} install_jemalloc - echo "Start to update ${productName2}..." + echo "Start to update ${productName}..." # Stop the service if running - if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then + if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then if ((${service_mod} == 0)); then - ${csudo}systemctl stop ${serverName2} || : + ${csudo}systemctl stop ${serverName} || : elif ((${service_mod} == 1)); then - ${csudo}service ${serverName2} stop || : + ${csudo}service ${serverName} stop || : else - kill_process ${serverName2} + kill_process ${serverName} fi sleep 1 fi @@ -922,82 +882,73 @@ function updateProduct() { install_config if [ "$verMode" == "cluster" ]; then - install_connector - install_taosx + install_connector + install_plugins fi install_examples - install_web if [ -z $1 ]; then install_bin - install_service - install_adapter_service - install_adapter_config - install_keeper_service - if [ "${verMode}" != "cloud" ]; then - install_keeper_config + install_services + + if [ "${pagMode}" != "lite" ]; then + install_adapter_config + install_taosx_config + install_explorer_config + if [ "${verMode}" != "cloud" ]; then + install_keeper_config + fi fi openresty_work=false echo - echo -e "${GREEN_DARK}To configure ${productName2} ${NC}\t\t: edit ${cfg_install_dir}/${configFile2}" - [ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To configure ${clientName2}Adapter ${NC}\t: edit ${configDir}/${clientName2}adapter.toml" + echo -e "${GREEN_DARK}To configure ${productName} ${NC}\t\t: edit ${configDir}/${configFile}" + [ -f ${configDir}/${adapterName}.toml ] && [ -f ${installDir}/bin/${adapterName} ] && + echo -e "${GREEN_DARK}To configure ${adapterName} ${NC}\t: edit ${configDir}/${adapterName}.toml" if [ "$verMode" == "cluster" ]; then - echo -e "${GREEN_DARK}To configure ${clientName2}-explorer ${NC}\t: edit ${configDir}/explorer.toml" + echo -e "${GREEN_DARK}To configure ${explorerName} ${NC}\t: edit ${configDir}/explorer.toml" fi if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${csudo}systemctl start ${serverName2}${NC}" - [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName2}adapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}systemctl start ${serverName}${NC}" + [ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${csudo}service ${serverName2} start${NC}" - [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}service ${clientName2}adapter start${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}service ${serverName} start${NC}" + [ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}service ${clientName}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ./${serverName2}${NC}" - [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${clientName2}adapter ${NC}" - fi - - echo -e "${GREEN_DARK}To enable ${clientName2}keeper ${NC}\t\t: sudo systemctl enable ${clientName2}keeper ${NC}" - if [ "$verMode" == "cluster" ];then - echo -e "${GREEN_DARK}To start ${clientName2}x ${NC}\t\t\t: sudo systemctl start ${clientName2}x ${NC}" - echo -e "${GREEN_DARK}To start ${clientName2}-explorer ${NC}\t\t: sudo systemctl start ${clientName2}-explorer ${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ./${serverName}${NC}" + [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${clientName}adapter ${NC}" fi - # if [ ${openresty_work} = 'true' ]; then - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}" - # else - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell${NC}" - # fi - - # if ((${prompt_force} == 1)); then - # echo "" - # echo -e "${RED}Please run '${serverName2} --force-keep-file' at first time for the exist ${productName2} $exist_version!${NC}" - # fi + echo -e "${GREEN_DARK}To enable ${clientName}keeper ${NC}\t\t: sudo systemctl enable ${clientName}keeper ${NC}" + if [ "$verMode" == "cluster" ]; then + echo -e "${GREEN_DARK}To start ${clientName}x ${NC}\t\t\t: sudo systemctl start ${clientName}x ${NC}" + echo -e "${GREEN_DARK}To start ${clientName}-explorer ${NC}\t\t: sudo systemctl start ${clientName}-explorer ${NC}" + fi echo - echo "${productName2} is updated successfully!" + echo "${productName} is updated successfully!" echo - if [ "$verMode" == "cluster" ];then + if [ "$verMode" == "cluster" ]; then echo -e "\033[44;32;1mTo start all the components : ./start-all.sh${NC}" fi - echo -e "\033[44;32;1mTo access ${productName2} : ${clientName2} -h $serverFqdn${NC}" - if [ "$verMode" == "cluster" ];then + echo -e "\033[44;32;1mTo access ${productName} : ${clientName} -h $serverFqdn${NC}" + if [ "$verMode" == "cluster" ]; then echo -e "\033[44;32;1mTo access the management system : http://$serverFqdn:6060${NC}" echo -e "\033[44;32;1mTo read the user manual : http://$serverFqdn:6060/docs${NC}" fi else - install_bin + install_bin echo - echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}" + echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}" fi cd $script_dir - rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } function installProduct() { @@ -1008,7 +959,7 @@ function installProduct() { fi tar -zxf ${tarName} - echo "Start to install ${productName2}..." + echo "Start to install ${productName}..." install_main_path @@ -1025,105 +976,114 @@ function installProduct() { install_config if [ "$verMode" == "cluster" ]; then - install_connector - install_taosx + install_connector + install_plugins fi - install_examples - install_web + install_examples + if [ -z $1 ]; then # install service and client # For installing new install_bin - install_service - install_adapter_service - install_adapter_config - install_keeper_service - if [ "${verMode}" != "cloud" ]; then - install_keeper_config - fi - openresty_work=false + install_services + if [ "${pagMode}" != "lite" ]; then + install_adapter_config + install_taosx_config + install_explorer_config + if [ "${verMode}" != "cloud" ]; then + install_keeper_config + fi + fi + + openresty_work=false # Ask if to start the service echo - echo -e "${GREEN_DARK}To configure ${productName2} ${NC}\t\t: edit ${cfg_install_dir}/${configFile2}" - [ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To configure ${clientName2}Adapter ${NC}\t: edit ${configDir}/${clientName2}adapter.toml" + echo -e "${GREEN_DARK}To configure ${productName} ${NC}\t\t: edit ${configDir}/${configFile}" + [ -f ${configDir}/${clientName}adapter.toml ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To configure ${clientName}Adapter ${NC}\t: edit ${configDir}/${clientName}adapter.toml" if [ "$verMode" == "cluster" ]; then - echo -e "${GREEN_DARK}To configure ${clientName2}-explorer ${NC}\t: edit ${configDir}/explorer.toml" + echo -e "${GREEN_DARK}To configure ${clientName}-explorer ${NC}\t: edit ${configDir}/explorer.toml" fi if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${csudo}systemctl start ${serverName2}${NC}" - [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName2}adapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}systemctl start ${serverName}${NC}" + [ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${csudo}service ${serverName2} start${NC}" - [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}service ${clientName2}adapter start${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}service ${serverName} start${NC}" + [ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}service ${clientName}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${serverName2}${NC}" - [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${clientName2}adapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${serverName}${NC}" + [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${clientName}adapter ${NC}" fi - echo -e "${GREEN_DARK}To enable ${clientName2}keeper ${NC}\t\t: sudo systemctl enable ${clientName2}keeper ${NC}" - - if [ "$verMode" == "cluster" ];then - echo -e "${GREEN_DARK}To start ${clientName2}x ${NC}\t\t\t: sudo systemctl start ${clientName2}x ${NC}" - echo -e "${GREEN_DARK}To start ${clientName2}-explorer ${NC}\t\t: sudo systemctl start ${clientName2}-explorer ${NC}" + echo -e "${GREEN_DARK}To enable ${clientName}keeper ${NC}\t\t: sudo systemctl enable ${clientName}keeper ${NC}" + + if [ "$verMode" == "cluster" ]; then + echo -e "${GREEN_DARK}To start ${clientName}x ${NC}\t\t\t: sudo systemctl start ${clientName}x ${NC}" + echo -e "${GREEN_DARK}To start ${clientName}-explorer ${NC}\t\t: sudo systemctl start ${clientName}-explorer ${NC}" fi - # if [ ! -z "$firstEp" ]; then - # tmpFqdn=${firstEp%%:*} - # substr=":" - # if [[ $firstEp =~ $substr ]]; then - # tmpPort=${firstEp#*:} - # else - # tmpPort="" - # fi - # if [[ "$tmpPort" != "" ]]; then - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: ${clientName2} -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}" - # else - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: ${clientName2} -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}" - # fi - # echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}" - # echo - # elif [ ! -z "$serverFqdn" ]; then - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: ${clientName2} -h $serverFqdn${GREEN_DARK} to login into ${productName2} server${NC}" - # echo - # fi echo - echo "${productName2} is installed successfully!" + echo "${productName} is installed successfully!" echo - if [ "$verMode" == "cluster" ];then + if [ "$verMode" == "cluster" ]; then echo -e "\033[44;32;1mTo start all the components : sudo ./start-all.sh${NC}" fi - echo -e "\033[44;32;1mTo access ${productName2} : ${clientName2} -h $serverFqdn${NC}" - if [ "$verMode" == "cluster" ];then + echo -e "\033[44;32;1mTo access ${productName} : ${clientName} -h $serverFqdn${NC}" + if [ "$verMode" == "cluster" ]; then echo -e "\033[44;32;1mTo access the management system : http://$serverFqdn:6060${NC}" echo -e "\033[44;32;1mTo read the user manual : http://$serverFqdn:6060/docs-en${NC}" fi echo else # Only install client install_bin - + echo - echo -e "\033[44;32;1m${productName2} client is installed successfully!${NC}" + echo -e "\033[44;32;1m${productName} client is installed successfully!${NC}" fi - + cd $script_dir touch ~/.${historyFile} rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } +check_java_env() { + if ! command -v java &> /dev/null + then + echo -e "\033[31mWarning: Java command not found. Version 1.8+ is required.\033[0m" + return + fi + + java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}') + java_version_ok=false + if [[ $(echo "$java_version" | cut -d"." -f1) -gt 1 ]]; then + java_version_ok=true + elif [[ $(echo "$java_version" | cut -d"." -f1) -eq 1 && $(echo "$java_version" | cut -d"." -f2) -ge 8 ]]; then + java_version_ok=true + fi + + if $java_version_ok; then + echo -e "\033[32mJava ${java_version} has been found.\033[0m" + else + echo -e "\033[31mWarning: Java Version 1.8+ is required, but version ${java_version} has been found.\033[0m" + fi +} + ## ==============================Main program starts from here============================ serverFqdn=$(hostname) if [ "$verType" == "server" ]; then + if [ -x ${script_dir}/${xname}/bin/${xname} ]; then + check_java_env + fi # Check default 2.x data file. - if [ -x ${data_dir}/dnode/dnodeCfg.json ]; then - echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of ${productName2} 2.x, please clear it before installing!\033[0m" + if [ -x ${dataDir}/dnode/dnodeCfg.json ]; then + echo -e "\033[44;31;5mThe default data directory ${dataDir} contains old data of ${productName} 2.x, please clear it before installing!\033[0m" else # Install server and client - if [ -x ${bin_dir}/${serverName2} ]; then + if [ -x ${bin_dir}/${serverName} ]; then update_flag=1 updateProduct else @@ -1133,7 +1093,7 @@ if [ "$verType" == "server" ]; then elif [ "$verType" == "client" ]; then interactiveFqdn=no # Only install client - if [ -x ${bin_dir}/${clientName2} ]; then + if [ -x ${bin_dir}/${clientName} ]; then update_flag=1 updateProduct client else @@ -1142,5 +1102,3 @@ elif [ "$verType" == "client" ]; then else echo "please input correct verType" fi - - diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 4b0faaa958..3744892526 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -231,12 +231,8 @@ fi if [ "$verMode" == "cluster" ]; then sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >>remove_temp.sh - sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" remove_temp.sh - sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" remove_temp.sh - sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" remove_temp.sh - sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" remove_temp.sh - cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'` - sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" remove_temp.sh + sed -i "s/PREFIX=\"taos\"/PREFIX=\"${serverName2}\"/g" remove_temp.sh + sed -i "s/productName=\"TDengine\"/productName=\"${productName2}\"/g" remove_temp.sh mv remove_temp.sh ${install_dir}/bin/remove.sh fi if [ "$verMode" == "cloud" ]; then @@ -262,12 +258,10 @@ cp ${install_files} ${install_dir} cp ${install_dir}/install.sh install_temp.sh if [ "$verMode" == "cluster" ]; then sed -i 's/verMode=edge/verMode=cluster/g' install_temp.sh - sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_temp.sh - sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_temp.sh - sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" install_temp.sh - sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_temp.sh + sed -i "s/PREFIX=\"taos\"/PREFIX=\"${serverName2}\"/g" install_temp.sh + sed -i "s/productName=\"TDengine\"/productName=\"${productName2}\"/g" install_temp.sh cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'` - sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" install_temp.sh + sed -i "s/emailName=\"taosdata.com\"/emailName=\"${cusDomain}\"/g" install_temp.sh mv install_temp.sh ${install_dir}/install.sh fi if [ "$verMode" == "cloud" ]; then @@ -367,8 +361,7 @@ if [ "$verMode" == "cluster" ]; then # copy taosx if [ -d ${top_dir}/../enterprise/src/plugins/taosx/release/taosx ]; then - cp -r ${top_dir}/../enterprise/src/plugins/taosx/release/taosx ${install_dir} - cp ${top_dir}/../enterprise/packaging/install_taosx.sh ${install_dir}/taosx + cp -r ${top_dir}/../enterprise/src/plugins/taosx/release/taosx ${install_dir} cp ${top_dir}/../enterprise/src/plugins/taosx/packaging/uninstall.sh ${install_dir}/taosx sed -i 's/target=\"\"/target=\"taosx\"/g' ${install_dir}/taosx/uninstall.sh fi