From 92ebc8e945bd1aea76c6f62cd940673926a76619 Mon Sep 17 00:00:00 2001 From: xinsheng Ren <285808407@qq.com> Date: Sat, 21 Jan 2023 10:23:07 +0800 Subject: [PATCH] Enh/xsren/td 21710/mac installer check (#19653) * enh/TD-21710/mac-install-check * fix:delete unuseful variable Co-authored-by: facetosea <25808407@qq.com> --- packaging/tools/post.sh | 84 ++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 18 deletions(-) diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index b246e0225f..85f1f00935 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -48,6 +48,7 @@ fi data_link_dir="${install_main_dir}/data" log_link_dir="${install_main_dir}/log" +install_log_path="${log_dir}/taos_install.log" # static directory cfg_dir="${install_main_dir}/cfg" @@ -101,6 +102,11 @@ if [ "$osType" = "Darwin" ]; then ${csudo}cp -rf tdengine ${install_main_dir} fi +function log_print(){ + now=$(date +"%D %T") + echo "$now $1" >> ${install_log_path} +} + function kill_taosadapter() { # ${csudo}pkill -f taosadapter || : pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') @@ -125,6 +131,7 @@ function kill_taosd() { } function install_include() { + log_print "start install include from ${inc_dir} to ${inc_link_dir}" ${csudo}mkdir -p ${inc_link_dir} ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : [ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h ||: @@ -135,34 +142,39 @@ function install_include() { ${csudo}ln -s ${inc_dir}/taosudf.h ${inc_link_dir}/taosudf.h [ -f ${inc_dir}/taosws.h ] && ${csudo}ln -sf ${inc_dir}/taosws.h ${inc_link_dir}/taosws.h ||: + log_print "install include success" } function install_lib() { + log_print "start install lib from ${lib_dir} to ${lib_link_dir}" ${csudo}rm -f ${lib_link_dir}/libtaos* || : ${csudo}rm -f ${lib64_link_dir}/libtaos* || : [ -f ${lib_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.${lib_file_ext} || : [ -f ${lib64_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.${lib_file_ext} || : - ${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.${lib_file_ext_1} - ${csudo}ln -s ${lib_link_dir}/libtaos.${lib_file_ext_1} ${lib_link_dir}/libtaos.${lib_file_ext} + ${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.${lib_file_ext_1} 2>>${install_log_path} || return 1 + ${csudo}ln -s ${lib_link_dir}/libtaos.${lib_file_ext_1} ${lib_link_dir}/libtaos.${lib_file_ext} 2>>${install_log_path} || return 1 [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib_link_dir}/libtaosws.${lib_file_ext} ||: if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.${lib_file_ext} ]]; then - ${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.${lib_file_ext_1} || : - ${csudo}ln -s ${lib64_link_dir}/libtaos.${lib_file_ext_1} ${lib64_link_dir}/libtaos.${lib_file_ext} || : + ${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.${lib_file_ext_1} 2>>${install_log_path} || return 1 + ${csudo}ln -s ${lib64_link_dir}/libtaos.${lib_file_ext_1} ${lib64_link_dir}/libtaos.${lib_file_ext} 2>>${install_log_path} || return 1 - [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib64_link_dir}/libtaosws.${lib_file_ext} || : + [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib64_link_dir}/libtaosws.${lib_file_ext} 2>>${install_log_path} fi if [ "$osType" != "Darwin" ]; then ${csudo}ldconfig fi + + log_print "install lib success" } function install_bin() { # Remove links + log_print "start install bin from ${bin_dir} to ${bin_link_dir}" ${csudo}rm -f ${bin_link_dir}/taos || : ${csudo}rm -f ${bin_link_dir}/taosd || : ${csudo}rm -f ${bin_link_dir}/udfd || : @@ -177,17 +189,38 @@ function install_bin() { ${csudo}chmod 0555 ${bin_dir}/* #Make link - [ -x ${bin_dir}/taos ] && ${csudo}ln -s ${bin_dir}/taos ${bin_link_dir}/taos || : - [ -x ${bin_dir}/taosd ] && ${csudo}ln -s ${bin_dir}/taosd ${bin_link_dir}/taosd || : - [ -x ${bin_dir}/udfd ] && ${csudo}ln -s ${bin_dir}/udfd ${bin_link_dir}/udfd || : - [ -x ${bin_dir}/taosadapter ] && ${csudo}ln -s ${bin_dir}/taosadapter ${bin_link_dir}/taosadapter || : - [ -x ${bin_dir}/taosBenchmark ] && ${csudo}ln -sf ${bin_dir}/taosBenchmark ${bin_link_dir}/taosdemo || : - [ -x ${bin_dir}/taosBenchmark ] && ${csudo}ln -sf ${bin_dir}/taosBenchmark ${bin_link_dir}/taosBenchmark || : - [ -x ${bin_dir}/TDinsight.sh ] && ${csudo}ln -sf ${bin_dir}/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : - [ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || : - [ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${bin_dir}/remove.sh ] && ${csudo}ln -s ${bin_dir}/remove.sh ${bin_link_dir}/rmtaos || : - [ -x ${bin_dir}/taoskeeper ] && ${csudo}ln -sf ${bin_dir}/taoskeeper ${bin_link_dir}/taoskeeper || : + if [ -x ${bin_dir}/taos ]; then + ${csudo}ln -s ${bin_dir}/taos ${bin_link_dir}/taos 2>>${install_log_path} || return 1 + fi + if [ -x ${bin_dir}/taosd ]; then + ${csudo}ln -s ${bin_dir}/taosd ${bin_link_dir}/taosd 2>>${install_log_path} || return 1 + fi + if [ -x ${bin_dir}/udfd ]; then + ${csudo}ln -s ${bin_dir}/udfd ${bin_link_dir}/udfd 2>>${install_log_path} || return 1 + fi + if [ -x ${bin_dir}/taosadapter ]; then + ${csudo}ln -s ${bin_dir}/taosadapter ${bin_link_dir}/taosadapter 2>>${install_log_path} || return 1 + fi + if [ -x ${bin_dir}/taosBenchmark ]; then + ${csudo}ln -sf ${bin_dir}/taosBenchmark ${bin_link_dir}/taosdemo 2>>${install_log_path} + ${csudo}ln -sf ${bin_dir}/taosBenchmark ${bin_link_dir}/taosBenchmark 2>>${install_log_path} + fi + if [ -x ${bin_dir}/TDinsight.sh ]; then + ${csudo}ln -sf ${bin_dir}/TDinsight.sh ${bin_link_dir}/TDinsight.sh 2>>${install_log_path} || return 1 + fi + if [ -x ${bin_dir}/taosdump ]; then + ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump 2>>${install_log_path} || return 1 + fi + if [ -x ${bin_dir}/set_core.sh ]; then + ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core 2>>${install_log_path} || return 1 + fi + if [ -x ${bin_dir}/remove.sh ]; then + ${csudo}ln -s ${bin_dir}/remove.sh ${bin_link_dir}/rmtaos 2>>${install_log_path} || return 1 + fi + if [ -x ${bin_dir}/taoskeeper ]; then + ${csudo}ln -sf ${bin_dir}/taoskeeper ${bin_link_dir}/taoskeeper 2>>${install_log_path} || return 1 + fi + log_print "install bin success" } function add_newHostname_to_hosts() { @@ -377,6 +410,7 @@ function install_taoskeeper_config() { } function install_config() { + log_print "start install config from ${cfg_dir} to ${cfg_install_dir}" if [ ! -f "${cfg_install_dir}/taos.cfg" ]; then ${csudo}${csudo}mkdir -p ${cfg_install_dir} [ -f ${cfg_dir}/taos.cfg ] && ${csudo}cp ${cfg_dir}/taos.cfg ${cfg_install_dir} @@ -444,6 +478,8 @@ function install_config() { break fi done + + log_print "install config success" } function clean_service_on_sysvinit() { @@ -558,6 +594,7 @@ function install_taosadapter_service() { } function install_service() { + log_print "start install service" if [ "$osType" != "Darwin" ]; then if ((${service_mod}==0)); then install_service_on_systemd @@ -571,6 +608,7 @@ function install_service() { else install_service_on_launchctl fi + log_print "install service success" } function install_app() { @@ -591,6 +629,7 @@ function install_app() { function install_TDengine() { echo -e "${GREEN}Start to install TDengine...${NC}" + log_print "start to install TDengine" #install log and data dir , then ln to /usr/local/taos ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} @@ -603,9 +642,15 @@ function install_TDengine() { ${csudo}ln -s ${data_dir} ${data_link_dir} || : # Install include, lib, binary and service - install_include - install_lib + install_include && + install_lib && install_bin + + if [[ "$?" != 0 ]];then + log_print "install TDengine failed!" + return 1 + fi + install_config install_taosadapter_config install_taoskeeper_config @@ -648,11 +693,14 @@ function install_TDengine() { echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $serverFqdn${GREEN_DARK} to login into TDengine server${NC}" echo fi + log_print "install TDengine successfully!" echo echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" } ## ==============================Main program starts from here============================ +${csudo}rm -rf ${install_log_path} +log_print "installer start..." serverFqdn=$(hostname) install_TDengine -- GitLab