From 43a8c77757466f7e506d1898d0ee1fa453140e45 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Sun, 15 Oct 2023 16:34:58 +0800 Subject: [PATCH] update script --- packaging/tools/install.sh | 145 ++++++++++++++++++++++++------------- packaging/tools/makepkg.sh | 26 +++++-- packaging/tools/remove.sh | 15 +++- 3 files changed, 129 insertions(+), 57 deletions(-) diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 0a11ef3a53..e8798ed16b 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -607,6 +607,9 @@ function install_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 ${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" fi } @@ -622,6 +625,14 @@ function install_web() { 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 + fi +} + function clean_service_on_sysvinit() { if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then ${csudo}service ${serverName2} stop || : @@ -893,6 +904,7 @@ function updateProduct() { if [ "$verMode" == "cluster" ]; then install_connector + install_taosx fi install_examples @@ -907,38 +919,54 @@ function updateProduct() { openresty_work=false echo - echo -e "${GREEN_DARK}To configure ${productName2} ${NC}\t: edit ${cfg_install_dir}/${configFile2}" + 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" + if [ "$verMode" == "cluster" ]; then + echo -e "${GREEN_DARK}To configure ${clientName2}-explorer ${NC}\t: edit ${configDir}/explorer.toml" + fi if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${csudo}systemctl start ${serverName2}${NC}" + 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: ${csudo}systemctl start ${clientName2}adapter ${NC}" + echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName2}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${csudo}service ${serverName2} start${NC}" + 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: ${csudo}service ${clientName2}adapter start${NC}" + echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}service ${clientName2}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ./${serverName2}${NC}" + 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: ${clientName2}adapter ${NC}" + 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: sudo systemctl enable ${clientName2}keeper ${NC}" - - if [ ${openresty_work} = 'true' ]; then - echo -e "${GREEN_DARK}To access ${productName2} ${NC}\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: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell${NC}" + 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}" 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 + # 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 echo -e "\033[44;32;1m${productName2} is updated successfully!${NC}" - echo -e "\033[44;32;1mTo manage ${productName2} instance, view documentation or explorer features, please install ${clientName2}Explorer ${NC}" + echo + if [ "$verMode" == "cluster" ];then + echo -e "\033[44;32;1mTo start all the components \t: sudo ./start-all.sh${NC}" + fi + echo -e "\033[44;32;1mTo access ${productName2} \t\t: ${clientName2} -h $serverFqdn${NC}" + if [ "$verMode" == "cluster" ];then + echo -e "\033[44;32;1mTo access the management system \t: http://$serverFqdn:6060${NC}" + echo -e "\033[44;32;1mTo read the user manual \t: http://$serverFqdn:6060/docs${NC}" + fi else install_bin install_config @@ -947,7 +975,8 @@ function updateProduct() { echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}" fi - rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") + cd $script_dir + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } function installProduct() { @@ -975,6 +1004,7 @@ function installProduct() { if [ "$verMode" == "cluster" ]; then install_connector + install_taosx fi install_examples install_web @@ -991,47 +1021,63 @@ function installProduct() { # Ask if to start the service echo - echo -e "${GREEN_DARK}To configure ${productName2} ${NC}\t: edit ${cfg_install_dir}/${configFile2}" + 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" + if [ "$verMode" == "cluster" ]; then + echo -e "${GREEN_DARK}To configure ${clientName2}-explorer ${NC}\t: edit ${configDir}/explorer.toml" + fi if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${csudo}systemctl start ${serverName2}${NC}" + 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: ${csudo}systemctl start ${clientName2}adapter ${NC}" + echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName2}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${csudo}service ${serverName2} start${NC}" + 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: ${csudo}service ${clientName2}adapter start${NC}" + echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}service ${clientName2}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${serverName2}${NC}" + 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: ${clientName2}adapter ${NC}" + 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: sudo systemctl enable ${clientName2}keeper ${NC}" - - 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: ${clientName2} -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}" - else - echo -e "${GREEN_DARK}To access ${productName2} ${NC}\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: ${clientName2} -h $serverFqdn${GREEN_DARK} to login into ${productName2} server${NC}" - echo + 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}" 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 -e "\033[44;32;1m${productName2} is installed successfully!${NC}" - echo -e "\033[44;32;1mTo manage ${productName2} instance, view documentation or explorer features, please install ${clientName2}Explorer ${NC}" + echo + if [ "$verMode" == "cluster" ];then + echo -e "\033[44;32;1mTo start all the components \t: sudo ./start-all.sh${NC}" + fi + echo -e "\033[44;32;1mTo access ${productName2} \t\t: ${clientName2} -h $serverFqdn${NC}" + if [ "$verMode" == "cluster" ];then + echo -e "\033[44;32;1mTo access the management system \t: http://$serverFqdn:6060${NC}" + echo -e "\033[44;32;1mTo read the user manual \t: http://$serverFqdn:6060/docs${NC}" + fi echo else # Only install client install_bin @@ -1039,7 +1085,8 @@ function installProduct() { echo echo -e "\033[44;32;1m${productName2} client is installed successfully!${NC}" fi - + + cd $script_dir touch ~/.${historyFile} rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } @@ -1070,4 +1117,4 @@ elif [ "$verType" == "client" ]; then fi else echo "please input correct verType" -fi +fi \ No newline at end of file diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 42465b8783..d94e6f566d 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -284,8 +284,13 @@ if [ "$pagMode" == "lite" ]; then fi chmod a+x ${install_dir}/install.sh -if [[ $dbName == "taos" ]]; then - # Copy example code +if [[ $dbName == "taos" ]]; then + cp ${top_dir}/../enterprise/packaging/start-all.sh ${install_dir} + cp ${top_dir}/../enterprise/packaging/stop-all.sh ${install_dir} + cp ${top_dir}/../enterprise/packaging/README.md ${install_dir} + chmod a+x ${install_dir}/start-all.sh + chmod a+x ${install_dir}/stop-all.sh + # Copy example code mkdir -p ${install_dir}/examples examples_dir="${top_dir}/examples" cp -r ${examples_dir}/c ${install_dir}/examples @@ -330,8 +335,8 @@ fi mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo "${versionComp}" >${install_dir}/driver/vercomp.txt [ -f ${wslib_files} ] && cp ${wslib_files} ${install_dir}/driver || : -# Copy connector -if [ "$verMode" == "cluster" ]; then +# Copy connector && taosx +if [ "$verMode" == "cluster" ]; then connector_dir="${code_dir}/connector" mkdir -p ${install_dir}/connector if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then @@ -364,8 +369,15 @@ if [ "$verMode" == "cluster" ]; then git clone --depth 1 https://github.com/taosdata/taos-connector-rust ${install_dir}/connector/rust rm -rf ${install_dir}/connector/rust/.git ||: - # cp -r ${connector_dir}/python ${install_dir}/connector - # cp -r ${connector_dir}/nodejs ${install_dir}/connector + # 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 ${top_dir}/../enterprise/src/plugins/taosx/packaging/uninstall.sh ${install_dir}/taosx + else + echo "taox package not found" + exit 1 + fi fi fi @@ -436,4 +448,4 @@ if [ -n "${taostools_bin_files}" ] && [ "$verMode" != "cloud" ]; then fi fi -cd ${curr_dir} +cd ${curr_dir} \ No newline at end of file diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 97bffb0535..37cc357065 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -284,6 +284,16 @@ function clean_service() { fi } +function uninstall_taosx() { + if [ -f /usr/local/taosx/uninstall.sh ]; then + cd /usr/local/taosx + bash uninstall.sh > /dev/null + + echo -e "${GREEN}${xName2} is removed successfully!${NC}" + echo -e "${GREEN}${explorerName2} is removed successfully!${NC}" + fi +} + # Stop service and disable booting start. clean_service # Remove binary file and links @@ -323,4 +333,7 @@ if [ "$osType" = "Darwin" ]; then fi echo -e "${GREEN}${productName2} is removed successfully!${NC}" -echo +if [ "$verMode" == "cluster" ]; then + uninstall_taosx +fi +echo \ No newline at end of file