diff --git a/packaging/check_package.sh b/packaging/check_package.sh index e625f90912825f30ba279ecf6dbe59ff7dade97f..81abff57a586d116ead0137f96697ece04250d6b 100755 --- a/packaging/check_package.sh +++ b/packaging/check_package.sh @@ -50,7 +50,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi # ============================= get input parameters ================================================= @@ -85,7 +85,7 @@ done function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } diff --git a/packaging/deb/DEBIAN/postinst b/packaging/deb/DEBIAN/postinst index 556e757c2bfced34c43283c0de39baaacb95003f..2638f096250b8fa52277573f14a6f0f07b335b32 100644 --- a/packaging/deb/DEBIAN/postinst +++ b/packaging/deb/DEBIAN/postinst @@ -5,9 +5,9 @@ insmetaPath="/usr/local/taos/script" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi -${csudo} chmod -R 744 ${insmetaPath} +${csudo}chmod -R 744 ${insmetaPath} cd ${insmetaPath} -${csudo} ./post.sh +${csudo}./post.sh diff --git a/packaging/deb/DEBIAN/preinst b/packaging/deb/DEBIAN/preinst index 4b8b72e9abd9e12d9f669cf5658be2468ebab40b..5217a8229571bf993c6c3df8f82beb1ed67c3e96 100644 --- a/packaging/deb/DEBIAN/preinst +++ b/packaging/deb/DEBIAN/preinst @@ -2,19 +2,19 @@ csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi # Stop the service if running if pidof taosd &> /dev/null; then if pidof systemd &> /dev/null; then - ${csudo} systemctl stop taosd || : + ${csudo}systemctl stop taosd || : elif $(which service &> /dev/null); then - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : else pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi fi echo "Stop taosd service success!" @@ -25,16 +25,16 @@ fi cfg_install_dir="/etc/taos" install_main_dir="/usr/local/taos" if [ -f "${install_main_dir}/taos.cfg" ]; then - ${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : + ${csudo}rm -f ${install_main_dir}/cfg/taos.cfg || : fi if [ -f "${install_main_dir}/taosadapter.toml" ]; then - ${csudo} rm -f ${install_main_dir}/cfg/taosadapter.toml || : + ${csudo}rm -f ${install_main_dir}/cfg/taosadapter.toml || : fi if [ -f "${install_main_dir}/taosadapter.service" ]; then - ${csudo} rm -f ${install_main_dir}/cfg/taosadapter.service || : + ${csudo}rm -f ${install_main_dir}/cfg/taosadapter.service || : fi # there can not libtaos.so*, otherwise ln -s error -${csudo} rm -f ${install_main_dir}/driver/libtaos* || : +${csudo}rm -f ${install_main_dir}/driver/libtaos* || : diff --git a/packaging/deb/DEBIAN/prerm b/packaging/deb/DEBIAN/prerm index b6979cf26435e4c4b0d19f5c93bb92cda988b3bf..c01db74701f99e52cc45b589d8fe7b07c4c8afe1 100644 --- a/packaging/deb/DEBIAN/prerm +++ b/packaging/deb/DEBIAN/prerm @@ -4,15 +4,15 @@ insmetaPath="/usr/local/taos/script" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi -${csudo} chmod -R 744 ${insmetaPath} || : +${csudo}chmod -R 744 ${insmetaPath} || : #cd ${insmetaPath} -#${csudo} ./preun.sh +#${csudo}./preun.sh if [ -f ${insmetaPath}/preun.sh ]; then cd ${insmetaPath} - ${csudo} ./preun.sh + ${csudo}./preun.sh else bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" @@ -23,20 +23,20 @@ else cfg_link_dir="/usr/local/taos/cfg" # Remove all links - ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosd || : - ${csudo} rm -f ${bin_link_dir}/taosadapter || : - ${csudo} rm -f ${bin_link_dir}/taosdemo || : - ${csudo} rm -f ${cfg_link_dir}/* || : - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${bin_link_dir}/taos || : + ${csudo}rm -f ${bin_link_dir}/taosd || : + ${csudo}rm -f ${bin_link_dir}/taosadapter || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${log_link_dir} || : - ${csudo} rm -f ${data_link_dir} || : + ${csudo}rm -f ${log_link_dir} || : + ${csudo}rm -f ${data_link_dir} || : pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi fi diff --git a/packaging/release.sh b/packaging/release.sh index ca8715f68430fc08b86f008936ddfc9409ae58a8..fd2266792ebf9ed419ef3dee1ee6e146e4e9534f 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -113,7 +113,7 @@ fi csudo="" #if command -v sudo > /dev/null; then -# csudo="sudo" +# csudo="sudo " #fi function is_valid_version() { @@ -183,11 +183,11 @@ cd ${curr_dir} # 2. cmake executable file compile_dir="${top_dir}/debug" if [ -d ${compile_dir} ]; then - ${csudo} rm -rf ${compile_dir} + ${csudo}rm -rf ${compile_dir} fi if [ "$osType" != "Darwin" ]; then - ${csudo} mkdir -p ${compile_dir} + ${csudo}mkdir -p ${compile_dir} else mkdir -p ${compile_dir} fi @@ -496,9 +496,9 @@ fi if [[ "$allocator" == "jemalloc" ]]; then # jemalloc need compile first, so disable parallel build - make -j 8 && ${csudo} make install + make -j 8 && ${csudo}make install else - make -j 8 && ${csudo} make install + make -j 8 && ${csudo}make install fi cd ${curr_dir} @@ -512,11 +512,11 @@ if [ "$osType" != "Darwin" ]; then echo "====do deb package for the ubuntu system====" output_dir="${top_dir}/debs" if [ -d ${output_dir} ]; then - ${csudo} rm -rf ${output_dir} + ${csudo}rm -rf ${output_dir} fi - ${csudo} mkdir -p ${output_dir} + ${csudo}mkdir -p ${output_dir} cd ${script_dir}/deb - ${csudo} ./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType} + ${csudo}./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType} if [[ "$pagMode" == "full" ]]; then if [ -d ${top_dir}/src/kit/taos-tools/packaging/deb ]; then @@ -524,7 +524,7 @@ if [ "$osType" != "Darwin" ]; then [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" taos_tools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}') - ${csudo} ./make-taos-tools-deb.sh ${top_dir} \ + ${csudo}./make-taos-tools-deb.sh ${top_dir} \ ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} fi fi @@ -537,11 +537,11 @@ if [ "$osType" != "Darwin" ]; then echo "====do rpm package for the centos system====" output_dir="${top_dir}/rpms" if [ -d ${output_dir} ]; then - ${csudo} rm -rf ${output_dir} + ${csudo}rm -rf ${output_dir} fi - ${csudo} mkdir -p ${output_dir} + ${csudo}mkdir -p ${output_dir} cd ${script_dir}/rpm - ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType} + ${csudo}./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType} if [[ "$pagMode" == "full" ]]; then if [ -d ${top_dir}/src/kit/taos-tools/packaging/rpm ]; then @@ -549,7 +549,7 @@ if [ "$osType" != "Darwin" ]; then [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" taos_tools_ver=$(git describe --tags|sed -e 's/ver-//g'|awk -F '-' '{print $1}'|sed -e 's/-/_/g') - ${csudo} ./make-taos-tools-rpm.sh ${top_dir} \ + ${csudo}./make-taos-tools-rpm.sh ${top_dir} \ ${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType} fi fi @@ -562,29 +562,29 @@ if [ "$osType" != "Darwin" ]; then cd ${script_dir}/tools if [[ "$dbName" == "taos" ]]; then - ${csudo} ./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} - ${csudo} ./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} - ${csudo} ./makearbi.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + ${csudo}./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} + ${csudo}./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + ${csudo}./makearbi.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} elif [[ "$dbName" == "tq" ]]; then - ${csudo} ./makepkg_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} - ${csudo} ./makeclient_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} - ${csudo} ./makearbi_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + ${csudo}./makepkg_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} + ${csudo}./makeclient_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} + ${csudo}./makearbi_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} elif [[ "$dbName" == "pro" ]]; then - ${csudo} ./makepkg_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} - ${csudo} ./makeclient_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} - ${csudo} ./makearbi_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + ${csudo}./makepkg_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} + ${csudo}./makeclient_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} + ${csudo}./makearbi_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} elif [[ "$dbName" == "kh" ]]; then - ${csudo} ./makepkg_kh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} - ${csudo} ./makeclient_kh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} - ${csudo} ./makearbi_kh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + ${csudo}./makepkg_kh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} + ${csudo}./makeclient_kh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} + ${csudo}./makearbi_kh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} elif [[ "$dbName" == "jh" ]]; then - ${csudo} ./makepkg_jh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} - ${csudo} ./makeclient_jh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} - ${csudo} ./makearbi_jh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + ${csudo}./makepkg_jh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} + ${csudo}./makeclient_jh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} + ${csudo}./makearbi_jh.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} else - ${csudo} ./makepkg_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} - ${csudo} ./makeclient_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} - ${csudo} ./makearbi_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + ${csudo}./makepkg_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} + ${csudo}./makeclient_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} + ${csudo}./makearbi_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} fi else # only make client for Darwin diff --git a/packaging/rpm/makerpm.sh b/packaging/rpm/makerpm.sh index b4cf3d1450619f6a43a5303afa45f71c4402c2e7..4ac67ec754ce230f9a777570c42a9300c757978d 100755 --- a/packaging/rpm/makerpm.sh +++ b/packaging/rpm/makerpm.sh @@ -28,7 +28,7 @@ echo "spec_file: ${spec_file}" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi function cp_rpm_package() { @@ -49,17 +49,17 @@ function cp_rpm_package() { } if [ -d ${pkg_dir} ]; then - ${csudo} rm -rf ${pkg_dir} + ${csudo}rm -rf ${pkg_dir} fi -${csudo} mkdir -p ${pkg_dir} +${csudo}mkdir -p ${pkg_dir} cd ${pkg_dir} -${csudo} mkdir -p BUILD BUILDROOT RPMS SOURCES SPECS SRPMS +${csudo}mkdir -p BUILD BUILDROOT RPMS SOURCES SPECS SRPMS -${csudo} rpmbuild --define="_version ${tdengine_ver}" --define="_topdir ${pkg_dir}" --define="_compiledir ${compile_dir}" -bb ${spec_file} +${csudo}rpmbuild --define="_version ${tdengine_ver}" --define="_topdir ${pkg_dir}" --define="_compiledir ${compile_dir}" -bb ${spec_file} # copy rpm package to output_dir, and modify package name, then clean temp dir -#${csudo} cp -rf RPMS/* ${output_dir} +#${csudo}cp -rf RPMS/* ${output_dir} cp_rpm_package ${pkg_dir}/RPMS @@ -84,4 +84,4 @@ fi mv ${output_dir}/TDengine-${tdengine_ver}.rpm ${output_dir}/${rpmname} cd .. -${csudo} rm -rf ${pkg_dir} +${csudo}rm -rf ${pkg_dir} diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index e1a8a9f9f6aee3ebe7fbcdacd579235cde7165e8..3a8153ff2bf791d0660cd81c2081af829a79e751 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -128,19 +128,19 @@ fi %pre csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi # Stop the service if running if pidof taosd &> /dev/null; then if pidof systemd &> /dev/null; then - ${csudo} systemctl stop taosd || : + ${csudo}systemctl stop taosd || : elif $(which service &> /dev/null); then - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : else pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi fi echo "Stop taosd service success!" @@ -148,40 +148,40 @@ if pidof taosd &> /dev/null; then fi # if taos.cfg already exist, remove it if [ -f %{cfg_install_dir}/taos.cfg ]; then - ${csudo} rm -f %{cfg_install_dir}/cfg/taos.cfg || : + ${csudo}rm -f %{cfg_install_dir}/cfg/taos.cfg || : fi # if taosadapter.toml already exist, remove it if [ -f %{cfg_install_dir}/taosadapter.toml ]; then - ${csudo} rm -f %{cfg_install_dir}/cfg/taosadapter.toml || : + ${csudo}rm -f %{cfg_install_dir}/cfg/taosadapter.toml || : fi # there can not libtaos.so*, otherwise ln -s error -${csudo} rm -f %{homepath}/driver/libtaos* || : +${csudo}rm -f %{homepath}/driver/libtaos* || : #Scripts executed after installation %post csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi cd %{homepath}/script -${csudo} ./post.sh +${csudo}./post.sh # Scripts executed before uninstall %preun csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi # only remove package to call preun.sh, not but update(2) if [ $1 -eq 0 ];then #cd %{homepath}/script - #${csudo} ./preun.sh + #${csudo}./preun.sh if [ -f %{homepath}/script/preun.sh ]; then cd %{homepath}/script - ${csudo} ./preun.sh + ${csudo}./preun.sh else bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" @@ -192,21 +192,21 @@ if [ $1 -eq 0 ];then cfg_link_dir="/usr/local/taos/cfg" # Remove all links - ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosd || : - ${csudo} rm -f ${bin_link_dir}/taosadapter || : - ${csudo} rm -f ${cfg_link_dir}/* || : - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - - ${csudo} rm -f ${log_link_dir} || : - ${csudo} rm -f ${data_link_dir} || : + ${csudo}rm -f ${bin_link_dir}/taos || : + ${csudo}rm -f ${bin_link_dir}/taosd || : + ${csudo}rm -f ${bin_link_dir}/taosadapter || : + ${csudo}rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + + ${csudo}rm -f ${log_link_dir} || : + ${csudo}rm -f ${data_link_dir} || : pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi fi fi @@ -218,9 +218,9 @@ fi %clean csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi -${csudo} rm -rf %{buildroot} +${csudo}rm -rf %{buildroot} #Specify the files to be packaged %files diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 6d007c0dd1527c281b09bf1f3623eab873b235d6..511b3003e857ca410e0f91bf4af4d268a32adace 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -50,7 +50,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -157,103 +157,103 @@ done function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then - ${csudo} mkdir -p ${nginx_dir} + ${csudo}mkdir -p ${nginx_dir} fi if [[ -e ${script_dir}/email ]]; then - ${csudo} cp ${script_dir}/email ${install_main_dir}/ ||: + ${csudo}cp ${script_dir}/email ${install_main_dir}/ ||: fi } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosd || : - ${csudo} rm -f ${bin_link_dir}/taosadapter || : - ${csudo} rm -f ${bin_link_dir}/taosdemo || : - ${csudo} rm -f ${bin_link_dir}/taosdump || : - ${csudo} rm -f ${bin_link_dir}/rmtaos || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : - - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}rm -f ${bin_link_dir}/taos || : + ${csudo}rm -f ${bin_link_dir}/taosd || : + ${csudo}rm -f ${bin_link_dir}/taosadapter || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/rmtaos || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : + + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : - [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : - [ -x ${install_main_dir}/bin/taosadapter ] && ${csudo} ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || : - [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : - [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo} ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/taos ] && ${csudo}ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : + [ -x ${install_main_dir}/bin/taosd ] && ${csudo}ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : + [ -x ${install_main_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || : + [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + [ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then - ${csudo} cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo} chmod 0555 ${nginx_dir}/* - ${csudo} mkdir -p ${nginx_dir}/logs - ${csudo} chmod 777 ${nginx_dir}/sbin/nginx + ${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/* + ${csudo}mkdir -p ${nginx_dir}/logs + ${csudo}chmod 777 ${nginx_dir}/sbin/nginx fi } function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi #if [ "$verMode" == "cluster" ]; then # # Compatible with version 1.5 - # ${csudo} mkdir -p ${v15_java_app_dir} - # ${csudo} ln -s ${install_main_dir}/connector/taos-jdbcdriver-1.0.2-dist.jar ${v15_java_app_dir}/JDBCDriver-1.0.2-dist.jar - # ${csudo} chmod 777 ${v15_java_app_dir} || : + # ${csudo}mkdir -p ${v15_java_app_dir} + # ${csudo}ln -s ${install_main_dir}/connector/taos-jdbcdriver-1.0.2-dist.jar ${v15_java_app_dir}/JDBCDriver-1.0.2-dist.jar + # ${csudo}chmod 777 ${v15_java_app_dir} || : #fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_avro() { if [ "$osType" != "Darwin" ]; then avro_dir=${script_dir}/avro if [ -f "${avro_dir}/lib/libavro.so.23.0.0" ] && [ -d /usr/local/$1 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/$1 - ${csudo} /usr/bin/install -c -m 755 ${avro_dir}/lib/libavro.so.23.0.0 /usr/local/$1 - ${csudo} ln -sf /usr/local/$1/libavro.so.23.0.0 /usr/local/$1/libavro.so.23 - ${csudo} ln -sf /usr/local/$1/libavro.so.23 /usr/local/$1/libavro.so + ${csudo}/usr/bin/install -c -d /usr/local/$1 + ${csudo}/usr/bin/install -c -m 755 ${avro_dir}/lib/libavro.so.23.0.0 /usr/local/$1 + ${csudo}ln -sf /usr/local/$1/libavro.so.23.0.0 /usr/local/$1/libavro.so.23 + ${csudo}ln -sf /usr/local/$1/libavro.so.23 /usr/local/$1/libavro.so - ${csudo} /usr/bin/install -c -d /usr/local/$1 + ${csudo}/usr/bin/install -c -d /usr/local/$1 [ -f ${avro_dir}/lib/libavro.a ] && - ${csudo} /usr/bin/install -c -m 755 ${avro_dir}/lib/libavro.a /usr/local/$1 + ${csudo}/usr/bin/install -c -m 755 ${avro_dir}/lib/libavro.a /usr/local/$1 if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/$1" | ${csudo} tee /etc/ld.so.conf.d/libavro.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/libavro.conf" - ${csudo} ldconfig + echo "/usr/local/$1" | ${csudo}tee /etc/ld.so.conf.d/libavro.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/libavro.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -265,49 +265,49 @@ function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -315,11 +315,11 @@ function install_jemalloc() { } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function add_newHostname_to_hosts() { @@ -335,7 +335,7 @@ function add_newHostname_to_hosts() { return fi done - ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: + ${csudo}echo "127.0.0.1 $1" >> /etc/hosts ||: } function set_hostname() { @@ -349,7 +349,7 @@ function set_hostname() { fi done - ${csudo} hostname $newHostname ||: + ${csudo}hostname $newHostname ||: retval=`echo $?` if [[ $retval != 0 ]]; then echo @@ -362,15 +362,15 @@ function set_hostname() { #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then - ${csudo} echo $newHostname > /etc/hostname ||: + ${csudo}echo $newHostname > /etc/hostname ||: fi #debian: #HOSTNAME=yourname if [[ -e /etc/sysconfig/network ]]; then - ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: + ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: fi - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -405,7 +405,7 @@ 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 - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg serverFqdn=$localFqdn echo return @@ -427,7 +427,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg serverFqdn=$localFqdn break fi @@ -475,32 +475,32 @@ function local_fqdn_check() { function install_taosadapter_config() { if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/taosadapter.toml ] && ${csudo} cp ${script_dir}/cfg/taosadapter.toml ${cfg_install_dir} - [ -f ${cfg_install_dir}/taosadapter.toml ] && ${csudo} chmod 644 ${cfg_install_dir}/taosadapter.toml + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/taosadapter.toml ] && ${csudo}cp ${script_dir}/cfg/taosadapter.toml ${cfg_install_dir} + [ -f ${cfg_install_dir}/taosadapter.toml ] && ${csudo}chmod 644 ${cfg_install_dir}/taosadapter.toml fi [ -f ${script_dir}/cfg/taosadapter.toml ] && - ${csudo} cp -f ${script_dir}/cfg/taosadapter.toml ${cfg_install_dir}/taosadapter.toml.new + ${csudo}cp -f ${script_dir}/cfg/taosadapter.toml ${cfg_install_dir}/taosadapter.toml.new [ -f ${cfg_install_dir}/taosadapter.toml ] && - ${csudo} ln -s ${cfg_install_dir}/taosadapter.toml ${install_main_dir}/cfg/taosadapter.toml + ${csudo}ln -s ${cfg_install_dir}/taosadapter.toml ${install_main_dir}/cfg/taosadapter.toml [ ! -z $1 ] && return 0 || : # only install client } function install_config() { - #${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : + #${csudo}rm -f ${install_main_dir}/cfg/taos.cfg || : if [ ! -f "${cfg_install_dir}/taos.cfg" ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo}cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/taos.cfg ${cfg_install_dir}/taos.cfg.new - ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/taos.cfg ${cfg_install_dir}/taos.cfg.new + ${csudo}ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg [ ! -z $1 ] && return 0 || : # only install client @@ -530,7 +530,7 @@ function install_config() { # check the format of the firstEp #if [[ $firstEp == $FQDN_PATTERN ]]; then # Write the first FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg break #else # read -p "Please enter the correct FQDN:port: " firstEp @@ -553,7 +553,7 @@ function install_config() { #if [[ "$emailAddr" =~ $EMAIL_PATTERN ]]; then # Write the email address to temp file email_file="${install_main_dir}/email" - ${csudo} bash -c "echo $emailAddr > ${email_file}" + ${csudo}bash -c "echo $emailAddr > ${email_file}" break #else # read -p "Please enter the correct email address: " emailAddr @@ -566,69 +566,69 @@ function install_config() { function install_log() { - ${csudo} rm -rf ${log_dir} || : - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}rm -rf ${log_dir} || : + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_data() { - ${csudo} mkdir -p ${data_dir} + ${csudo}mkdir -p ${data_dir} - ${csudo} ln -s ${data_dir} ${install_main_dir}/data + ${csudo}ln -s ${data_dir} ${install_main_dir}/data } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/ ${install_main_dir}/ + ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof taosd &> /dev/null; then - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : fi if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/taosd ]; then - ${csudo} chkconfig --del taosd || : + ${csudo}chkconfig --del taosd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/taosd ]; then - ${csudo} insserv -r taosd || : + ${csudo}insserv -r taosd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/taosd ]; then - ${csudo} update-rc.d -f taosd remove || : + ${csudo}update-rc.d -f taosd remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/taosd || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/taosd || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -639,33 +639,33 @@ function install_service_on_sysvinit() { # Install taosd service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/taosd.deb ${install_main_dir}/init.d/taosd - ${csudo} cp ${script_dir}/init.d/taosd.deb ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/taosd.deb ${install_main_dir}/init.d/taosd + ${csudo}cp ${script_dir}/init.d/taosd.deb ${service_config_dir}/taosd && ${csudo}chmod a+x ${service_config_dir}/taosd + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/taosd.rpm ${install_main_dir}/init.d/taosd - ${csudo} cp ${script_dir}/init.d/taosd.rpm ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/taosd.rpm ${install_main_dir}/init.d/taosd + ${csudo}cp ${script_dir}/init.d/taosd.rpm ${service_config_dir}/taosd && ${csudo}chmod a+x ${service_config_dir}/taosd + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" + #${csudo}grep -q -F "$restart_config_str" /etc/inittab || ${csudo}bash -c "echo '${restart_config_str}' >> /etc/inittab" if ((${initd_mod}==1)); then - ${csudo} chkconfig --add taosd || : - ${csudo} chkconfig --level 2345 taosd on || : - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add taosd || : + ${csudo}chkconfig --level 2345 taosd on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv taosd || : - ${csudo} insserv -d taosd || : - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv taosd || : + ${csudo}insserv -d taosd || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d taosd defaults || : - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d taosd defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -673,27 +673,27 @@ function clean_service_on_systemd() { taosd_service_config="${service_config_dir}/taosd.service" if systemctl is-active --quiet taosd; then echo "TDengine is running, stopping it..." - ${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop taosd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${taosd_service_config} + ${csudo}systemctl disable taosd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${taosd_service_config} 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" if systemctl is-active --quiet nginxd; then echo "Nginx for TDengine is running, stopping it..." - ${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop nginxd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}systemctl disable nginxd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${nginx_service_config} fi } @@ -703,106 +703,106 @@ function install_service_on_systemd() { clean_service_on_systemd [ -f ${script_dir}/cfg/taosd.service ] &&\ - ${csudo} cp ${script_dir}/cfg/taosd.service \ + ${csudo}cp ${script_dir}/cfg/taosd.service \ ${service_config_dir}/ || : - ${csudo} systemctl daemon-reload + ${csudo}systemctl daemon-reload #taosd_service_config="${service_config_dir}/taosd.service" - #${csudo} bash -c "echo '[Unit]' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'After=network-online.target taosadapter.service' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'Wants=network-online.target taosadapter.service' >> ${taosd_service_config}" - #${csudo} bash -c "echo >> ${taosd_service_config}" - #${csudo} bash -c "echo '[Service]' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'Type=simple' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'ExecStart=/usr/bin/taosd' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'ExecStartPre=/usr/local/taos/bin/startPre.sh' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'Restart=always' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}" - ##${csudo} bash -c "echo 'StartLimitIntervalSec=60s' >> ${taosd_service_config}" - #${csudo} bash -c "echo >> ${taosd_service_config}" - #${csudo} bash -c "echo '[Install]' >> ${taosd_service_config}" - #${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}" - ${csudo} systemctl enable taosd + #${csudo}bash -c "echo '[Unit]' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'After=network-online.target taosadapter.service' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'Wants=network-online.target taosadapter.service' >> ${taosd_service_config}" + #${csudo}bash -c "echo >> ${taosd_service_config}" + #${csudo}bash -c "echo '[Service]' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'Type=simple' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'ExecStart=/usr/bin/taosd' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'ExecStartPre=/usr/local/taos/bin/startPre.sh' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'Restart=always' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}" + ##${csudo}bash -c "echo 'StartLimitIntervalSec=60s' >> ${taosd_service_config}" + #${csudo}bash -c "echo >> ${taosd_service_config}" + #${csudo}bash -c "echo '[Install]' >> ${taosd_service_config}" + #${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}" + ${csudo}systemctl enable taosd [ -f ${script_dir}/cfg/tarbitratord.service ] &&\ - ${csudo} cp ${script_dir}/cfg/tarbitratord.service \ + ${csudo}cp ${script_dir}/cfg/tarbitratord.service \ ${service_config_dir}/ || : - ${csudo} systemctl daemon-reload + ${csudo}systemctl daemon-reload #tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - #${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - #${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - #${csudo} systemctl enable tarbitratord + #${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + #${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + #${csudo}systemctl enable tarbitratord if [ "$verMode" == "cluster" ]; then [ -f ${script_dir}/cfg/nginxd.service ] &&\ - ${csudo} cp ${script_dir}/cfg/nginxd.service \ + ${csudo}cp ${script_dir}/cfg/nginxd.service \ ${service_config_dir}/ || : - ${csudo} systemctl daemon-reload + ${csudo}systemctl daemon-reload #nginx_service_config="${service_config_dir}/nginxd.service" - #${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'Description=Nginx For TDengine Service' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" - #${csudo} bash -c "echo >> ${nginx_service_config}" - #${csudo} bash -c "echo '[Service]' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'Type=forking' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'Restart=always' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" - #${csudo} bash -c "echo >> ${nginx_service_config}" - #${csudo} bash -c "echo '[Install]' >> ${nginx_service_config}" - #${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" - if ! ${csudo} systemctl enable nginxd &> /dev/null; then - ${csudo} systemctl daemon-reexec - ${csudo} systemctl enable nginxd + #${csudo}bash -c "echo '[Unit]' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'Description=Nginx For TDengine Service' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" + #${csudo}bash -c "echo >> ${nginx_service_config}" + #${csudo}bash -c "echo '[Service]' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'Type=forking' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'Restart=always' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" + #${csudo}bash -c "echo >> ${nginx_service_config}" + #${csudo}bash -c "echo '[Install]' >> ${nginx_service_config}" + #${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" + if ! ${csudo}systemctl enable nginxd &> /dev/null; then + ${csudo}systemctl daemon-reexec + ${csudo}systemctl enable nginxd fi - ${csudo} systemctl start nginxd + ${csudo}systemctl start nginxd fi } function install_taosadapter_service() { if ((${service_mod}==0)); then [ -f ${script_dir}/cfg/taosadapter.service ] &&\ - ${csudo} cp ${script_dir}/cfg/taosadapter.service \ + ${csudo}cp ${script_dir}/cfg/taosadapter.service \ ${service_config_dir}/ || : - ${csudo} systemctl daemon-reload + ${csudo}systemctl daemon-reload fi } @@ -896,9 +896,9 @@ function update_TDengine() { # Stop the service if running if pidof taosd &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop taosd || : + ${csudo}systemctl stop taosd || : elif ((${service_mod}==1)); then - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : else kill_process taosd fi @@ -908,9 +908,9 @@ function update_TDengine() { if [ "$verMode" == "cluster" ]; then if pidof nginx &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop nginxd || : + ${csudo}systemctl stop nginxd || : elif ((${service_mod}==1)); then - ${csudo} service nginxd stop || : + ${csudo}service nginxd stop || : else kill_process nginx fi @@ -952,11 +952,13 @@ function update_TDengine() { #echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" echo echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" + echo -e "${GREEN_DARK}To configure Taos Adapter (if has) ${NC}: edit /etc/taos/taosadapter.toml" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}systemctl start taosd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}service taosd start${NC}" else + echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" fi @@ -1037,11 +1039,13 @@ function install_TDengine() { #echo -e "\033[44;32;1mTDengine is installed successfully!${NC}" echo echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" + echo -e "${GREEN_DARK}To configure taosadapter (if has) ${NC}: edit /etc/taos/taosadapter.toml" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}systemctl start taosd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}service taosd start${NC}" else + echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}" fi diff --git a/packaging/tools/install_arbi.sh b/packaging/tools/install_arbi.sh index 33896a08b3f653dbddc1ad480ddab3bf73a513ef..a582e0322aa025a69690a4041afd2fa24cc20a62 100755 --- a/packaging/tools/install_arbi.sh +++ b/packaging/tools/install_arbi.sh @@ -29,7 +29,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -91,85 +91,85 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/bin - #${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/bin + #${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/rmtarbitrator || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}rm -f ${bin_link_dir}/rmtarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/remove_arbi.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_arbi.sh ${bin_link_dir}/rmtarbitrator || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/remove_arbi.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_arbi.sh ${bin_link_dir}/rmtarbitrator || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -178,30 +178,30 @@ function install_jemalloc() { function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -212,24 +212,24 @@ function install_service_on_sysvinit() { # Install taosd service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" + #${csudo}grep -q -F "$restart_config_str" /etc/inittab || ${csudo}bash -c "echo '${restart_config_str}' >> /etc/inittab" if ((${initd_mod}==1)); then - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -237,11 +237,11 @@ function clean_service_on_systemd() { 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } # taos:2345:respawn:/etc/init.d/tarbitratord start @@ -251,27 +251,27 @@ function install_service_on_systemd() { tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - ${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + ${csudo}systemctl enable tarbitratord } function install_service() { @@ -291,9 +291,9 @@ function update_TDengine() { # Stop the service if running if pidof tarbitrator &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop tarbitratord || : + ${csudo}systemctl stop tarbitratord || : elif ((${service_mod}==1)); then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : else kill_tarbitrator fi @@ -309,9 +309,9 @@ function update_TDengine() { echo #echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}" fi @@ -332,9 +332,9 @@ function install_TDengine() { echo #echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}" fi diff --git a/packaging/tools/install_arbi_jh.sh b/packaging/tools/install_arbi_jh.sh index 2403f8fbd79abf4324577fe3dca3a8e0eac8ed01..3b0d050c2c1c395b197ed040ce20c86f512cad2b 100755 --- a/packaging/tools/install_arbi_jh.sh +++ b/packaging/tools/install_arbi_jh.sh @@ -29,7 +29,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -91,60 +91,60 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/bin - #${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/bin + #${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/rmtarbitrator || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}rm -f ${bin_link_dir}/rmtarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/remove_arbi_jh.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_arbi_jh.sh ${bin_link_dir}/rmtarbitrator || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/remove_arbi_jh.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_arbi_jh.sh ${bin_link_dir}/rmtarbitrator || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -154,21 +154,21 @@ function install_service_on_sysvinit() { # Install server service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -176,11 +176,11 @@ function clean_service_on_systemd() { 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function install_service_on_systemd() { @@ -188,27 +188,27 @@ function install_service_on_systemd() { tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=jh_iot arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - ${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=jh_iot arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + ${csudo}systemctl enable tarbitratord } function install_service() { @@ -227,9 +227,9 @@ function update() { # Stop the service if running if pidof tarbitrator &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop tarbitratord || : + ${csudo}systemctl stop tarbitratord || : elif ((${service_mod}==1)); then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : else kill_tarbitrator fi @@ -243,9 +243,9 @@ function update() { echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}" fi @@ -263,9 +263,9 @@ function install() { install_service echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}" fi diff --git a/packaging/tools/install_arbi_kh.sh b/packaging/tools/install_arbi_kh.sh index 9a2542936d935b70b762702f0f2f6ff92b51a4f3..3c95639d181b6796128315fc9afb8bfa586c6dc3 100755 --- a/packaging/tools/install_arbi_kh.sh +++ b/packaging/tools/install_arbi_kh.sh @@ -29,7 +29,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -91,60 +91,60 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/bin - #${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/bin + #${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/rmtarbitrator || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}rm -f ${bin_link_dir}/rmtarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/remove_arbi_kh.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_arbi_kh.sh ${bin_link_dir}/rmtarbitrator || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/remove_arbi_kh.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_arbi_kh.sh ${bin_link_dir}/rmtarbitrator || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -154,21 +154,21 @@ function install_service_on_sysvinit() { # Install khserver service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -176,11 +176,11 @@ function clean_service_on_systemd() { 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function install_service_on_systemd() { @@ -188,27 +188,27 @@ function install_service_on_systemd() { tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=KingHistorian arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - ${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=KingHistorian arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + ${csudo}systemctl enable tarbitratord } function install_service() { @@ -227,9 +227,9 @@ function update() { # Stop the service if running if pidof tarbitrator &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop tarbitratord || : + ${csudo}systemctl stop tarbitratord || : elif ((${service_mod}==1)); then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : else kill_tarbitrator fi @@ -243,9 +243,9 @@ function update() { echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}" fi @@ -263,9 +263,9 @@ function install() { install_service echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}" fi diff --git a/packaging/tools/install_arbi_power.sh b/packaging/tools/install_arbi_power.sh index 755684d1bdb1ea02781518e9a78ccf1d881fb271..94f1b7fc538874d8c03aa1ecffce4bee528e8c0c 100755 --- a/packaging/tools/install_arbi_power.sh +++ b/packaging/tools/install_arbi_power.sh @@ -29,7 +29,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -91,77 +91,77 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/bin - #${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/bin + #${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/rmtarbitrator || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}rm -f ${bin_link_dir}/rmtarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/remove_arbi_power.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_arbi_power.sh ${bin_link_dir}/rmtarbitrator || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/remove_arbi_power.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_arbi_power.sh ${bin_link_dir}/rmtarbitrator || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -169,36 +169,36 @@ function install_jemalloc() { } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -209,24 +209,24 @@ function install_service_on_sysvinit() { # Install powerd service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi #restart_config_str="power:2345:respawn:${service_config_dir}/powerd start" - #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" + #${csudo}grep -q -F "$restart_config_str" /etc/inittab || ${csudo}bash -c "echo '${restart_config_str}' >> /etc/inittab" if ((${initd_mod}==1)); then - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -234,11 +234,11 @@ function clean_service_on_systemd() { 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } # power:2345:respawn:/etc/init.d/tarbitratord start @@ -248,27 +248,27 @@ function install_service_on_systemd() { tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=PowerDB arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - ${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=PowerDB arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + ${csudo}systemctl enable tarbitratord } function install_service() { @@ -287,9 +287,9 @@ function update_PowerDB() { # Stop the service if running if pidof tarbitrator &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop tarbitratord || : + ${csudo}systemctl stop tarbitratord || : elif ((${service_mod}==1)); then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : else kill_tarbitrator fi @@ -304,9 +304,9 @@ function update_PowerDB() { echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}" fi @@ -326,9 +326,9 @@ function install_PowerDB() { echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}" fi diff --git a/packaging/tools/install_arbi_pro.sh b/packaging/tools/install_arbi_pro.sh index 3e80ad8215e3ec709c17a6a46e34f5bd6cf7ac6c..5c5fa485b8852ea87fdbd58cc76a6b4b6b4377de 100755 --- a/packaging/tools/install_arbi_pro.sh +++ b/packaging/tools/install_arbi_pro.sh @@ -29,7 +29,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -91,61 +91,61 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/bin - #${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/bin + #${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/rmtarbitrator || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}rm -f ${bin_link_dir}/rmtarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/remove_arbi_prodb.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_arbi_prodb.sh ${bin_link_dir}/rmtarbitrator || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/remove_arbi_prodb.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_arbi_prodb.sh ${bin_link_dir}/rmtarbitrator || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -156,21 +156,21 @@ function install_service_on_sysvinit() { # Install prodbs service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -178,11 +178,11 @@ function clean_service_on_systemd() { 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function install_service_on_systemd() { @@ -190,27 +190,27 @@ function install_service_on_systemd() { tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=ProDB arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - ${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=ProDB arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + ${csudo}systemctl enable tarbitratord } function install_service() { @@ -229,9 +229,9 @@ function update_prodb() { # Stop the service if running if pidof tarbitrator &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop tarbitratord || : + ${csudo}systemctl stop tarbitratord || : elif ((${service_mod}==1)); then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : else kill_tarbitrator fi @@ -245,9 +245,9 @@ function update_prodb() { echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}" fi @@ -265,9 +265,9 @@ function install_prodb() { install_service echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}" fi diff --git a/packaging/tools/install_arbi_tq.sh b/packaging/tools/install_arbi_tq.sh index 8757326605b05aca63a585d1c3e1c66c98f6aaa7..132346a749f1559436e6db244593c660dbd69556 100755 --- a/packaging/tools/install_arbi_tq.sh +++ b/packaging/tools/install_arbi_tq.sh @@ -29,7 +29,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -91,61 +91,61 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/bin - #${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/bin + #${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/rmtarbitrator || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}rm -f ${bin_link_dir}/rmtarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/remove_arbi_tq.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_arbi_tq.sh ${bin_link_dir}/rmtarbitrator || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/remove_arbi_tq.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_arbi_tq.sh ${bin_link_dir}/rmtarbitrator || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -156,24 +156,24 @@ function install_service_on_sysvinit() { # Install tqd service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi #restart_config_str="tq:2345:respawn:${service_config_dir}/tqd start" - #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" + #${csudo}grep -q -F "$restart_config_str" /etc/inittab || ${csudo}bash -c "echo '${restart_config_str}' >> /etc/inittab" if ((${initd_mod}==1)); then - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -181,11 +181,11 @@ function clean_service_on_systemd() { 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } # tq:2345:respawn:/etc/init.d/tarbitratord start @@ -195,27 +195,27 @@ function install_service_on_systemd() { tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=TQ arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - ${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=TQ arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + ${csudo}systemctl enable tarbitratord } function install_service() { @@ -234,9 +234,9 @@ function update_tq() { # Stop the service if running if pidof tarbitrator &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop tarbitratord || : + ${csudo}systemctl stop tarbitratord || : elif ((${service_mod}==1)); then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : else kill_tarbitrator fi @@ -250,9 +250,9 @@ function update_tq() { echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}" fi @@ -270,9 +270,9 @@ function install_tq() { install_service echo if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}systemctl start tarbitratord${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo}service tarbitratord start${NC}" else echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}" fi diff --git a/packaging/tools/install_client.sh b/packaging/tools/install_client.sh index a73f6ac9718064855a245c0505e179b6376d7c96..4ea60d1d55336d606f7eabf10b464cff90860519 100755 --- a/packaging/tools/install_client.sh +++ b/packaging/tools/install_client.sh @@ -57,7 +57,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -65,40 +65,40 @@ update_flag=0 function kill_client() { pid=$(ps -ef | grep "taos" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/taos || : + ${csudo}rm -f ${bin_link_dir}/taos || : if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : fi - ${csudo} rm -f ${bin_link_dir}/rmtaos || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/rmtaos || : + ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : + [ -x ${install_main_dir}/bin/taos ] && ${csudo}ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : fi - [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : } function clean_lib() { @@ -108,87 +108,87 @@ function clean_lib() { function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* if [ "$osType" != "Darwin" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [ -d "${lib64_link_dir}" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi else - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib - ${csudo} ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib + ${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib fi if [ "$osType" != "Darwin" ]; then - ${csudo} ldconfig + ${csudo}ldconfig else - ${csudo} update_dyld_shared_cache + ${csudo}update_dyld_shared_cache fi } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -196,37 +196,37 @@ function install_jemalloc() { } function install_config() { - #${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : + #${csudo}rm -f ${install_main_dir}/cfg/taos.cfg || : if [ ! -f ${cfg_install_dir}/taos.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo}cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org - ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org + ${csudo}ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg } function install_log() { - ${csudo} rm -rf ${log_dir} || : + ${csudo}rm -rf ${log_dir} || : if [ "$osType" != "Darwin" ]; then - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} else - mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} fi - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/ ${install_main_dir}/ + ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } diff --git a/packaging/tools/install_client_jh.sh b/packaging/tools/install_client_jh.sh index a8599812feaea06120aa3391771e7c94523a53c2..436b683b29b81e612ef15af6cf976f29b42347fc 100755 --- a/packaging/tools/install_client_jh.sh +++ b/packaging/tools/install_client_jh.sh @@ -54,7 +54,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -62,42 +62,42 @@ update_flag=0 function kill_client() { pid=$(ps -ef | grep "jh_taos" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/jh_taos || : + ${csudo}rm -f ${bin_link_dir}/jh_taos || : if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${bin_link_dir}/jhdemo || : - ${csudo} rm -f ${bin_link_dir}/jh_taosdump || : + ${csudo}rm -f ${bin_link_dir}/jhdemo || : + ${csudo}rm -f ${bin_link_dir}/jh_taosdump || : fi - ${csudo} rm -f ${bin_link_dir}/rmjh || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/rmjh || : + ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/jh_taos ] && ${csudo} ln -s ${install_main_dir}/bin/jh_taos ${bin_link_dir}/jh_taos || : + [ -x ${install_main_dir}/bin/jh_taos ] && ${csudo}ln -s ${install_main_dir}/bin/jh_taos ${bin_link_dir}/jh_taos || : if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/jhdemo ] && ${csudo} ln -s ${install_main_dir}/bin/jhdemo ${bin_link_dir}/jhdemo || : - [ -x ${install_main_dir}/bin/jh_taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/jh_taosdump ${bin_link_dir}/jh_taosdump || : + [ -x ${install_main_dir}/bin/jhdemo ] && ${csudo}ln -s ${install_main_dir}/bin/jhdemo ${bin_link_dir}/jhdemo || : + [ -x ${install_main_dir}/bin/jh_taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/jh_taosdump ${bin_link_dir}/jh_taosdump || : fi - [ -x ${install_main_dir}/bin/remove_client_jh.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client_jh.sh ${bin_link_dir}/rmjh || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/remove_client_jh.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client_jh.sh ${bin_link_dir}/rmjh || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : } function clean_lib() { @@ -107,64 +107,64 @@ function clean_lib() { function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* if [ "$osType" != "Darwin" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [ -d "${lib64_link_dir}" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi else - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib - ${csudo} ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib + ${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_config() { if [ ! -f ${cfg_install_dir}/taos.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo}cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org - ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org + ${csudo}ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg } function install_log() { - ${csudo} rm -rf ${log_dir} || : + ${csudo}rm -rf ${log_dir} || : if [ "$osType" != "Darwin" ]; then - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} else - mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} fi - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } diff --git a/packaging/tools/install_client_kh.sh b/packaging/tools/install_client_kh.sh index 3e7df18486a20b9ea75dba3d2644d46bee6b423b..0b8c0f5aeba96fff65907105ca571cf5955c6648 100755 --- a/packaging/tools/install_client_kh.sh +++ b/packaging/tools/install_client_kh.sh @@ -54,7 +54,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -62,42 +62,42 @@ update_flag=0 function kill_client() { pid=$(ps -ef | grep "khclient" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/khclient || : + ${csudo}rm -f ${bin_link_dir}/khclient || : if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${bin_link_dir}/khdemo || : - ${csudo} rm -f ${bin_link_dir}/khdump || : + ${csudo}rm -f ${bin_link_dir}/khdemo || : + ${csudo}rm -f ${bin_link_dir}/khdump || : fi - ${csudo} rm -f ${bin_link_dir}/rmkh || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/rmkh || : + ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/khclient ] && ${csudo} ln -s ${install_main_dir}/bin/khclient ${bin_link_dir}/khclient || : + [ -x ${install_main_dir}/bin/khclient ] && ${csudo}ln -s ${install_main_dir}/bin/khclient ${bin_link_dir}/khclient || : if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/khdemo ] && ${csudo} ln -s ${install_main_dir}/bin/khdemo ${bin_link_dir}/khdemo || : - [ -x ${install_main_dir}/bin/khdump ] && ${csudo} ln -s ${install_main_dir}/bin/khdump ${bin_link_dir}/khdump || : + [ -x ${install_main_dir}/bin/khdemo ] && ${csudo}ln -s ${install_main_dir}/bin/khdemo ${bin_link_dir}/khdemo || : + [ -x ${install_main_dir}/bin/khdump ] && ${csudo}ln -s ${install_main_dir}/bin/khdump ${bin_link_dir}/khdump || : fi - [ -x ${install_main_dir}/bin/remove_client_kh.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client_kh.sh ${bin_link_dir}/rmkh || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/remove_client_kh.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client_kh.sh ${bin_link_dir}/rmkh || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : } function clean_lib() { @@ -107,65 +107,65 @@ function clean_lib() { function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* if [ "$osType" != "Darwin" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [ -d "${lib64_link_dir}" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi else - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib - ${csudo} ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib + ${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_config() { if [ ! -f ${cfg_install_dir}/kinghistorian.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/kinghistorian.cfg ] && ${csudo} cp ${script_dir}/cfg/kinghistorian.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/kinghistorian.cfg ] && ${csudo}cp ${script_dir}/cfg/kinghistorian.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/kinghistorian.cfg ${install_main_dir}/cfg/kinghistorian.cfg.org - ${csudo} ln -s ${cfg_install_dir}/kinghistorian.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/kinghistorian.cfg ${install_main_dir}/cfg/kinghistorian.cfg.org + ${csudo}ln -s ${cfg_install_dir}/kinghistorian.cfg ${install_main_dir}/cfg } function install_log() { - ${csudo} rm -rf ${log_dir} || : + ${csudo}rm -rf ${log_dir} || : if [ "$osType" != "Darwin" ]; then - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} else - mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} fi - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } diff --git a/packaging/tools/install_client_power.sh b/packaging/tools/install_client_power.sh index 3c9abddb09646ea54f44e28664afea49822055f6..4e7ee96a6255bd74862a509206ef6aff69320916 100755 --- a/packaging/tools/install_client_power.sh +++ b/packaging/tools/install_client_power.sh @@ -57,7 +57,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -65,42 +65,42 @@ update_flag=0 function kill_client() { pid=$(ps -ef | grep "power" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/power || : + ${csudo}rm -f ${bin_link_dir}/power || : if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${bin_link_dir}/powerdemo || : - ${csudo} rm -f ${bin_link_dir}/powerdump || : + ${csudo}rm -f ${bin_link_dir}/powerdemo || : + ${csudo}rm -f ${bin_link_dir}/powerdump || : fi - ${csudo} rm -f ${bin_link_dir}/rmpower || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/rmpower || : + ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/power ] && ${csudo} ln -s ${install_main_dir}/bin/power ${bin_link_dir}/power || : + [ -x ${install_main_dir}/bin/power ] && ${csudo}ln -s ${install_main_dir}/bin/power ${bin_link_dir}/power || : if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/powerdemo ] && ${csudo} ln -s ${install_main_dir}/bin/powerdemo ${bin_link_dir}/powerdemo || : - [ -x ${install_main_dir}/bin/powerdump ] && ${csudo} ln -s ${install_main_dir}/bin/powerdump ${bin_link_dir}/powerdump || : + [ -x ${install_main_dir}/bin/powerdemo ] && ${csudo}ln -s ${install_main_dir}/bin/powerdemo ${bin_link_dir}/powerdemo || : + [ -x ${install_main_dir}/bin/powerdump ] && ${csudo}ln -s ${install_main_dir}/bin/powerdump ${bin_link_dir}/powerdump || : fi - [ -x ${install_main_dir}/bin/remove_client_power.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client_power.sh ${bin_link_dir}/rmpower || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/remove_client_power.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client_power.sh ${bin_link_dir}/rmpower || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : } function clean_lib() { @@ -110,83 +110,83 @@ function clean_lib() { function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* if [ "$osType" != "Darwin" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [ -d "${lib64_link_dir}" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi else - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib - ${csudo} ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib + ${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -195,34 +195,34 @@ function install_jemalloc() { function install_config() { if [ ! -f ${cfg_install_dir}/power.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/power.cfg ] && ${csudo} cp ${script_dir}/cfg/power.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/power.cfg ] && ${csudo}cp ${script_dir}/cfg/power.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/power.cfg ${install_main_dir}/cfg/power.cfg.org - ${csudo} ln -s ${cfg_install_dir}/power.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/power.cfg ${install_main_dir}/cfg/power.cfg.org + ${csudo}ln -s ${cfg_install_dir}/power.cfg ${install_main_dir}/cfg } function install_log() { - ${csudo} rm -rf ${log_dir} || : + ${csudo}rm -rf ${log_dir} || : if [ "$osType" != "Darwin" ]; then - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} else - mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} fi - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } diff --git a/packaging/tools/install_client_pro.sh b/packaging/tools/install_client_pro.sh index e34dc6d4ac1d1ef1715ff903b38b1a8735001985..7551484e56c8d5fc59539d26f52ac7d318106fa5 100755 --- a/packaging/tools/install_client_pro.sh +++ b/packaging/tools/install_client_pro.sh @@ -54,7 +54,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -62,42 +62,42 @@ update_flag=0 function kill_client() { pid=$(ps -ef | grep "prodbc" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/prodbc || : + ${csudo}rm -f ${bin_link_dir}/prodbc || : if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${bin_link_dir}/prodemo || : - ${csudo} rm -f ${bin_link_dir}/prodump || : + ${csudo}rm -f ${bin_link_dir}/prodemo || : + ${csudo}rm -f ${bin_link_dir}/prodump || : fi - ${csudo} rm -f ${bin_link_dir}/rmprodb || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/rmprodb || : + ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/prodbc ] && ${csudo} ln -s ${install_main_dir}/bin/prodbc ${bin_link_dir}/prodbc || : + [ -x ${install_main_dir}/bin/prodbc ] && ${csudo}ln -s ${install_main_dir}/bin/prodbc ${bin_link_dir}/prodbc || : if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/prodemo ] && ${csudo} ln -s ${install_main_dir}/bin/prodemo ${bin_link_dir}/prodemo || : - [ -x ${install_main_dir}/bin/prodump ] && ${csudo} ln -s ${install_main_dir}/bin/prodump ${bin_link_dir}/prodump || : + [ -x ${install_main_dir}/bin/prodemo ] && ${csudo}ln -s ${install_main_dir}/bin/prodemo ${bin_link_dir}/prodemo || : + [ -x ${install_main_dir}/bin/prodump ] && ${csudo}ln -s ${install_main_dir}/bin/prodump ${bin_link_dir}/prodump || : fi - [ -x ${install_main_dir}/bin/remove_client_prodb.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client_prodb.sh ${bin_link_dir}/rmprodb || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/remove_client_prodb.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client_prodb.sh ${bin_link_dir}/rmprodb || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : } function clean_lib() { @@ -107,65 +107,65 @@ function clean_lib() { function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* if [ "$osType" != "Darwin" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [ -d "${lib64_link_dir}" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi else - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib - ${csudo} ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib + ${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_config() { if [ ! -f ${cfg_install_dir}/prodb.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/prodb.cfg ] && ${csudo} cp ${script_dir}/cfg/prodb.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/prodb.cfg ] && ${csudo}cp ${script_dir}/cfg/prodb.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/prodb.cfg ${install_main_dir}/cfg/prodb.cfg.org - ${csudo} ln -s ${cfg_install_dir}/prodb.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/prodb.cfg ${install_main_dir}/cfg/prodb.cfg.org + ${csudo}ln -s ${cfg_install_dir}/prodb.cfg ${install_main_dir}/cfg } function install_log() { - ${csudo} rm -rf ${log_dir} || : + ${csudo}rm -rf ${log_dir} || : if [ "$osType" != "Darwin" ]; then - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} else - mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} fi - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } diff --git a/packaging/tools/install_client_tq.sh b/packaging/tools/install_client_tq.sh index b7f10324dcd1c62fee20fe11399fbb61d8a38577..04479cfdbe234fe323a43a6a521992838069ecd9 100755 --- a/packaging/tools/install_client_tq.sh +++ b/packaging/tools/install_client_tq.sh @@ -57,7 +57,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -65,42 +65,42 @@ update_flag=0 function kill_client() { pid=$(ps -ef | grep "tq" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/tq || : + ${csudo}rm -f ${bin_link_dir}/tq || : if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${bin_link_dir}/tqdemo || : - ${csudo} rm -f ${bin_link_dir}/tqdump || : + ${csudo}rm -f ${bin_link_dir}/tqdemo || : + ${csudo}rm -f ${bin_link_dir}/tqdump || : fi - ${csudo} rm -f ${bin_link_dir}/rmtq || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/rmtq || : + ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/tq ] && ${csudo} ln -s ${install_main_dir}/bin/tq ${bin_link_dir}/tq || : + [ -x ${install_main_dir}/bin/tq ] && ${csudo}ln -s ${install_main_dir}/bin/tq ${bin_link_dir}/tq || : if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/tqdemo ] && ${csudo} ln -s ${install_main_dir}/bin/tqdemo ${bin_link_dir}/tqdemo || : - [ -x ${install_main_dir}/bin/tqdump ] && ${csudo} ln -s ${install_main_dir}/bin/tqdump ${bin_link_dir}/tqdump || : + [ -x ${install_main_dir}/bin/tqdemo ] && ${csudo}ln -s ${install_main_dir}/bin/tqdemo ${bin_link_dir}/tqdemo || : + [ -x ${install_main_dir}/bin/tqdump ] && ${csudo}ln -s ${install_main_dir}/bin/tqdump ${bin_link_dir}/tqdump || : fi - [ -x ${install_main_dir}/bin/remove_client_tq.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client_tq.sh ${bin_link_dir}/rmtq || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/remove_client_tq.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client_tq.sh ${bin_link_dir}/rmtq || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : } function clean_lib() { @@ -110,66 +110,66 @@ function clean_lib() { function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* if [ "$osType" != "Darwin" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [ -d "${lib64_link_dir}" ]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi else - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib - ${csudo} ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib + ${csudo}ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_config() { if [ ! -f ${cfg_install_dir}/tq.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/tq.cfg ] && ${csudo} cp ${script_dir}/cfg/tq.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/tq.cfg ] && ${csudo}cp ${script_dir}/cfg/tq.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/tq.cfg ${install_main_dir}/cfg/tq.cfg.org - ${csudo} ln -s ${cfg_install_dir}/tq.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/tq.cfg ${install_main_dir}/cfg/tq.cfg.org + ${csudo}ln -s ${cfg_install_dir}/tq.cfg ${install_main_dir}/cfg } function install_log() { - ${csudo} rm -rf ${log_dir} || : + ${csudo}rm -rf ${log_dir} || : if [ "$osType" != "Darwin" ]; then - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} else - mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} fi - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } diff --git a/packaging/tools/install_jh.sh b/packaging/tools/install_jh.sh index ecc166fba10ef4c3f8e0bacc04ff27ebf717e409..667766154e92004b3eea695b08f0fc43872cbd2e 100755 --- a/packaging/tools/install_jh.sh +++ b/packaging/tools/install_jh.sh @@ -46,7 +46,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -144,129 +144,129 @@ done function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin -# ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver -# ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin +# ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver +# ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then - ${csudo} mkdir -p ${nginx_dir} + ${csudo}mkdir -p ${nginx_dir} fi } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/jh_taos || : - ${csudo} rm -f ${bin_link_dir}/jh_taosd || : - ${csudo} rm -f ${bin_link_dir}/jhdemo || : - ${csudo} rm -f ${bin_link_dir}/rmjh || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/jh_taos || : + ${csudo}rm -f ${bin_link_dir}/jh_taosd || : + ${csudo}rm -f ${bin_link_dir}/jhdemo || : + ${csudo}rm -f ${bin_link_dir}/rmjh || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/jh_taos ] && ${csudo} ln -s ${install_main_dir}/bin/jh_taos ${bin_link_dir}/jh_taos || : - [ -x ${install_main_dir}/bin/jh_taosd ] && ${csudo} ln -s ${install_main_dir}/bin/jh_taosd ${bin_link_dir}/jh_taosd || : - [ -x ${install_main_dir}/bin/jhdemo ] && ${csudo} ln -s ${install_main_dir}/bin/jhdemo ${bin_link_dir}/jhdemo || : - [ -x ${install_main_dir}/bin/remove_jh.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_jh.sh ${bin_link_dir}/rmjh || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo} ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/jh_taos ] && ${csudo}ln -s ${install_main_dir}/bin/jh_taos ${bin_link_dir}/jh_taos || : + [ -x ${install_main_dir}/bin/jh_taosd ] && ${csudo}ln -s ${install_main_dir}/bin/jh_taosd ${bin_link_dir}/jh_taosd || : + [ -x ${install_main_dir}/bin/jhdemo ] && ${csudo}ln -s ${install_main_dir}/bin/jhdemo ${bin_link_dir}/jhdemo || : + [ -x ${install_main_dir}/bin/remove_jh.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_jh.sh ${bin_link_dir}/rmjh || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then - ${csudo} cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo} chmod 0555 ${nginx_dir}/* - ${csudo} mkdir -p ${nginx_dir}/logs - ${csudo} chmod 777 ${nginx_dir}/sbin/nginx + ${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/* + ${csudo}mkdir -p ${nginx_dir}/logs + ${csudo}chmod 777 ${nginx_dir}/sbin/nginx fi } function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi if [ "$osType" != "Darwin" ]; then - ${csudo} ldconfig + ${csudo}ldconfig else - ${csudo} update_dyld_shared_cache + ${csudo}update_dyld_shared_cache fi } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -286,7 +286,7 @@ function add_newHostname_to_hosts() { return fi done - ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: + ${csudo}echo "127.0.0.1 $1" >> /etc/hosts ||: } function set_hostname() { @@ -300,7 +300,7 @@ function set_hostname() { fi done - ${csudo} hostname $newHostname ||: + ${csudo}hostname $newHostname ||: retval=`echo $?` if [[ $retval != 0 ]]; then echo @@ -310,15 +310,15 @@ function set_hostname() { #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then - ${csudo} echo $newHostname > /etc/hostname ||: + ${csudo}echo $newHostname > /etc/hostname ||: fi #debian: #HOSTNAME=yourname if [[ -e /etc/sysconfig/network ]]; then - ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: + ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: fi - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -353,7 +353,7 @@ 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 - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg serverFqdn=$localFqdn echo return @@ -375,7 +375,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg serverFqdn=$localFqdn break fi @@ -423,13 +423,13 @@ function local_fqdn_check() { function install_config() { if [ ! -f ${cfg_install_dir}/taos.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo}cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org - ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org + ${csudo}ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg [ ! -z $1 ] && return 0 || : # only install client @@ -459,7 +459,7 @@ function install_config() { # check the format of the firstEp #if [[ $firstEp == $FQDN_PATTERN ]]; then # Write the first FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg break #else # read -p "Please enter the correct FQDN:port: " firstEp @@ -472,66 +472,66 @@ function install_config() { function install_log() { - ${csudo} rm -rf ${log_dir} || : - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}rm -rf ${log_dir} || : + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_data() { - ${csudo} mkdir -p ${data_dir} + ${csudo}mkdir -p ${data_dir} - ${csudo} ln -s ${data_dir} ${install_main_dir}/data + ${csudo}ln -s ${data_dir} ${install_main_dir}/data } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } function clean_service_on_sysvinit() { if pidof jh_taosd &> /dev/null; then - ${csudo} service jh_taosd stop || : + ${csudo}service jh_taosd stop || : fi if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/jh_taosd ]; then - ${csudo} chkconfig --del jh_taosd || : + ${csudo}chkconfig --del jh_taosd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/jh_taosd ]; then - ${csudo} insserv -r jh_taosd || : + ${csudo}insserv -r jh_taosd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/jh_taosd ]; then - ${csudo} update-rc.d -f jh_taosd remove || : + ${csudo}update-rc.d -f jh_taosd remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/jh_taosd || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/jh_taosd || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -542,30 +542,30 @@ function install_service_on_sysvinit() { # Install jh_taosd service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/jh_taosd.deb ${install_main_dir}/init.d/jh_taosd - ${csudo} cp ${script_dir}/init.d/jh_taosd.deb ${service_config_dir}/jh_taosd && ${csudo} chmod a+x ${service_config_dir}/jh_taosd - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/jh_taosd.deb ${install_main_dir}/init.d/jh_taosd + ${csudo}cp ${script_dir}/init.d/jh_taosd.deb ${service_config_dir}/jh_taosd && ${csudo}chmod a+x ${service_config_dir}/jh_taosd + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/jh_taosd.rpm ${install_main_dir}/init.d/jh_taosd - ${csudo} cp ${script_dir}/init.d/jh_taosd.rpm ${service_config_dir}/jh_taosd && ${csudo} chmod a+x ${service_config_dir}/jh_taosd - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/jh_taosd.rpm ${install_main_dir}/init.d/jh_taosd + ${csudo}cp ${script_dir}/init.d/jh_taosd.rpm ${service_config_dir}/jh_taosd && ${csudo}chmod a+x ${service_config_dir}/jh_taosd + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --add jh_taosd || : - ${csudo} chkconfig --level 2345 jh_taosd on || : - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add jh_taosd || : + ${csudo}chkconfig --level 2345 jh_taosd on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv jh_taosd || : - ${csudo} insserv -d jh_taosd || : - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv jh_taosd || : + ${csudo}insserv -d jh_taosd || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d jh_taosd defaults || : - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d jh_taosd defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -573,27 +573,27 @@ function clean_service_on_systemd() { jh_taosd_service_config="${service_config_dir}/jh_taosd.service" if systemctl is-active --quiet jh_taosd; then echo "jh_iot is running, stopping it..." - ${csudo} systemctl stop jh_taosd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop jh_taosd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable jh_taosd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${jh_taosd_service_config} + ${csudo}systemctl disable jh_taosd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${jh_taosd_service_config} 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" if systemctl is-active --quiet nginxd; then echo "Nginx for jh_iot is running, stopping it..." - ${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop nginxd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}systemctl disable nginxd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${nginx_service_config} fi } @@ -601,81 +601,81 @@ function install_service_on_systemd() { clean_service_on_systemd service_config="${service_config_dir}/jh_taosd.service" - ${csudo} bash -c "echo '[Unit]' >> ${service_config}" - ${csudo} bash -c "echo 'Description=jh_iot server service' >> ${service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${service_config}" - ${csudo} bash -c "echo >> ${service_config}" - ${csudo} bash -c "echo '[Service]' >> ${service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/jh_taosd' >> ${service_config}" - ${csudo} bash -c "echo 'ExecStartPre=/usr/local/jh_taos/bin/startPre.sh' >> ${service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${service_config}" - ${csudo} bash -c "echo >> ${service_config}" - ${csudo} bash -c "echo '[Install]' >> ${service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${service_config}" - ${csudo} systemctl enable jh_taosd + ${csudo}bash -c "echo '[Unit]' >> ${service_config}" + ${csudo}bash -c "echo 'Description=jh_iot server service' >> ${service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${service_config}" + ${csudo}bash -c "echo >> ${service_config}" + ${csudo}bash -c "echo '[Service]' >> ${service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/jh_taosd' >> ${service_config}" + ${csudo}bash -c "echo 'ExecStartPre=/usr/local/jh_taos/bin/startPre.sh' >> ${service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${service_config}" + ${csudo}bash -c "echo >> ${service_config}" + ${csudo}bash -c "echo '[Install]' >> ${service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${service_config}" + ${csudo}systemctl enable jh_taosd tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=jh_iot arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - #${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=jh_iot arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + #${csudo}systemctl enable tarbitratord if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" - ${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Description=Nginx For jh_iot Service' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Type=forking' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" - if ! ${csudo} systemctl enable nginxd &> /dev/null; then - ${csudo} systemctl daemon-reexec - ${csudo} systemctl enable nginxd + ${csudo}bash -c "echo '[Unit]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Description=Nginx For jh_iot Service' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Type=forking' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" + if ! ${csudo}systemctl enable nginxd &> /dev/null; then + ${csudo}systemctl daemon-reexec + ${csudo}systemctl enable nginxd fi - ${csudo} systemctl start nginxd + ${csudo}systemctl start nginxd fi } @@ -755,9 +755,9 @@ function update() { # Stop the service if running if pidof jh_taosd &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop jh_taosd || : + ${csudo}systemctl stop jh_taosd || : elif ((${service_mod}==1)); then - ${csudo} service jh_taosd stop || : + ${csudo}service jh_taosd stop || : else kill_process jh_taosd fi @@ -766,9 +766,9 @@ function update() { if [ "$verMode" == "cluster" ]; then if pidof nginx &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop nginxd || : + ${csudo}systemctl stop nginxd || : elif ((${service_mod}==1)); then - ${csudo} service nginxd stop || : + ${csudo}service nginxd stop || : else kill_process nginx fi @@ -809,9 +809,9 @@ function update() { echo echo -e "${GREEN_DARK}To configure jh_iot ${NC}: edit /etc/jh_taos/taos.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start jh_iot ${NC}: ${csudo} systemctl start jh_taosd${NC}" + echo -e "${GREEN_DARK}To start jh_iot ${NC}: ${csudo}systemctl start jh_taosd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start jh_iot ${NC}: ${csudo} service jh_taosd start${NC}" + echo -e "${GREEN_DARK}To start jh_iot ${NC}: ${csudo}service jh_taosd start${NC}" else echo -e "${GREEN_DARK}To start jh_iot ${NC}: ./jh_taosd${NC}" fi @@ -886,9 +886,9 @@ function install() { echo echo -e "${GREEN_DARK}To configure jh_iot ${NC}: edit /etc/jh_taos/taos.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start jh_iot ${NC}: ${csudo} systemctl start jh_taosd${NC}" + echo -e "${GREEN_DARK}To start jh_iot ${NC}: ${csudo}systemctl start jh_taosd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start jh_iot ${NC}: ${csudo} service jh_taosd start${NC}" + echo -e "${GREEN_DARK}To start jh_iot ${NC}: ${csudo}service jh_taosd start${NC}" else echo -e "${GREEN_DARK}To start jh_iot ${NC}: jh_taosd${NC}" fi diff --git a/packaging/tools/install_kh.sh b/packaging/tools/install_kh.sh index e53e014351ff9ae64e727151c72f3157a2077043..8adad4dbbe32c6e052721f8657425b19d7338c4e 100755 --- a/packaging/tools/install_kh.sh +++ b/packaging/tools/install_kh.sh @@ -46,7 +46,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -144,129 +144,129 @@ done function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin -# ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver -# ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin +# ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver +# ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then - ${csudo} mkdir -p ${nginx_dir} + ${csudo}mkdir -p ${nginx_dir} fi } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/khclient || : - ${csudo} rm -f ${bin_link_dir}/khserver || : - ${csudo} rm -f ${bin_link_dir}/khdemo || : - ${csudo} rm -f ${bin_link_dir}/rmkh || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/khclient || : + ${csudo}rm -f ${bin_link_dir}/khserver || : + ${csudo}rm -f ${bin_link_dir}/khdemo || : + ${csudo}rm -f ${bin_link_dir}/rmkh || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/khclient ] && ${csudo} ln -s ${install_main_dir}/bin/khclient ${bin_link_dir}/khclient || : - [ -x ${install_main_dir}/bin/khserver ] && ${csudo} ln -s ${install_main_dir}/bin/khserver ${bin_link_dir}/khserver || : - [ -x ${install_main_dir}/bin/khdemo ] && ${csudo} ln -s ${install_main_dir}/bin/khdemo ${bin_link_dir}/khdemo || : - [ -x ${install_main_dir}/bin/remove_kh.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_kh.sh ${bin_link_dir}/rmkh || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo} ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/khclient ] && ${csudo}ln -s ${install_main_dir}/bin/khclient ${bin_link_dir}/khclient || : + [ -x ${install_main_dir}/bin/khserver ] && ${csudo}ln -s ${install_main_dir}/bin/khserver ${bin_link_dir}/khserver || : + [ -x ${install_main_dir}/bin/khdemo ] && ${csudo}ln -s ${install_main_dir}/bin/khdemo ${bin_link_dir}/khdemo || : + [ -x ${install_main_dir}/bin/remove_kh.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_kh.sh ${bin_link_dir}/rmkh || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then - ${csudo} cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo} chmod 0555 ${nginx_dir}/* - ${csudo} mkdir -p ${nginx_dir}/logs - ${csudo} chmod 777 ${nginx_dir}/sbin/nginx + ${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/* + ${csudo}mkdir -p ${nginx_dir}/logs + ${csudo}chmod 777 ${nginx_dir}/sbin/nginx fi } function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi if [ "$osType" != "Darwin" ]; then - ${csudo} ldconfig + ${csudo}ldconfig else - ${csudo} update_dyld_shared_cache + ${csudo}update_dyld_shared_cache fi } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -286,7 +286,7 @@ function add_newHostname_to_hosts() { return fi done - ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: + ${csudo}echo "127.0.0.1 $1" >> /etc/hosts ||: } function set_hostname() { @@ -300,7 +300,7 @@ function set_hostname() { fi done - ${csudo} hostname $newHostname ||: + ${csudo}hostname $newHostname ||: retval=`echo $?` if [[ $retval != 0 ]]; then echo @@ -310,15 +310,15 @@ function set_hostname() { #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then - ${csudo} echo $newHostname > /etc/hostname ||: + ${csudo}echo $newHostname > /etc/hostname ||: fi #debian: #HOSTNAME=yourname if [[ -e /etc/sysconfig/network ]]; then - ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: + ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: fi - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/kinghistorian.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/kinghistorian.cfg serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -353,7 +353,7 @@ 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 - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/kinghistorian.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/kinghistorian.cfg serverFqdn=$localFqdn echo return @@ -375,7 +375,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/kinghistorian.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/kinghistorian.cfg serverFqdn=$localFqdn break fi @@ -423,13 +423,13 @@ function local_fqdn_check() { function install_config() { if [ ! -f ${cfg_install_dir}/kinghistorian.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/kinghistorian.cfg ] && ${csudo} cp ${script_dir}/cfg/kinghistorian.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/kinghistorian.cfg ] && ${csudo}cp ${script_dir}/cfg/kinghistorian.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/kinghistorian.cfg ${install_main_dir}/cfg/kinghistorian.cfg.org - ${csudo} ln -s ${cfg_install_dir}/kinghistorian.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/kinghistorian.cfg ${install_main_dir}/cfg/kinghistorian.cfg.org + ${csudo}ln -s ${cfg_install_dir}/kinghistorian.cfg ${install_main_dir}/cfg [ ! -z $1 ] && return 0 || : # only install client @@ -459,7 +459,7 @@ function install_config() { # check the format of the firstEp #if [[ $firstEp == $FQDN_PATTERN ]]; then # Write the first FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/kinghistorian.cfg + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/kinghistorian.cfg break #else # read -p "Please enter the correct FQDN:port: " firstEp @@ -472,66 +472,66 @@ function install_config() { function install_log() { - ${csudo} rm -rf ${log_dir} || : - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}rm -rf ${log_dir} || : + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_data() { - ${csudo} mkdir -p ${data_dir} + ${csudo}mkdir -p ${data_dir} - ${csudo} ln -s ${data_dir} ${install_main_dir}/data + ${csudo}ln -s ${data_dir} ${install_main_dir}/data } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } function clean_service_on_sysvinit() { if pidof khserver &> /dev/null; then - ${csudo} service khserver stop || : + ${csudo}service khserver stop || : fi if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/khserver ]; then - ${csudo} chkconfig --del khserver || : + ${csudo}chkconfig --del khserver || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/khserver ]; then - ${csudo} insserv -r khserver || : + ${csudo}insserv -r khserver || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/khserver ]; then - ${csudo} update-rc.d -f khserver remove || : + ${csudo}update-rc.d -f khserver remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/khserver || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/khserver || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -542,30 +542,30 @@ function install_service_on_sysvinit() { # Install khserver service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/khserver.deb ${install_main_dir}/init.d/khserver - ${csudo} cp ${script_dir}/init.d/khserver.deb ${service_config_dir}/khserver && ${csudo} chmod a+x ${service_config_dir}/khserver - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/khserver.deb ${install_main_dir}/init.d/khserver + ${csudo}cp ${script_dir}/init.d/khserver.deb ${service_config_dir}/khserver && ${csudo}chmod a+x ${service_config_dir}/khserver + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/khserver.rpm ${install_main_dir}/init.d/khserver - ${csudo} cp ${script_dir}/init.d/khserver.rpm ${service_config_dir}/khserver && ${csudo} chmod a+x ${service_config_dir}/khserver - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/khserver.rpm ${install_main_dir}/init.d/khserver + ${csudo}cp ${script_dir}/init.d/khserver.rpm ${service_config_dir}/khserver && ${csudo}chmod a+x ${service_config_dir}/khserver + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --add khserver || : - ${csudo} chkconfig --level 2345 khserver on || : - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add khserver || : + ${csudo}chkconfig --level 2345 khserver on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv khserver || : - ${csudo} insserv -d khserver || : - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv khserver || : + ${csudo}insserv -d khserver || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d khserver defaults || : - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d khserver defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -573,27 +573,27 @@ function clean_service_on_systemd() { khserver_service_config="${service_config_dir}/khserver.service" if systemctl is-active --quiet khserver; then echo "KingHistorian is running, stopping it..." - ${csudo} systemctl stop khserver &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop khserver &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable khserver &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${khserver_service_config} + ${csudo}systemctl disable khserver &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${khserver_service_config} 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" if systemctl is-active --quiet nginxd; then echo "Nginx for KingHistorian is running, stopping it..." - ${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop nginxd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}systemctl disable nginxd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${nginx_service_config} fi } @@ -601,81 +601,81 @@ function install_service_on_systemd() { clean_service_on_systemd service_config="${service_config_dir}/khserver.service" - ${csudo} bash -c "echo '[Unit]' >> ${service_config}" - ${csudo} bash -c "echo 'Description=KingHistorian server service' >> ${service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${service_config}" - ${csudo} bash -c "echo >> ${service_config}" - ${csudo} bash -c "echo '[Service]' >> ${service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/khserver' >> ${service_config}" - ${csudo} bash -c "echo 'ExecStartPre=/usr/local/kinghistorian/bin/startPre.sh' >> ${service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${service_config}" - ${csudo} bash -c "echo >> ${service_config}" - ${csudo} bash -c "echo '[Install]' >> ${service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${service_config}" - ${csudo} systemctl enable khserver + ${csudo}bash -c "echo '[Unit]' >> ${service_config}" + ${csudo}bash -c "echo 'Description=KingHistorian server service' >> ${service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${service_config}" + ${csudo}bash -c "echo >> ${service_config}" + ${csudo}bash -c "echo '[Service]' >> ${service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/khserver' >> ${service_config}" + ${csudo}bash -c "echo 'ExecStartPre=/usr/local/kinghistorian/bin/startPre.sh' >> ${service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${service_config}" + ${csudo}bash -c "echo >> ${service_config}" + ${csudo}bash -c "echo '[Install]' >> ${service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${service_config}" + ${csudo}systemctl enable khserver tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=KingHistorian arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - #${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=KingHistorian arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + #${csudo}systemctl enable tarbitratord if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" - ${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Description=Nginx For KingHistorian Service' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Type=forking' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" - if ! ${csudo} systemctl enable nginxd &> /dev/null; then - ${csudo} systemctl daemon-reexec - ${csudo} systemctl enable nginxd + ${csudo}bash -c "echo '[Unit]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Description=Nginx For KingHistorian Service' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Type=forking' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" + if ! ${csudo}systemctl enable nginxd &> /dev/null; then + ${csudo}systemctl daemon-reexec + ${csudo}systemctl enable nginxd fi - ${csudo} systemctl start nginxd + ${csudo}systemctl start nginxd fi } @@ -755,9 +755,9 @@ function update() { # Stop the service if running if pidof khserver &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop khserver || : + ${csudo}systemctl stop khserver || : elif ((${service_mod}==1)); then - ${csudo} service khserver stop || : + ${csudo}service khserver stop || : else kill_process khserver fi @@ -766,9 +766,9 @@ function update() { if [ "$verMode" == "cluster" ]; then if pidof nginx &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop nginxd || : + ${csudo}systemctl stop nginxd || : elif ((${service_mod}==1)); then - ${csudo} service nginxd stop || : + ${csudo}service nginxd stop || : else kill_process nginx fi @@ -809,9 +809,9 @@ function update() { echo echo -e "${GREEN_DARK}To configure KingHistorian ${NC}: edit /etc/kinghistorian/kinghistorian.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ${csudo} systemctl start khserver${NC}" + echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ${csudo}systemctl start khserver${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ${csudo} service khserver start${NC}" + echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ${csudo}service khserver start${NC}" else echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ./khserver${NC}" fi @@ -886,9 +886,9 @@ function install() { echo echo -e "${GREEN_DARK}To configure KingHistorian ${NC}: edit /etc/kinghistorian/kinghistorian.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ${csudo} systemctl start khserver${NC}" + echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ${csudo}systemctl start khserver${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ${csudo} service khserver start${NC}" + echo -e "${GREEN_DARK}To start KingHistorian ${NC}: ${csudo}service khserver start${NC}" else echo -e "${GREEN_DARK}To start KingHistorian ${NC}: khserver${NC}" fi diff --git a/packaging/tools/install_power.sh b/packaging/tools/install_power.sh index cde33f9b368041d7072bc851d54b68e30a067a95..705c86432569c3e59145f8d887e55b78b111a4a8 100755 --- a/packaging/tools/install_power.sh +++ b/packaging/tools/install_power.sh @@ -49,7 +49,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -149,119 +149,119 @@ done function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then - ${csudo} mkdir -p ${nginx_dir} + ${csudo}mkdir -p ${nginx_dir} fi } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/power || : - ${csudo} rm -f ${bin_link_dir}/powerd || : - ${csudo} rm -f ${bin_link_dir}/powerdemo || : - ${csudo} rm -f ${bin_link_dir}/rmpower || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/power || : + ${csudo}rm -f ${bin_link_dir}/powerd || : + ${csudo}rm -f ${bin_link_dir}/powerdemo || : + ${csudo}rm -f ${bin_link_dir}/rmpower || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/power ] && ${csudo} ln -s ${install_main_dir}/bin/power ${bin_link_dir}/power || : - [ -x ${install_main_dir}/bin/powerd ] && ${csudo} ln -s ${install_main_dir}/bin/powerd ${bin_link_dir}/powerd || : - [ -x ${install_main_dir}/bin/powerdemo ] && ${csudo} ln -s ${install_main_dir}/bin/powerdemo ${bin_link_dir}/powerdemo || : - [ -x ${install_main_dir}/bin/remove_power.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_power.sh ${bin_link_dir}/rmpower || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo} ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/power ] && ${csudo}ln -s ${install_main_dir}/bin/power ${bin_link_dir}/power || : + [ -x ${install_main_dir}/bin/powerd ] && ${csudo}ln -s ${install_main_dir}/bin/powerd ${bin_link_dir}/powerd || : + [ -x ${install_main_dir}/bin/powerdemo ] && ${csudo}ln -s ${install_main_dir}/bin/powerdemo ${bin_link_dir}/powerdemo || : + [ -x ${install_main_dir}/bin/remove_power.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_power.sh ${bin_link_dir}/rmpower || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then - ${csudo} cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo} chmod 0555 ${nginx_dir}/* - ${csudo} mkdir -p ${nginx_dir}/logs - ${csudo} chmod 777 ${nginx_dir}/sbin/nginx + ${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/* + ${csudo}mkdir -p ${nginx_dir}/logs + ${csudo}chmod 777 ${nginx_dir}/sbin/nginx fi } function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -269,11 +269,11 @@ function install_jemalloc() { } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function add_newHostname_to_hosts() { @@ -289,7 +289,7 @@ function add_newHostname_to_hosts() { return fi done - ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: + ${csudo}echo "127.0.0.1 $1" >> /etc/hosts ||: } function set_hostname() { @@ -303,7 +303,7 @@ function set_hostname() { fi done - ${csudo} hostname $newHostname ||: + ${csudo}hostname $newHostname ||: retval=`echo $?` if [[ $retval != 0 ]]; then echo @@ -316,15 +316,15 @@ function set_hostname() { #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then - ${csudo} echo $newHostname > /etc/hostname ||: + ${csudo}echo $newHostname > /etc/hostname ||: fi #debian: #HOSTNAME=yourname if [[ -e /etc/sysconfig/network ]]; then - ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: + ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: fi - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/power.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/power.cfg serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -359,7 +359,7 @@ 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 - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/power.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/power.cfg serverFqdn=$localFqdn echo return @@ -381,7 +381,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/power.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/power.cfg serverFqdn=$localFqdn break fi @@ -429,13 +429,13 @@ function local_fqdn_check() { function install_config() { if [ ! -f ${cfg_install_dir}/power.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/power.cfg ] && ${csudo} cp ${script_dir}/cfg/power.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/power.cfg ] && ${csudo}cp ${script_dir}/cfg/power.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/power.cfg ${install_main_dir}/cfg/power.cfg.org - ${csudo} ln -s ${cfg_install_dir}/power.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/power.cfg ${install_main_dir}/cfg/power.cfg.org + ${csudo}ln -s ${cfg_install_dir}/power.cfg ${install_main_dir}/cfg [ ! -z $1 ] && return 0 || : # only install client @@ -465,7 +465,7 @@ function install_config() { # check the format of the firstEp #if [[ $firstEp == $FQDN_PATTERN ]]; then # Write the first FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/power.cfg + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/power.cfg break #else # read -p "Please enter the correct FQDN:port: " firstEp @@ -478,69 +478,69 @@ function install_config() { function install_log() { - ${csudo} rm -rf ${log_dir} || : - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}rm -rf ${log_dir} || : + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_data() { - ${csudo} mkdir -p ${data_dir} + ${csudo}mkdir -p ${data_dir} - ${csudo} ln -s ${data_dir} ${install_main_dir}/data + ${csudo}ln -s ${data_dir} ${install_main_dir}/data } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } function clean_service_on_sysvinit() { #restart_config_str="power:2345:respawn:${service_config_dir}/powerd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof powerd &> /dev/null; then - ${csudo} service powerd stop || : + ${csudo}service powerd stop || : fi if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/powerd ]; then - ${csudo} chkconfig --del powerd || : + ${csudo}chkconfig --del powerd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/powerd ]; then - ${csudo} insserv -r powerd || : + ${csudo}insserv -r powerd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/powerd ]; then - ${csudo} update-rc.d -f powerd remove || : + ${csudo}update-rc.d -f powerd remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/powerd || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/powerd || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -551,33 +551,33 @@ function install_service_on_sysvinit() { # Install powerd service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/powerd.deb ${install_main_dir}/init.d/powerd - ${csudo} cp ${script_dir}/init.d/powerd.deb ${service_config_dir}/powerd && ${csudo} chmod a+x ${service_config_dir}/powerd - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/powerd.deb ${install_main_dir}/init.d/powerd + ${csudo}cp ${script_dir}/init.d/powerd.deb ${service_config_dir}/powerd && ${csudo}chmod a+x ${service_config_dir}/powerd + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/powerd.rpm ${install_main_dir}/init.d/powerd - ${csudo} cp ${script_dir}/init.d/powerd.rpm ${service_config_dir}/powerd && ${csudo} chmod a+x ${service_config_dir}/powerd - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/powerd.rpm ${install_main_dir}/init.d/powerd + ${csudo}cp ${script_dir}/init.d/powerd.rpm ${service_config_dir}/powerd && ${csudo}chmod a+x ${service_config_dir}/powerd + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi #restart_config_str="power:2345:respawn:${service_config_dir}/powerd start" - #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" + #${csudo}grep -q -F "$restart_config_str" /etc/inittab || ${csudo}bash -c "echo '${restart_config_str}' >> /etc/inittab" if ((${initd_mod}==1)); then - ${csudo} chkconfig --add powerd || : - ${csudo} chkconfig --level 2345 powerd on || : - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add powerd || : + ${csudo}chkconfig --level 2345 powerd on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv powerd || : - ${csudo} insserv -d powerd || : - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv powerd || : + ${csudo}insserv -d powerd || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d powerd defaults || : - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d powerd defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -585,27 +585,27 @@ function clean_service_on_systemd() { powerd_service_config="${service_config_dir}/powerd.service" if systemctl is-active --quiet powerd; then echo "PowerDB is running, stopping it..." - ${csudo} systemctl stop powerd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop powerd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable powerd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${powerd_service_config} + ${csudo}systemctl disable powerd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${powerd_service_config} 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" if systemctl is-active --quiet nginxd; then echo "Nginx for PowerDB is running, stopping it..." - ${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop nginxd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}systemctl disable nginxd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${nginx_service_config} fi } @@ -615,81 +615,81 @@ function install_service_on_systemd() { clean_service_on_systemd powerd_service_config="${service_config_dir}/powerd.service" - ${csudo} bash -c "echo '[Unit]' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'Description=PowerDB server service' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${powerd_service_config}" - ${csudo} bash -c "echo >> ${powerd_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/powerd' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'ExecStartPre=/usr/local/power/bin/startPre.sh' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${powerd_service_config}" - ${csudo} bash -c "echo >> ${powerd_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${powerd_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${powerd_service_config}" - ${csudo} systemctl enable powerd + ${csudo}bash -c "echo '[Unit]' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'Description=PowerDB server service' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${powerd_service_config}" + ${csudo}bash -c "echo >> ${powerd_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/powerd' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'ExecStartPre=/usr/local/power/bin/startPre.sh' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${powerd_service_config}" + ${csudo}bash -c "echo >> ${powerd_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${powerd_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${powerd_service_config}" + ${csudo}systemctl enable powerd tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=PowerDB arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - #${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=PowerDB arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + #${csudo}systemctl enable tarbitratord if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" - ${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Description=Nginx For PowrDB Service' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Type=forking' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" - if ! ${csudo} systemctl enable nginxd &> /dev/null; then - ${csudo} systemctl daemon-reexec - ${csudo} systemctl enable nginxd + ${csudo}bash -c "echo '[Unit]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Description=Nginx For PowrDB Service' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Type=forking' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" + if ! ${csudo}systemctl enable nginxd &> /dev/null; then + ${csudo}systemctl daemon-reexec + ${csudo}systemctl enable nginxd fi - ${csudo} systemctl start nginxd + ${csudo}systemctl start nginxd fi } @@ -770,9 +770,9 @@ function update_PowerDB() { # Stop the service if running if pidof powerd &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop powerd || : + ${csudo}systemctl stop powerd || : elif ((${service_mod}==1)); then - ${csudo} service powerd stop || : + ${csudo}service powerd stop || : else kill_process powerd fi @@ -781,9 +781,9 @@ function update_PowerDB() { if [ "$verMode" == "cluster" ]; then if pidof nginx &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop nginxd || : + ${csudo}systemctl stop nginxd || : elif ((${service_mod}==1)); then - ${csudo} service nginxd stop || : + ${csudo}service nginxd stop || : else kill_process nginx fi @@ -824,9 +824,9 @@ function update_PowerDB() { echo echo -e "${GREEN_DARK}To configure PowerDB ${NC}: edit /etc/power/power.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start PowerDB ${NC}: ${csudo} systemctl start powerd${NC}" + echo -e "${GREEN_DARK}To start PowerDB ${NC}: ${csudo}systemctl start powerd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start PowerDB ${NC}: ${csudo} service powerd start${NC}" + echo -e "${GREEN_DARK}To start PowerDB ${NC}: ${csudo}service powerd start${NC}" else echo -e "${GREEN_DARK}To start PowerDB ${NC}: ./powerd${NC}" fi @@ -901,9 +901,9 @@ function install_PowerDB() { echo echo -e "${GREEN_DARK}To configure PowerDB ${NC}: edit /etc/power/power.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start PowerDB ${NC}: ${csudo} systemctl start powerd${NC}" + echo -e "${GREEN_DARK}To start PowerDB ${NC}: ${csudo}systemctl start powerd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start PowerDB ${NC}: ${csudo} service powerd start${NC}" + echo -e "${GREEN_DARK}To start PowerDB ${NC}: ${csudo}service powerd start${NC}" else echo -e "${GREEN_DARK}To start PowerDB ${NC}: powerd${NC}" fi diff --git a/packaging/tools/install_pro.sh b/packaging/tools/install_pro.sh index 44a21abc19f19a1bffc2be42e71db30157d4e220..f1c71985f1464e3074c006b1eec7597f5990bf9d 100755 --- a/packaging/tools/install_pro.sh +++ b/packaging/tools/install_pro.sh @@ -46,7 +46,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -144,130 +144,130 @@ done function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin -# ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver -# ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin +# ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver +# ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then - ${csudo} mkdir -p ${nginx_dir} + ${csudo}mkdir -p ${nginx_dir} fi } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/prodbc || : - ${csudo} rm -f ${bin_link_dir}/prodbs || : - ${csudo} rm -f ${bin_link_dir}/prodemo || : - ${csudo} rm -f ${bin_link_dir}/rmprodb || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/prodbc || : + ${csudo}rm -f ${bin_link_dir}/prodbs || : + ${csudo}rm -f ${bin_link_dir}/prodemo || : + ${csudo}rm -f ${bin_link_dir}/rmprodb || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/prodbc ] && ${csudo} ln -s ${install_main_dir}/bin/prodbc ${bin_link_dir}/prodbc || : - [ -x ${install_main_dir}/bin/prodbs ] && ${csudo} ln -s ${install_main_dir}/bin/prodbs ${bin_link_dir}/prodbs || : - [ -x ${install_main_dir}/bin/prodemo ] && ${csudo} ln -s ${install_main_dir}/bin/prodemo ${bin_link_dir}/prodemo || : - [ -x ${install_main_dir}/bin/remove_pro.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_pro.sh ${bin_link_dir}/rmprodb || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo} ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/prodbc ] && ${csudo}ln -s ${install_main_dir}/bin/prodbc ${bin_link_dir}/prodbc || : + [ -x ${install_main_dir}/bin/prodbs ] && ${csudo}ln -s ${install_main_dir}/bin/prodbs ${bin_link_dir}/prodbs || : + [ -x ${install_main_dir}/bin/prodemo ] && ${csudo}ln -s ${install_main_dir}/bin/prodemo ${bin_link_dir}/prodemo || : + [ -x ${install_main_dir}/bin/remove_pro.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_pro.sh ${bin_link_dir}/rmprodb || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then - ${csudo} cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo} chmod 0555 ${nginx_dir}/* - ${csudo} mkdir -p ${nginx_dir}/logs - ${csudo} chmod 777 ${nginx_dir}/sbin/nginx + ${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/* + ${csudo}mkdir -p ${nginx_dir}/logs + ${csudo}chmod 777 ${nginx_dir}/sbin/nginx fi } function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi if [ "$osType" != "Darwin" ]; then - ${csudo} ldconfig + ${csudo}ldconfig else - ${csudo} update_dyld_shared_cache + ${csudo}update_dyld_shared_cache fi } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -287,7 +287,7 @@ function add_newHostname_to_hosts() { return fi done - ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: + ${csudo}echo "127.0.0.1 $1" >> /etc/hosts ||: } function set_hostname() { @@ -301,7 +301,7 @@ function set_hostname() { fi done - ${csudo} hostname $newHostname ||: + ${csudo}hostname $newHostname ||: retval=`echo $?` if [[ $retval != 0 ]]; then echo @@ -311,15 +311,15 @@ function set_hostname() { #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then - ${csudo} echo $newHostname > /etc/hostname ||: + ${csudo}echo $newHostname > /etc/hostname ||: fi #debian: #HOSTNAME=yourname if [[ -e /etc/sysconfig/network ]]; then - ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: + ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: fi - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/prodb.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/prodb.cfg serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -354,7 +354,7 @@ 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 - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/prodb.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/prodb.cfg serverFqdn=$localFqdn echo return @@ -376,7 +376,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/prodb.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/prodb.cfg serverFqdn=$localFqdn break fi @@ -424,13 +424,13 @@ function local_fqdn_check() { function install_config() { if [ ! -f ${cfg_install_dir}/prodb.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/prodb.cfg ] && ${csudo} cp ${script_dir}/cfg/prodb.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/prodb.cfg ] && ${csudo}cp ${script_dir}/cfg/prodb.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/prodb.cfg ${install_main_dir}/cfg/prodb.cfg.org - ${csudo} ln -s ${cfg_install_dir}/prodb.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/prodb.cfg ${install_main_dir}/cfg/prodb.cfg.org + ${csudo}ln -s ${cfg_install_dir}/prodb.cfg ${install_main_dir}/cfg [ ! -z $1 ] && return 0 || : # only install client @@ -460,7 +460,7 @@ function install_config() { # check the format of the firstEp #if [[ $firstEp == $FQDN_PATTERN ]]; then # Write the first FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/prodb.cfg + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/prodb.cfg break #else # read -p "Please enter the correct FQDN:port: " firstEp @@ -473,66 +473,66 @@ function install_config() { function install_log() { - ${csudo} rm -rf ${log_dir} || : - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}rm -rf ${log_dir} || : + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_data() { - ${csudo} mkdir -p ${data_dir} + ${csudo}mkdir -p ${data_dir} - ${csudo} ln -s ${data_dir} ${install_main_dir}/data + ${csudo}ln -s ${data_dir} ${install_main_dir}/data } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } function clean_service_on_sysvinit() { if pidof prodbs &> /dev/null; then - ${csudo} service prodbs stop || : + ${csudo}service prodbs stop || : fi if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/prodbs ]; then - ${csudo} chkconfig --del prodbs || : + ${csudo}chkconfig --del prodbs || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/prodbs ]; then - ${csudo} insserv -r prodbs || : + ${csudo}insserv -r prodbs || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/prodbs ]; then - ${csudo} update-rc.d -f prodbs remove || : + ${csudo}update-rc.d -f prodbs remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/prodbs || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/prodbs || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -543,30 +543,30 @@ function install_service_on_sysvinit() { # Install prodbs service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/prodbs.deb ${install_main_dir}/init.d/prodbs - ${csudo} cp ${script_dir}/init.d/prodbs.deb ${service_config_dir}/prodbs && ${csudo} chmod a+x ${service_config_dir}/prodbs - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/prodbs.deb ${install_main_dir}/init.d/prodbs + ${csudo}cp ${script_dir}/init.d/prodbs.deb ${service_config_dir}/prodbs && ${csudo}chmod a+x ${service_config_dir}/prodbs + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/prodbs.rpm ${install_main_dir}/init.d/prodbs - ${csudo} cp ${script_dir}/init.d/prodbs.rpm ${service_config_dir}/prodbs && ${csudo} chmod a+x ${service_config_dir}/prodbs - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/prodbs.rpm ${install_main_dir}/init.d/prodbs + ${csudo}cp ${script_dir}/init.d/prodbs.rpm ${service_config_dir}/prodbs && ${csudo}chmod a+x ${service_config_dir}/prodbs + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --add prodbs || : - ${csudo} chkconfig --level 2345 prodbs on || : - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add prodbs || : + ${csudo}chkconfig --level 2345 prodbs on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv prodbs || : - ${csudo} insserv -d prodbs || : - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv prodbs || : + ${csudo}insserv -d prodbs || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d prodbs defaults || : - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d prodbs defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -574,27 +574,27 @@ function clean_service_on_systemd() { prodbs_service_config="${service_config_dir}/prodbs.service" if systemctl is-active --quiet prodbs; then echo "ProDB is running, stopping it..." - ${csudo} systemctl stop prodbs &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop prodbs &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable prodbs &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${prodbs_service_config} + ${csudo}systemctl disable prodbs &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${prodbs_service_config} 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" if systemctl is-active --quiet nginxd; then echo "Nginx for ProDB is running, stopping it..." - ${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop nginxd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}systemctl disable nginxd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${nginx_service_config} fi } @@ -602,81 +602,81 @@ function install_service_on_systemd() { clean_service_on_systemd prodbs_service_config="${service_config_dir}/prodbs.service" - ${csudo} bash -c "echo '[Unit]' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'Description=ProDB server service' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${prodbs_service_config}" - ${csudo} bash -c "echo >> ${prodbs_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/prodbs' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'ExecStartPre=/usr/local/ProDB/bin/startPre.sh' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${prodbs_service_config}" - ${csudo} bash -c "echo >> ${prodbs_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${prodbs_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${prodbs_service_config}" - ${csudo} systemctl enable prodbs + ${csudo}bash -c "echo '[Unit]' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'Description=ProDB server service' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${prodbs_service_config}" + ${csudo}bash -c "echo >> ${prodbs_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/prodbs' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'ExecStartPre=/usr/local/ProDB/bin/startPre.sh' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${prodbs_service_config}" + ${csudo}bash -c "echo >> ${prodbs_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${prodbs_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${prodbs_service_config}" + ${csudo}systemctl enable prodbs tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=ProDB arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - #${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=ProDB arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + #${csudo}systemctl enable tarbitratord if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" - ${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Description=Nginx For PowrDB Service' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Type=forking' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" - if ! ${csudo} systemctl enable nginxd &> /dev/null; then - ${csudo} systemctl daemon-reexec - ${csudo} systemctl enable nginxd + ${csudo}bash -c "echo '[Unit]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Description=Nginx For PowrDB Service' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Type=forking' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" + if ! ${csudo}systemctl enable nginxd &> /dev/null; then + ${csudo}systemctl daemon-reexec + ${csudo}systemctl enable nginxd fi - ${csudo} systemctl start nginxd + ${csudo}systemctl start nginxd fi } @@ -756,9 +756,9 @@ function update_prodb() { # Stop the service if running if pidof prodbs &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop prodbs || : + ${csudo}systemctl stop prodbs || : elif ((${service_mod}==1)); then - ${csudo} service prodbs stop || : + ${csudo}service prodbs stop || : else kill_process prodbs fi @@ -767,9 +767,9 @@ function update_prodb() { if [ "$verMode" == "cluster" ]; then if pidof nginx &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop nginxd || : + ${csudo}systemctl stop nginxd || : elif ((${service_mod}==1)); then - ${csudo} service nginxd stop || : + ${csudo}service nginxd stop || : else kill_process nginx fi @@ -810,9 +810,9 @@ function update_prodb() { echo echo -e "${GREEN_DARK}To configure ProDB ${NC}: edit /etc/ProDB/prodb.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo} systemctl start prodbs${NC}" + echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo}systemctl start prodbs${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo} service prodbs start${NC}" + echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo}service prodbs start${NC}" else echo -e "${GREEN_DARK}To start ProDB ${NC}: ./prodbs${NC}" fi @@ -887,9 +887,9 @@ function install_prodb() { echo echo -e "${GREEN_DARK}To configure ProDB ${NC}: edit /etc/ProDB/prodb.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo} systemctl start prodbs${NC}" + echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo}systemctl start prodbs${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo} service prodbs start${NC}" + echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo}service prodbs start${NC}" else echo -e "${GREEN_DARK}To start ProDB ${NC}: prodbs${NC}" fi diff --git a/packaging/tools/install_tq.sh b/packaging/tools/install_tq.sh index 481cbb19792b654710aab13d99c50ab4b5475be1..e74d5c7c4576f96608bc8a727b97aa84b9626817 100755 --- a/packaging/tools/install_tq.sh +++ b/packaging/tools/install_tq.sh @@ -49,7 +49,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi update_flag=0 @@ -149,127 +149,127 @@ done function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then - ${csudo} mkdir -p ${nginx_dir} + ${csudo}mkdir -p ${nginx_dir} fi } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/tq || : - ${csudo} rm -f ${bin_link_dir}/tqd || : - ${csudo} rm -f ${bin_link_dir}/tqdemo || : - ${csudo} rm -f ${bin_link_dir}/rmtq || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/tq || : + ${csudo}rm -f ${bin_link_dir}/tqd || : + ${csudo}rm -f ${bin_link_dir}/tqdemo || : + ${csudo}rm -f ${bin_link_dir}/rmtq || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : - ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/tq ] && ${csudo} ln -s ${install_main_dir}/bin/tq ${bin_link_dir}/tq || : - [ -x ${install_main_dir}/bin/tqd ] && ${csudo} ln -s ${install_main_dir}/bin/tqd ${bin_link_dir}/tqd || : - [ -x ${install_main_dir}/bin/tqdemo ] && ${csudo} ln -s ${install_main_dir}/bin/tqdemo ${bin_link_dir}/tqdemo || : - [ -x ${install_main_dir}/bin/remove_tq.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_tq.sh ${bin_link_dir}/rmtq || : - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo} ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : - [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + [ -x ${install_main_dir}/bin/tq ] && ${csudo}ln -s ${install_main_dir}/bin/tq ${bin_link_dir}/tq || : + [ -x ${install_main_dir}/bin/tqd ] && ${csudo}ln -s ${install_main_dir}/bin/tqd ${bin_link_dir}/tqd || : + [ -x ${install_main_dir}/bin/tqdemo ] && ${csudo}ln -s ${install_main_dir}/bin/tqdemo ${bin_link_dir}/tqdemo || : + [ -x ${install_main_dir}/bin/remove_tq.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_tq.sh ${bin_link_dir}/rmtq || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/run_taosd.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then - ${csudo} cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo} chmod 0555 ${nginx_dir}/* - ${csudo} mkdir -p ${nginx_dir}/logs - ${csudo} chmod 777 ${nginx_dir}/sbin/nginx + ${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/* + ${csudo}mkdir -p ${nginx_dir}/logs + ${csudo}chmod 777 ${nginx_dir}/sbin/nginx fi } function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : + ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h } function install_jemalloc() { jemalloc_dir=${script_dir}/jemalloc if [ -d ${jemalloc_dir} ]; then - ${csudo} /usr/bin/install -c -d /usr/local/bin + ${csudo}/usr/bin/install -c -d /usr/local/bin if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin fi if [ -f ${jemalloc_dir}/bin/jeprof ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin fi if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc fi if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib fi if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig fi fi if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc fi if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -289,7 +289,7 @@ function add_newHostname_to_hosts() { return fi done - ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: + ${csudo}echo "127.0.0.1 $1" >> /etc/hosts ||: } function set_hostname() { @@ -303,7 +303,7 @@ function set_hostname() { fi done - ${csudo} hostname $newHostname ||: + ${csudo}hostname $newHostname ||: retval=`echo $?` if [[ $retval != 0 ]]; then echo @@ -316,15 +316,15 @@ function set_hostname() { #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then - ${csudo} echo $newHostname > /etc/hostname ||: + ${csudo}echo $newHostname > /etc/hostname ||: fi #debian: #HOSTNAME=yourname if [[ -e /etc/sysconfig/network ]]; then - ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: + ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: fi - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/tq.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/tq.cfg serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -359,7 +359,7 @@ 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 - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/tq.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/tq.cfg serverFqdn=$localFqdn echo return @@ -381,7 +381,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/tq.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/tq.cfg serverFqdn=$localFqdn break fi @@ -429,13 +429,13 @@ function local_fqdn_check() { function install_config() { if [ ! -f ${cfg_install_dir}/tq.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/tq.cfg ] && ${csudo} cp ${script_dir}/cfg/tq.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/tq.cfg ] && ${csudo}cp ${script_dir}/cfg/tq.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi - ${csudo} cp -f ${script_dir}/cfg/tq.cfg ${install_main_dir}/cfg/tq.cfg.org - ${csudo} ln -s ${cfg_install_dir}/tq.cfg ${install_main_dir}/cfg + ${csudo}cp -f ${script_dir}/cfg/tq.cfg ${install_main_dir}/cfg/tq.cfg.org + ${csudo}ln -s ${cfg_install_dir}/tq.cfg ${install_main_dir}/cfg [ ! -z $1 ] && return 0 || : # only install client @@ -465,7 +465,7 @@ function install_config() { # check the format of the firstEp #if [[ $firstEp == $FQDN_PATTERN ]]; then # Write the first FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/tq.cfg + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/tq.cfg break #else # read -p "Please enter the correct FQDN:port: " firstEp @@ -478,69 +478,69 @@ function install_config() { function install_log() { - ${csudo} rm -rf ${log_dir} || : - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}rm -rf ${log_dir} || : + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_data() { - ${csudo} mkdir -p ${data_dir} + ${csudo}mkdir -p ${data_dir} - ${csudo} ln -s ${data_dir} ${install_main_dir}/data + ${csudo}ln -s ${data_dir} ${install_main_dir}/data } function install_connector() { - ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector + ${csudo}cp -rf ${script_dir}/connector/* ${install_main_dir}/connector } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples fi } function clean_service_on_sysvinit() { #restart_config_str="tq:2345:respawn:${service_config_dir}/tqd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof tqd &> /dev/null; then - ${csudo} service tqd stop || : + ${csudo}service tqd stop || : fi if pidof tarbitrator &> /dev/null; then - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tqd ]; then - ${csudo} chkconfig --del tqd || : + ${csudo}chkconfig --del tqd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tqd ]; then - ${csudo} insserv -r tqd || : + ${csudo}insserv -r tqd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tqd ]; then - ${csudo} update-rc.d -f tqd remove || : + ${csudo}update-rc.d -f tqd remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tqd || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tqd || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -551,33 +551,33 @@ function install_service_on_sysvinit() { # Install tqd service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/init.d/tqd.deb ${install_main_dir}/init.d/tqd - ${csudo} cp ${script_dir}/init.d/tqd.deb ${service_config_dir}/tqd && ${csudo} chmod a+x ${service_config_dir}/tqd - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tqd.deb ${install_main_dir}/init.d/tqd + ${csudo}cp ${script_dir}/init.d/tqd.deb ${service_config_dir}/tqd && ${csudo}chmod a+x ${service_config_dir}/tqd + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/init.d/tqd.rpm ${install_main_dir}/init.d/tqd - ${csudo} cp ${script_dir}/init.d/tqd.rpm ${service_config_dir}/tqd && ${csudo} chmod a+x ${service_config_dir}/tqd - ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord - ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + ${csudo}cp -f ${script_dir}/init.d/tqd.rpm ${install_main_dir}/init.d/tqd + ${csudo}cp ${script_dir}/init.d/tqd.rpm ${service_config_dir}/tqd && ${csudo}chmod a+x ${service_config_dir}/tqd + ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord fi #restart_config_str="tq:2345:respawn:${service_config_dir}/tqd start" - #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" + #${csudo}grep -q -F "$restart_config_str" /etc/inittab || ${csudo}bash -c "echo '${restart_config_str}' >> /etc/inittab" if ((${initd_mod}==1)); then - ${csudo} chkconfig --add tqd || : - ${csudo} chkconfig --level 2345 tqd on || : - ${csudo} chkconfig --add tarbitratord || : - ${csudo} chkconfig --level 2345 tarbitratord on || : + ${csudo}chkconfig --add tqd || : + ${csudo}chkconfig --level 2345 tqd on || : + ${csudo}chkconfig --add tarbitratord || : + ${csudo}chkconfig --level 2345 tarbitratord on || : elif ((${initd_mod}==2)); then - ${csudo} insserv tqd || : - ${csudo} insserv -d tqd || : - ${csudo} insserv tarbitratord || : - ${csudo} insserv -d tarbitratord || : + ${csudo}insserv tqd || : + ${csudo}insserv -d tqd || : + ${csudo}insserv tarbitratord || : + ${csudo}insserv -d tarbitratord || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d tqd defaults || : - ${csudo} update-rc.d tarbitratord defaults || : + ${csudo}update-rc.d tqd defaults || : + ${csudo}update-rc.d tarbitratord defaults || : fi } @@ -585,27 +585,27 @@ function clean_service_on_systemd() { tqd_service_config="${service_config_dir}/tqd.service" if systemctl is-active --quiet tqd; then echo "TQ is running, stopping it..." - ${csudo} systemctl stop tqd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop tqd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tqd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tqd_service_config} + ${csudo}systemctl disable tqd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tqd_service_config} 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 + ${csudo}systemctl stop tarbitratord &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" if systemctl is-active --quiet nginxd; then echo "Nginx for TQ is running, stopping it..." - ${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop nginxd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}systemctl disable nginxd &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${nginx_service_config} fi } @@ -615,81 +615,81 @@ function install_service_on_systemd() { clean_service_on_systemd tqd_service_config="${service_config_dir}/tqd.service" - ${csudo} bash -c "echo '[Unit]' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'Description=TQ server service' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tqd_service_config}" - ${csudo} bash -c "echo >> ${tqd_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tqd' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'ExecStartPre=/usr/local/tq/bin/startPre.sh' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tqd_service_config}" - ${csudo} bash -c "echo >> ${tqd_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tqd_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tqd_service_config}" - ${csudo} systemctl enable tqd + ${csudo}bash -c "echo '[Unit]' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'Description=TQ server service' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tqd_service_config}" + ${csudo}bash -c "echo >> ${tqd_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tqd' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'ExecStartPre=/usr/local/tq/bin/startPre.sh' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tqd_service_config}" + ${csudo}bash -c "echo >> ${tqd_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tqd_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tqd_service_config}" + ${csudo}systemctl enable tqd tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Description=TQ arbitrator service' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - #${csudo} systemctl enable tarbitratord + ${csudo}bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Description=TQ arbitrator service' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + #${csudo}systemctl enable tarbitratord if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/nginxd.service" - ${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Description=Nginx For PowrDB Service' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Type=forking' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" - ${csudo} bash -c "echo >> ${nginx_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${nginx_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" - if ! ${csudo} systemctl enable nginxd &> /dev/null; then - ${csudo} systemctl daemon-reexec - ${csudo} systemctl enable nginxd + ${csudo}bash -c "echo '[Unit]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Description=Nginx For PowrDB Service' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Type=forking' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" + ${csudo}bash -c "echo >> ${nginx_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${nginx_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" + if ! ${csudo}systemctl enable nginxd &> /dev/null; then + ${csudo}systemctl daemon-reexec + ${csudo}systemctl enable nginxd fi - ${csudo} systemctl start nginxd + ${csudo}systemctl start nginxd fi } @@ -770,9 +770,9 @@ function update_tq() { # Stop the service if running if pidof tqd &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop tqd || : + ${csudo}systemctl stop tqd || : elif ((${service_mod}==1)); then - ${csudo} service tqd stop || : + ${csudo}service tqd stop || : else kill_process tqd fi @@ -781,9 +781,9 @@ function update_tq() { if [ "$verMode" == "cluster" ]; then if pidof nginx &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop nginxd || : + ${csudo}systemctl stop nginxd || : elif ((${service_mod}==1)); then - ${csudo} service nginxd stop || : + ${csudo}service nginxd stop || : else kill_process nginx fi @@ -824,9 +824,9 @@ function update_tq() { echo echo -e "${GREEN_DARK}To configure TQ ${NC}: edit /etc/tq/tq.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start TQ ${NC}: ${csudo} systemctl start tqd${NC}" + echo -e "${GREEN_DARK}To start TQ ${NC}: ${csudo}systemctl start tqd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start TQ ${NC}: ${csudo} service tqd start${NC}" + echo -e "${GREEN_DARK}To start TQ ${NC}: ${csudo}service tqd start${NC}" else echo -e "${GREEN_DARK}To start TQ ${NC}: ./tqd${NC}" fi @@ -901,9 +901,9 @@ function install_tq() { echo echo -e "${GREEN_DARK}To configure TQ ${NC}: edit /etc/tq/tq.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start TQ ${NC}: ${csudo} systemctl start tqd${NC}" + echo -e "${GREEN_DARK}To start TQ ${NC}: ${csudo}systemctl start tqd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start TQ ${NC}: ${csudo} service tqd start${NC}" + echo -e "${GREEN_DARK}To start TQ ${NC}: ${csudo}service tqd start${NC}" else echo -e "${GREEN_DARK}To start TQ ${NC}: tqd${NC}" fi diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 38b45871a6a96887fee19cd460f056410f52fbc5..ba81aacb19e8054ce7d4423cd3b106c1a8d1ad67 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -67,7 +67,7 @@ os_type=0 if [ "$osType" != "Darwin" ]; then if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 if pidof systemd &> /dev/null; then @@ -118,7 +118,7 @@ fi function kill_taosadapter() { pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } @@ -126,79 +126,79 @@ function kill_taosd() { ps -ef | grep "taosd" pid=$(ps -ef | grep -w "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_main_path() { #create install main dir and all sub dir if [ "$osType" != "Darwin" ]; then - ${csudo} rm -rf ${install_main_dir} || : - ${csudo} mkdir -p ${install_main_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include - ${csudo} mkdir -p ${install_main_dir}/init.d + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/init.d else - ${csudo} rm -rf ${install_main_dir} || ${csudo} rm -rf ${install_main_2_dir} || : - ${csudo} mkdir -p ${install_main_dir} || ${csudo} mkdir -p ${install_main_2_dir} - ${csudo} mkdir -p ${install_main_dir}/cfg || ${csudo} mkdir -p ${install_main_2_dir}/cfg - ${csudo} mkdir -p ${install_main_dir}/bin || ${csudo} mkdir -p ${install_main_2_dir}/bin - ${csudo} mkdir -p ${install_main_dir}/connector || ${csudo} mkdir -p ${install_main_2_dir}/connector - ${csudo} mkdir -p ${install_main_dir}/driver || ${csudo} mkdir -p ${install_main_2_dir}/driver - ${csudo} mkdir -p ${install_main_dir}/examples || ${csudo} mkdir -p ${install_main_2_dir}/examples - ${csudo} mkdir -p ${install_main_dir}/include || ${csudo} mkdir -p ${install_main_2_dir}/include + ${csudo}rm -rf ${install_main_dir} || ${csudo}rm -rf ${install_main_2_dir} || : + ${csudo}mkdir -p ${install_main_dir} || ${csudo}mkdir -p ${install_main_2_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg || ${csudo}mkdir -p ${install_main_2_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin || ${csudo}mkdir -p ${install_main_2_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/connector || ${csudo}mkdir -p ${install_main_2_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver || ${csudo}mkdir -p ${install_main_2_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples || ${csudo}mkdir -p ${install_main_2_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include || ${csudo}mkdir -p ${install_main_2_dir}/include fi } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosd || : - ${csudo} rm -f ${bin_link_dir}/taosadapter || : - ${csudo} rm -f ${bin_link_dir}/taosdemo || : - ${csudo} rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/taos || : + ${csudo}rm -f ${bin_link_dir}/taosd || : + ${csudo}rm -f ${bin_link_dir}/taosadapter || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${bin_link_dir}/taosdump || : if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${bin_link_dir}/perfMonitor || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : - ${csudo} rm -f ${bin_link_dir}/rmtaos || : + ${csudo}rm -f ${bin_link_dir}/perfMonitor || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/rmtaos || : - ${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin - ${csudo} cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin + ${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin - ${csudo} cp -r ${script_dir}/remove.sh ${install_main_dir}/bin - ${csudo} cp -r ${script_dir}/set_core.sh ${install_main_dir}/bin - ${csudo} cp -r ${script_dir}/run_taosd.sh ${install_main_dir}/bin - ${csudo} cp -r ${script_dir}/startPre.sh ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/remove.sh ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/set_core.sh ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/run_taosd.sh ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/startPre.sh ${install_main_dir}/bin - ${csudo} chmod 0555 ${install_main_dir}/bin/* + ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : - [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : - [ -x ${install_main_dir}/bin/taosadapter ] && ${csudo} ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || : - [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : - [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : - [ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo} ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || : - [ -x ${install_main_dir}/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/run_taosd.sh ] && ${csudo} ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : + [ -x ${install_main_dir}/bin/taos ] && ${csudo}ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : + [ -x ${install_main_dir}/bin/taosd ] && ${csudo}ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : + [ -x ${install_main_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || : + [ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : + [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + [ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo}ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || : + [ -x ${install_main_dir}/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/run_taosd.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd.sh ${bin_link_dir}/run_taosd.sh || : + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : else - ${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin || ${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_2_dir}/bin || : - ${csudo} cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_2_dir} || : - ${csudo} cp -r ${script_dir}/remove_client.sh ${install_main_dir}/bin || ${csudo} cp -r ${script_dir}/remove_client.sh ${install_main_2_dir}/bin - ${csudo} chmod 0555 ${install_main_dir}/bin/* || ${csudo} chmod 0555 ${install_main_2_dir}/bin/* + ${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin || ${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_2_dir}/bin || : + ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_2_dir} || : + ${csudo}cp -r ${script_dir}/remove_client.sh ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/remove_client.sh ${install_main_2_dir}/bin + ${csudo}chmod 0555 ${install_main_dir}/bin/* || ${csudo}chmod 0555 ${install_main_2_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/taos ] || [ -x ${install_main_2_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || ${csudo} ln -s ${install_main_2_dir}/bin/taos || : - [ -x ${install_main_dir}/bin/taosd ] || [ -x ${install_main_2_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || ${csudo} ln -s ${install_main_2_dir}/bin/taosd || : - [ -x ${install_main_dir}/bin/taosadapter ] || [ -x ${install_main_2_dir}/bin/taosadapter ] && ${csudo} ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || ${csudo} ln -s ${install_main_2_dir}/bin/taosadapter || : - [ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || : - [ -x ${install_main_dir}/bin/taosdemo ] || [ -x ${install_main_2_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || ln -s ${install_main_2_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + [ -x ${install_main_dir}/bin/taos ] || [ -x ${install_main_2_dir}/bin/taos ] && ${csudo}ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || ${csudo}ln -s ${install_main_2_dir}/bin/taos || : + [ -x ${install_main_dir}/bin/taosd ] || [ -x ${install_main_2_dir}/bin/taosd ] && ${csudo}ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || ${csudo}ln -s ${install_main_2_dir}/bin/taosd || : + [ -x ${install_main_dir}/bin/taosadapter ] || [ -x ${install_main_2_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || ${csudo}ln -s ${install_main_2_dir}/bin/taosadapter || : + [ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || : + [ -x ${install_main_dir}/bin/taosdemo ] || [ -x ${install_main_2_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || ln -s ${install_main_2_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : fi } @@ -207,48 +207,48 @@ function install_jemalloc() { /usr/bin/install -c -d /usr/local/bin if [ -f "${binary_dir}/build/bin/jemalloc-config" ]; then - ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin fi if [ -f "${binary_dir}/build/bin/jemalloc.sh" ]; then - ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin fi if [ -f "${binary_dir}/build/bin/jeprof" ]; then - ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin fi if [ -f "${binary_dir}/build/include/jemalloc/jemalloc.h" ]; then - ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h\ + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h\ /usr/local/include/jemalloc fi if [ -f "${binary_dir}/build/lib/libjemalloc.so.2" ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib - ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib - ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so - ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib [ -f ${binary_dir}/build/lib/libjemalloc.a ] && - ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib [ -f ${binary_dir}/build/lib/libjemalloc_pic.a ] && - ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib if [ -f "${binary_dir}/build/lib/pkgconfig/jemalloc.pc" ]; then - ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig - ${csudo} /usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc\ + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc\ /usr/local/lib/pkgconfig fi if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" - ${csudo} ldconfig + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi fi if [ -f "${binary_dir}/build/share/doc/jemalloc/jemalloc.html" ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc - ${csudo} /usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html\ + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html\ /usr/local/share/doc/jemalloc fi if [ -f "${binary_dir}/build/share/man/man3/jemalloc.3" ]; then - ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 - ${csudo} /usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3\ + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3\ /usr/local/share/man/man3 fi fi @@ -257,17 +257,17 @@ function install_jemalloc() { function install_avro() { if [ "$osType" != "Darwin" ]; then if [ -f "${binary_dir}/build/$1/libavro.so.23.0.0" ] && [ -d /usr/local/$1 ]; then - ${csudo} /usr/bin/install -c -d /usr/local/$1 - ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.so.23.0.0 /usr/local/$1 - ${csudo} ln -sf libavro.so.23.0.0 /usr/local/$1/libavro.so.23 - ${csudo} ln -sf libavro.so.23 /usr/local/$1/libavro.so - ${csudo} /usr/bin/install -c -d /usr/local/$1 + ${csudo}/usr/bin/install -c -d /usr/local/$1 + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.so.23.0.0 /usr/local/$1 + ${csudo}ln -sf libavro.so.23.0.0 /usr/local/$1/libavro.so.23 + ${csudo}ln -sf libavro.so.23 /usr/local/$1/libavro.so + ${csudo}/usr/bin/install -c -d /usr/local/$1 [ -f ${binary_dir}/build/$1/libavro.a ] && - ${csudo} /usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.a /usr/local/$1 + ${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.a /usr/local/$1 if [ -d /etc/ld.so.conf.d ]; then - echo "/usr/local/$1" | ${csudo} tee /etc/ld.so.conf.d/libavro.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/libavro.conf" - ${csudo} ldconfig + echo "/usr/local/$1" | ${csudo}tee /etc/ld.so.conf.d/libavro.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/libavro.conf" + ${csudo}ldconfig else echo "/etc/ld.so.conf.d not found!" fi @@ -277,47 +277,47 @@ function install_avro() { function install_lib() { # Remove links - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : fi if [ "$osType" != "Darwin" ]; then - ${csudo} cp ${binary_dir}/build/lib/libtaos.so.${verNumber} \ + ${csudo}cp ${binary_dir}/build/lib/libtaos.so.${verNumber} \ ${install_main_dir}/driver \ - && ${csudo} chmod 777 ${install_main_dir}/driver/* + && ${csudo}chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [ -d "${lib64_link_dir}" ]; then - ${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 - ${csudo} ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 + ${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so fi else - ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ + ${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ ${install_main_dir}/driver \ - || ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ + || ${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ ${install_main_2_dir}/driver \ - && ${csudo} chmod 777 ${install_main_dir}/driver/* \ - || ${csudo} chmod 777 ${install_main_2_dir}/driver/* + && ${csudo}chmod 777 ${install_main_dir}/driver/* \ + || ${csudo}chmod 777 ${install_main_2_dir}/driver/* - ${csudo} ln -sf ${install_main_dir}/driver/libtaos.* \ + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* \ ${install_main_dir}/driver/libtaos.1.dylib \ - || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.* \ + || ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.* \ ${install_main_2_dir}/driver/libtaos.1.dylib || : - ${csudo} ln -sf ${install_main_dir}/driver/libtaos.1.dylib \ + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.1.dylib \ ${install_main_dir}/driver/libtaos.dylib \ - || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.1.dylib \ + || ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.1.dylib \ ${install_main_2_dir}/driver/libtaos.dylib || : - ${csudo} ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib \ + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib \ ${lib_link_dir}/libtaos.1.dylib \ - || ${csudo} ln -sf ${install_main_2_dir}/driver/libtaos.${verNumber}.dylib \ + || ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.${verNumber}.dylib \ ${lib_link_dir}/libtaos.1.dylib || : - ${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || : + ${csudo}ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || : fi install_jemalloc @@ -325,129 +325,129 @@ function install_lib() { install_avro lib64 if [ "$osType" != "Darwin" ]; then - ${csudo} ldconfig + ${csudo}ldconfig fi } function install_header() { if [ "$osType" != "Darwin" ]; then - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : - ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ - ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || : + ${csudo}cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ + ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h else - ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ + ${csudo}cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ ${install_main_dir}/include \ - || ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ + || ${csudo}cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ ${install_main_2_dir}/include \ - && ${csudo} chmod 644 ${install_main_dir}/include/* \ - || ${csudo} chmod 644 ${install_main_2_dir}/include/* + && ${csudo}chmod 644 ${install_main_dir}/include/* \ + || ${csudo}chmod 644 ${install_main_2_dir}/include/* fi } function install_config() { if [ ! -f ${cfg_install_dir}/taos.cfg ]; then - ${csudo} mkdir -p ${cfg_install_dir} + ${csudo}mkdir -p ${cfg_install_dir} [ -f ${script_dir}/../cfg/taos.cfg ] && - ${csudo} cp ${script_dir}/../cfg/taos.cfg ${cfg_install_dir} - ${csudo} chmod 644 ${cfg_install_dir}/taos.cfg - ${csudo} cp -f ${script_dir}/../cfg/taos.cfg \ + ${csudo}cp ${script_dir}/../cfg/taos.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/taos.cfg + ${csudo}cp -f ${script_dir}/../cfg/taos.cfg \ ${cfg_install_dir}/taos.cfg.${verNumber} - ${csudo} ln -s ${cfg_install_dir}/taos.cfg \ + ${csudo}ln -s ${cfg_install_dir}/taos.cfg \ ${install_main_dir}/cfg/taos.cfg else - ${csudo} cp -f ${script_dir}/../cfg/taos.cfg \ + ${csudo}cp -f ${script_dir}/../cfg/taos.cfg \ ${cfg_install_dir}/taos.cfg.${verNumber} fi } function install_taosadapter_config() { if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then - ${csudo} mkdir -p ${cfg_install_dir} + ${csudo}mkdir -p ${cfg_install_dir} [ -f ${binary_dir}/test/cfg/taosadapter.toml ] && - ${csudo} cp ${binary_dir}/test/cfg/taosadapter.toml ${cfg_install_dir} + ${csudo}cp ${binary_dir}/test/cfg/taosadapter.toml ${cfg_install_dir} [ -f ${cfg_install_dir}/taosadapter.toml ] && - ${csudo} chmod 644 ${cfg_install_dir}/taosadapter.toml + ${csudo}chmod 644 ${cfg_install_dir}/taosadapter.toml [ -f ${binary_dir}/test/cfg/taosadapter.toml ] && - ${csudo} cp -f ${binary_dir}/test/cfg/taosadapter.toml \ + ${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \ ${cfg_install_dir}/taosadapter.toml.${verNumber} [ -f ${cfg_install_dir}/taosadapter.toml ] && \ - ${csudo} ln -s ${cfg_install_dir}/taosadapter.toml \ + ${csudo}ln -s ${cfg_install_dir}/taosadapter.toml \ ${install_main_dir}/cfg/taosadapter.toml else if [ -f "${binary_dir}/test/cfg/taosadapter.toml" ]; then - ${csudo} cp -f ${binary_dir}/test/cfg/taosadapter.toml \ + ${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \ ${cfg_install_dir}/taosadapter.toml.${verNumber} fi fi } function install_log() { - ${csudo} rm -rf ${log_dir} || : - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo}rm -rf ${log_dir} || : + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} if [ "$osType" != "Darwin" ]; then - ${csudo} ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log else - ${csudo} ln -s ${log_dir} ${install_main_dir}/log || ${csudo} ln -s ${log_dir} ${install_main_2_dir}/log + ${csudo}ln -s ${log_dir} ${install_main_dir}/log || ${csudo}ln -s ${log_dir} ${install_main_2_dir}/log fi } function install_data() { - ${csudo} mkdir -p ${data_dir} + ${csudo}mkdir -p ${data_dir} if [ "$osType" != "Darwin" ]; then - ${csudo} ln -s ${data_dir} ${install_main_dir}/data + ${csudo}ln -s ${data_dir} ${install_main_dir}/data else - ${csudo} ln -s ${data_dir} ${install_main_dir}/data || ${csudo} ln -s ${data_dir} ${install_main_2_dir}/data + ${csudo}ln -s ${data_dir} ${install_main_dir}/data || ${csudo}ln -s ${data_dir} ${install_main_2_dir}/data fi } function install_connector() { if find ${source_dir}/src/connector/go -mindepth 1 -maxdepth 1 | read; then - ${csudo} cp -r ${source_dir}/src/connector/go ${install_main_dir}/connector + ${csudo}cp -r ${source_dir}/src/connector/go ${install_main_dir}/connector else echo "WARNING: go connector not found, please check if want to use it!" fi if [ "$osType" != "Darwin" ]; then - ${csudo} cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector - ${csudo} cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &> /dev/null && ${csudo} chmod 777 ${install_main_dir}/connector/*.jar || echo &> /dev/null + ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector + ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &> /dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &> /dev/null else - ${csudo} cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || ${csudo} cp -rf ${source_dir}/src/connector/python ${install_main_2_dir}/connector - ${csudo} cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &> /dev/null && ${csudo} chmod 777 ${install_main_dir}/connector/*.jar || echo &> /dev/null - ${csudo} cp ${binary_dir}/build/lib/*.jar ${install_main_2_dir}/connector &> /dev/null && ${csudo} chmod 777 ${install_main_2_dir}/connector/*.jar || echo &> /dev/null + ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_2_dir}/connector + ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &> /dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &> /dev/null + ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_2_dir}/connector &> /dev/null && ${csudo}chmod 777 ${install_main_2_dir}/connector/*.jar || echo &> /dev/null fi } function install_examples() { if [ "$osType" != "Darwin" ]; then - ${csudo} cp -rf ${source_dir}/tests/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${source_dir}/tests/examples/* ${install_main_dir}/examples else - ${csudo} cp -rf ${source_dir}/tests/examples/* ${install_main_dir}/examples || ${csudo} cp -rf ${source_dir}/tests/examples/* ${install_main_2_dir}/examples + ${csudo}cp -rf ${source_dir}/tests/examples/* ${install_main_dir}/examples || ${csudo}cp -rf ${source_dir}/tests/examples/* ${install_main_2_dir}/examples fi } function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof taosd &> /dev/null; then - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --del taosd || : + ${csudo}chkconfig --del taosd || : elif ((${initd_mod}==2)); then - ${csudo} insserv -r taosd || : + ${csudo}insserv -r taosd || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d -f taosd remove || : + ${csudo}update-rc.d -f taosd remove || : fi - ${csudo} rm -f ${service_config_dir}/taosd || : + ${csudo}rm -f ${service_config_dir}/taosd || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -458,24 +458,24 @@ function install_service_on_sysvinit() { # Install taosd service if ((${os_type}==1)); then - ${csudo} cp -f ${script_dir}/../deb/taosd ${install_main_dir}/init.d - ${csudo} cp ${script_dir}/../deb/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd + ${csudo}cp -f ${script_dir}/../deb/taosd ${install_main_dir}/init.d + ${csudo}cp ${script_dir}/../deb/taosd ${service_config_dir} && ${csudo}chmod a+x ${service_config_dir}/taosd elif ((${os_type}==2)); then - ${csudo} cp -f ${script_dir}/../rpm/taosd ${install_main_dir}/init.d - ${csudo} cp ${script_dir}/../rpm/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd + ${csudo}cp -f ${script_dir}/../rpm/taosd ${install_main_dir}/init.d + ${csudo}cp ${script_dir}/../rpm/taosd ${service_config_dir} && ${csudo}chmod a+x ${service_config_dir}/taosd fi #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" + #${csudo}grep -q -F "$restart_config_str" /etc/inittab || ${csudo}bash -c "echo '${restart_config_str}' >> /etc/inittab" if ((${initd_mod}==1)); then - ${csudo} chkconfig --add taosd || : - ${csudo} chkconfig --level 2345 taosd on || : + ${csudo}chkconfig --add taosd || : + ${csudo}chkconfig --level 2345 taosd on || : elif ((${initd_mod}==2)); then - ${csudo} insserv taosd || : - ${csudo} insserv -d taosd || : + ${csudo}insserv taosd || : + ${csudo}insserv -d taosd || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d taosd defaults || : + ${csudo}update-rc.d taosd defaults || : fi } @@ -484,11 +484,11 @@ function clean_service_on_systemd() { if systemctl is-active --quiet taosd; then echo "TDengine is running, stopping it..." - ${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop taosd &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable taosd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${taosd_service_config} + ${csudo}rm -f ${taosd_service_config} } # taos:2345:respawn:/etc/init.d/taosd start @@ -498,36 +498,36 @@ function install_service_on_systemd() { taosd_service_config="${service_config_dir}/taosd.service" - ${csudo} bash -c "echo '[Unit]' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'After=network-online.target taosadapter.service' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target taosadapter.service' >> ${taosd_service_config}" - ${csudo} bash -c "echo >> ${taosd_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/taosd' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'ExecStartPre=/usr/local/taos/bin/startPre.sh' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}" - ${csudo} bash -c "echo >> ${taosd_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}" - ${csudo} systemctl enable taosd + ${csudo}bash -c "echo '[Unit]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'After=network-online.target taosadapter.service' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target taosadapter.service' >> ${taosd_service_config}" + ${csudo}bash -c "echo >> ${taosd_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/taosd' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'ExecStartPre=/usr/local/taos/bin/startPre.sh' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}" + ${csudo}bash -c "echo >> ${taosd_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}" + ${csudo}systemctl enable taosd } function install_taosadapter_service() { if ((${service_mod}==0)); then [ -f ${binary_dir}/test/cfg/taosadapter.service ] &&\ - ${csudo} cp ${binary_dir}/test/cfg/taosadapter.service\ + ${csudo}cp ${binary_dir}/test/cfg/taosadapter.service\ ${service_config_dir}/ || : - ${csudo} systemctl daemon-reload + ${csudo}systemctl daemon-reload fi } @@ -548,9 +548,9 @@ function update_TDengine() { if pidof taosd &> /dev/null; then if ((${service_mod}==0)); then - ${csudo} systemctl stop taosd || : + ${csudo}systemctl stop taosd || : elif ((${service_mod}==1)); then - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : else kill_taosadapter kill_taosd @@ -580,9 +580,9 @@ function update_TDengine() { echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" echo -e "${GREEN_DARK}To configure Taos Adapter (if has) ${NC}: edit /etc/taos/taosadapter.toml" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}systemctl start taosd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}service taosd start${NC}" else echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}" @@ -620,10 +620,11 @@ function install_TDengine() { echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" echo -e "${GREEN_DARK}To configure taosadapter (if has) ${NC}: edit /etc/taos/taosadapter.toml" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}systemctl start taosd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}service taosd start${NC}" else + echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" fi diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 7a90435d8f1ce8dc190e0f1513aee080838e4645..7fc2f984570f65a0b0381e5e54510e0fef667c6a 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -41,7 +41,7 @@ NC='\033[0m' csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -65,62 +65,62 @@ else fi function kill_taosadapter() { -# ${csudo} pkill -f taosadapter || : +# ${csudo}pkill -f taosadapter || : pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_taosd() { -# ${csudo} pkill -f taosd || : +# ${csudo}pkill -f taosd || : pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function install_include() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h|| : - ${csudo} ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${inc_dir}/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo} ln -s ${inc_dir}/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h|| : + ${csudo}ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${inc_dir}/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${inc_dir}/taoserror.h ${inc_link_dir}/taoserror.h } function install_lib() { - ${csudo} rm -f ${lib_link_dir}/libtaos* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos* || : + ${csudo}rm -f ${lib_link_dir}/libtaos* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos* || : - ${csudo} ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo} ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi - ${csudo} ldconfig + ${csudo}ldconfig } function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosd || : - ${csudo} rm -f ${bin_link_dir}/taosadapter || : - ${csudo} rm -f ${bin_link_dir}/taosdemo || : - ${csudo} rm -f ${bin_link_dir}/taosdump || : - ${csudo} rm -f ${bin_link_dir}/rmtaos || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/taos || : + ${csudo}rm -f ${bin_link_dir}/taosd || : + ${csudo}rm -f ${bin_link_dir}/taosadapter || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/rmtaos || : + ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo} chmod 0555 ${bin_dir}/* + ${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}/taosadapter ] && ${csudo} ln -s ${bin_dir}/taosadapter ${bin_link_dir}/taosadapter || : - [ -x ${bin_dir}/taosdemo ] && ${csudo} ln -s ${bin_dir}/taosdemo ${bin_link_dir}/taosdemo || : - [ -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}/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}/taosadapter ] && ${csudo}ln -s ${bin_dir}/taosadapter ${bin_link_dir}/taosadapter || : + [ -x ${bin_dir}/taosdemo ] && ${csudo}ln -s ${bin_dir}/taosdemo ${bin_link_dir}/taosdemo || : + [ -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 || : } function add_newHostname_to_hosts() { @@ -136,7 +136,7 @@ function add_newHostname_to_hosts() { return fi done - ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: + ${csudo}echo "127.0.0.1 $1" >> /etc/hosts ||: } function set_hostname() { @@ -150,7 +150,7 @@ function set_hostname() { fi done - ${csudo} hostname $newHostname ||: + ${csudo}hostname $newHostname ||: retval=`echo $?` if [[ $retval != 0 ]]; then echo @@ -163,15 +163,15 @@ function set_hostname() { #ubuntu/centos /etc/hostname if [[ -e /etc/hostname ]]; then - ${csudo} echo $newHostname > /etc/hostname ||: + ${csudo}echo $newHostname > /etc/hostname ||: fi #debian: #HOSTNAME=yourname if [[ -e /etc/sysconfig/network ]]; then - ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: + ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: fi - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -206,7 +206,7 @@ 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 - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg serverFqdn=$localFqdn echo return @@ -228,7 +228,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg serverFqdn=$localFqdn break fi @@ -277,24 +277,24 @@ function local_fqdn_check() { function install_taosadapter_config() { if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then [ ! -d %{cfg_install_dir} ] && - ${csudo} ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${cfg_dir}/taosadapter.toml ] && ${csudo} cp ${cfg_dir}/taosadapter.toml ${cfg_install_dir} + ${csudo}${csudo}mkdir -p ${cfg_install_dir} + [ -f ${cfg_dir}/taosadapter.toml ] && ${csudo}cp ${cfg_dir}/taosadapter.toml ${cfg_install_dir} [ -f ${cfg_install_dir}/taosadapter.toml ] && - ${csudo} chmod 644 ${cfg_install_dir}/taosadapter.toml + ${csudo}chmod 644 ${cfg_install_dir}/taosadapter.toml fi [ -f ${cfg_dir}/taosadapter.toml ] && - ${csudo} mv ${cfg_dir}/taosadapter.toml ${cfg_dir}/taosadapter.toml.new + ${csudo}mv ${cfg_dir}/taosadapter.toml ${cfg_dir}/taosadapter.toml.new [ -f ${cfg_install_dir}/taosadapter.toml ] && - ${csudo} ln -s ${cfg_install_dir}/taosadapter.toml ${cfg_dir} + ${csudo}ln -s ${cfg_install_dir}/taosadapter.toml ${cfg_dir} } function install_config() { 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} - ${csudo} chmod 644 ${cfg_install_dir}/* + ${csudo}${csudo}mkdir -p ${cfg_install_dir} + [ -f ${cfg_dir}/taos.cfg ] && ${csudo}cp ${cfg_dir}/taos.cfg ${cfg_install_dir} + ${csudo}chmod 644 ${cfg_install_dir}/* fi # Save standard input to 6 and open / dev / TTY on standard input @@ -305,8 +305,8 @@ function install_config() { # restore the backup standard input, and turn off 6 exec 0<&6 6<&- - ${csudo} mv ${cfg_dir}/taos.cfg ${cfg_dir}/taos.cfg.new - ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${cfg_dir} + ${csudo}mv ${cfg_dir}/taos.cfg ${cfg_dir}/taos.cfg.new + ${csudo}ln -s ${cfg_install_dir}/taos.cfg ${cfg_dir} #FQDN_FORMAT="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" #FQDN_FORMAT="(:[1-6][0-9][0-9][0-9][0-9]$)" #PORT_FORMAT="(/[1-6][0-9][0-9][0-9][0-9]?/)" @@ -326,7 +326,7 @@ function install_config() { # check the format of the firstEp #if [[ $firstEp == $FQDN_PATTERN ]]; then # Write the first FQDN to configuration file - ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg break #else # read -p "Please enter the correct FQDN:port: " firstEp @@ -349,7 +349,7 @@ function install_config() { #if [[ "$emailAddr" =~ $EMAIL_PATTERN ]]; then # Write the email address to temp file email_file="${install_main_dir}/email" - ${csudo} bash -c "echo $emailAddr > ${email_file}" + ${csudo}bash -c "echo $emailAddr > ${email_file}" break #else # read -p "Please enter the correct email address: " emailAddr @@ -362,24 +362,24 @@ function install_config() { function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof taosd &> /dev/null; then - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --del taosd || : + ${csudo}chkconfig --del taosd || : elif ((${initd_mod}==2)); then - ${csudo} insserv -r taosd || : + ${csudo}insserv -r taosd || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d -f taosd remove || : + ${csudo}update-rc.d -f taosd remove || : fi - ${csudo} rm -f ${service_config_dir}/taosd || : + ${csudo}rm -f ${service_config_dir}/taosd || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -389,19 +389,19 @@ function install_service_on_sysvinit() { sleep 1 # Install taosd service - ${csudo} cp %{init_d_dir}/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd + ${csudo}cp %{init_d_dir}/taosd ${service_config_dir} && ${csudo}chmod a+x ${service_config_dir}/taosd #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" + #${csudo}grep -q -F "$restart_config_str" /etc/inittab || ${csudo}bash -c "echo '${restart_config_str}' >> /etc/inittab" if ((${initd_mod}==1)); then - ${csudo} chkconfig --add taosd || : - ${csudo} chkconfig --level 2345 taosd on || : + ${csudo}chkconfig --add taosd || : + ${csudo}chkconfig --level 2345 taosd on || : elif ((${initd_mod}==2)); then - ${csudo} insserv taosd || : - ${csudo} insserv -d taosd || : + ${csudo}insserv taosd || : + ${csudo}insserv -d taosd || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d taosd defaults || : + ${csudo}update-rc.d taosd defaults || : fi } @@ -411,11 +411,11 @@ function clean_service_on_systemd() { # taosd service already is stoped before install in preinst script #if systemctl is-active --quiet taosd; then # echo "TDengine is running, stopping it..." - # ${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null + # ${csudo}systemctl stop taosd &> /dev/null || echo &> /dev/null #fi - ${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable taosd &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${taosd_service_config} + ${csudo}rm -f ${taosd_service_config} } # taos:2345:respawn:/etc/init.d/taosd start @@ -425,36 +425,36 @@ function install_service_on_systemd() { taosd_service_config="${service_config_dir}/taosd.service" - ${csudo} bash -c "echo '[Unit]' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'After=network-online.target taosadapter.service' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Wants=network-online.target taosadapter.service' >> ${taosd_service_config}" - ${csudo} bash -c "echo >> ${taosd_service_config}" - ${csudo} bash -c "echo '[Service]' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Type=simple' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'ExecStart=/usr/bin/taosd' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'ExecStartPre=/usr/local/taos/bin/startPre.sh' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'Restart=always' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}" - ${csudo} bash -c "echo >> ${taosd_service_config}" - ${csudo} bash -c "echo '[Install]' >> ${taosd_service_config}" - ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}" - ${csudo} systemctl enable taosd + ${csudo}bash -c "echo '[Unit]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'After=network-online.target taosadapter.service' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Wants=network-online.target taosadapter.service' >> ${taosd_service_config}" + ${csudo}bash -c "echo >> ${taosd_service_config}" + ${csudo}bash -c "echo '[Service]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Type=simple' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'ExecStart=/usr/bin/taosd' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'ExecStartPre=/usr/local/taos/bin/startPre.sh' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'Restart=always' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}" + ${csudo}bash -c "echo >> ${taosd_service_config}" + ${csudo}bash -c "echo '[Install]' >> ${taosd_service_config}" + ${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}" + ${csudo}systemctl enable taosd } function install_taosadapter_service() { if ((${service_mod}==0)); then [ -f ${script_dir}/../cfg/taosadapter.service ] &&\ - ${csudo} cp ${script_dir}/../cfg/taosadapter.service \ + ${csudo}cp ${script_dir}/../cfg/taosadapter.service \ ${service_config_dir}/ || : - ${csudo} systemctl daemon-reload + ${csudo}systemctl daemon-reload fi } @@ -474,14 +474,14 @@ function install_TDengine() { echo -e "${GREEN}Start to install TDengine...${NC}" #install log and data dir , then ln to /usr/local/taos - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} - ${csudo} mkdir -p ${data_dir} + ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} + ${csudo}mkdir -p ${data_dir} - ${csudo} rm -rf ${log_link_dir} || : - ${csudo} rm -rf ${data_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${data_link_dir} || : - ${csudo} ln -s ${log_dir} ${log_link_dir} || : - ${csudo} ln -s ${data_dir} ${data_link_dir} || : + ${csudo}ln -s ${log_dir} ${log_link_dir} || : + ${csudo}ln -s ${data_dir} ${data_link_dir} || : # Install include, lib, binary and service install_include @@ -498,10 +498,10 @@ function install_TDengine() { echo echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg" if ((${service_mod}==0)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}systemctl start taosd${NC}" elif ((${service_mod}==1)); then - echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} update-rc.d taosd default ${RED} for the first time${NC}" - echo -e " : ${csudo} service taosd start ${RED} after${NC}" + echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}update-rc.d taosd default ${RED} for the first time${NC}" + echo -e " : ${csudo}service taosd start ${RED} after${NC}" else echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" fi diff --git a/packaging/tools/preun.sh b/packaging/tools/preun.sh index 43fead76ba675dfa8ee45422d9f9dc8166b2488d..27dc830a1f189d196a5b937f71dbafc776d035d4 100755 --- a/packaging/tools/preun.sh +++ b/packaging/tools/preun.sh @@ -20,7 +20,7 @@ taos_service_name="taosd" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -46,14 +46,14 @@ fi function kill_taosadapter() { pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_taosd() { pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } @@ -61,44 +61,44 @@ function clean_service_on_systemd() { taosadapter_service_config="${service_config_dir}/taosadapter.service" if systemctl is-active --quiet taosadapter; then echo "taosadapter is running, stopping it..." - ${csudo} systemctl stop taosadapter &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop taosadapter &> /dev/null || echo &> /dev/null fi taosd_service_config="${service_config_dir}/${taos_service_name}.service" if systemctl is-active --quiet ${taos_service_name}; then echo "TDengine taosd is running, stopping it..." - ${csudo} systemctl stop ${taos_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${taos_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${taosd_service_config} + ${csudo}rm -f ${taosd_service_config} - [ -f ${taosadapter_service_config} ] && ${csudo} rm -f ${taosadapter_service_config} + [ -f ${taosadapter_service_config} ] && ${csudo}rm -f ${taosadapter_service_config} } function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof taosd &> /dev/null; then echo "TDengine taosd is running, stopping it..." - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : fi if ((${initd_mod}==1)); then - ${csudo} chkconfig --del taosd || : + ${csudo}chkconfig --del taosd || : elif ((${initd_mod}==2)); then - ${csudo} insserv -r taosd || : + ${csudo}insserv -r taosd || : elif ((${initd_mod}==3)); then - ${csudo} update-rc.d -f taosd remove || : + ${csudo}update-rc.d -f taosd remove || : fi - ${csudo} rm -f ${service_config_dir}/taosd || : + ${csudo}rm -f ${service_config_dir}/taosd || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -118,20 +118,20 @@ function clean_service() { clean_service # Remove all links -${csudo} rm -f ${bin_link_dir}/taos || : -${csudo} rm -f ${bin_link_dir}/taosd || : -${csudo} rm -f ${bin_link_dir}/taosadapter || : -${csudo} rm -f ${bin_link_dir}/taosdemo || : -${csudo} rm -f ${bin_link_dir}/set_core || : -${csudo} rm -f ${cfg_link_dir}/*.new || : -${csudo} rm -f ${inc_link_dir}/taos.h || : -${csudo} rm -f ${inc_link_dir}/taosdef.h || : -${csudo} rm -f ${inc_link_dir}/taoserror.h || : -${csudo} rm -f ${lib_link_dir}/libtaos.* || : -${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - -${csudo} rm -f ${log_link_dir} || : -${csudo} rm -f ${data_link_dir} || : +${csudo}rm -f ${bin_link_dir}/taos || : +${csudo}rm -f ${bin_link_dir}/taosd || : +${csudo}rm -f ${bin_link_dir}/taosadapter || : +${csudo}rm -f ${bin_link_dir}/taosdemo || : +${csudo}rm -f ${bin_link_dir}/set_core || : +${csudo}rm -f ${cfg_link_dir}/*.new || : +${csudo}rm -f ${inc_link_dir}/taos.h || : +${csudo}rm -f ${inc_link_dir}/taosdef.h || : +${csudo}rm -f ${inc_link_dir}/taoserror.h || : +${csudo}rm -f ${lib_link_dir}/libtaos.* || : +${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + +${csudo}rm -f ${log_link_dir} || : +${csudo}rm -f ${data_link_dir} || : if ((${service_mod}==2)); then kill_taosadapter diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 4f814692ebaacf8017ede030a977af36528a27c1..b9bd1c163809c1d2dabfff6f85ffaa765378cede 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -32,7 +32,7 @@ tarbitrator_service_name="tarbitratord" nginx_service_name="nginxd" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -58,140 +58,140 @@ fi function kill_taosadapter() { pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_taosd() { pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosd || : - ${csudo} rm -f ${bin_link_dir}/taosadapter || : - ${csudo} rm -f ${bin_link_dir}/taosdemo || : - ${csudo} rm -f ${bin_link_dir}/taosdump || : - ${csudo} rm -f ${bin_link_dir}/rmtaos || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/taos || : + ${csudo}rm -f ${bin_link_dir}/taosd || : + ${csudo}rm -f ${bin_link_dir}/taosadapter || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/rmtaos || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } function clean_service_on_systemd() { taosd_service_config="${service_config_dir}/${taos_service_name}.service" if systemctl is-active --quiet ${taos_service_name}; then echo "TDengine taosd is running, stopping it..." - ${csudo} systemctl stop ${taos_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${taos_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${taosd_service_config} + ${csudo}systemctl disable ${taos_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${taosd_service_config} taosadapter_service_config="${service_config_dir}/taosadapter.service" if systemctl is-active --quiet ${taosadapter_service_name}; then echo "TDengine taosAdapter is running, stopping it..." - ${csudo} systemctl stop ${taosadapter_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${taosadapter_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${taosadapter_service_name} &> /dev/null || echo &> /dev/null - [ -f ${taosadapter_service_config} ] && ${csudo} rm -f ${taosadapter_service_config} + ${csudo}systemctl disable ${taosadapter_service_name} &> /dev/null || echo &> /dev/null + [ -f ${taosadapter_service_config} ] && ${csudo}rm -f ${taosadapter_service_config} tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "TDengine tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/${nginx_service_name}.service" if [ -d ${install_nginxd_dir} ]; then if systemctl is-active --quiet ${nginx_service_name}; then echo "Nginx for TDengine is running, stopping it..." - ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${nginx_service_config} fi fi } function clean_service_on_sysvinit() { #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof taosd &> /dev/null; then echo "TDengine taosd is running, stopping it..." - ${csudo} service taosd stop || : + ${csudo}service taosd stop || : fi if pidof tarbitrator &> /dev/null; then echo "TDengine tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/taosd ]; then - ${csudo} chkconfig --del taosd || : + ${csudo}chkconfig --del taosd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/taosd ]; then - ${csudo} insserv -r taosd || : + ${csudo}insserv -r taosd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/taosd ]; then - ${csudo} update-rc.d -f taosd remove || : + ${csudo}update-rc.d -f taosd remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/taosd || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/taosd || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -221,10 +221,10 @@ clean_log # Remove link configuration file clean_config # Remove data link directory -${csudo} rm -rf ${data_link_dir} || : +${csudo}rm -rf ${data_link_dir} || : -${csudo} rm -rf ${install_main_dir} -${csudo} rm -rf ${install_nginxd_dir} +${csudo}rm -rf ${install_main_dir} +${csudo}rm -rf ${install_nginxd_dir} if [[ -e /etc/os-release ]]; then osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) else @@ -233,13 +233,13 @@ fi if echo $osinfo | grep -qwi "ubuntu" ; then # echo "this is ubuntu system" - ${csudo} dpkg --force-all -P tdengine > /dev/null 2>&1 || : + ${csudo}dpkg --force-all -P tdengine > /dev/null 2>&1 || : elif echo $osinfo | grep -qwi "debian" ; then # echo "this is debian system" - ${csudo} dpkg --force-all -P tdengine > /dev/null 2>&1 || : + ${csudo}dpkg --force-all -P tdengine > /dev/null 2>&1 || : elif echo $osinfo | grep -qwi "centos" ; then # echo "this is centos system" - ${csudo} rpm -e --noscripts tdengine > /dev/null 2>&1 || : + ${csudo}rpm -e --noscripts tdengine > /dev/null 2>&1 || : fi echo -e "${GREEN}TDengine is removed successfully!${NC}" diff --git a/packaging/tools/remove_arbi.sh b/packaging/tools/remove_arbi.sh index 4495f25f3617c3c28c6dbd22ddeeda93cdf5423a..0a1162cd7a6793d8542ad5079b8c8cce1659724a 100755 --- a/packaging/tools/remove_arbi.sh +++ b/packaging/tools/remove_arbi.sh @@ -20,7 +20,7 @@ service_config_dir="/etc/systemd/system" tarbitrator_service_name="tarbitratord" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -46,24 +46,24 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_log() { # Remove link - ${csudo} rm -rf /arbitrator.log || : + ${csudo}rm -rf /arbitrator.log || : } function clean_service_on_systemd() { @@ -71,37 +71,37 @@ function clean_service_on_systemd() { if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "TDengine tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then echo "TDengine's tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -125,6 +125,6 @@ clean_bin # Remove log file clean_log -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}TDengine's arbitrator is removed successfully!${NC}" diff --git a/packaging/tools/remove_arbi_jh.sh b/packaging/tools/remove_arbi_jh.sh index 8b690771c761ac51772dac83cafec46360a16be3..018bf793d9df80ed5076fa15e3714975e2c3ea80 100755 --- a/packaging/tools/remove_arbi_jh.sh +++ b/packaging/tools/remove_arbi_jh.sh @@ -19,7 +19,7 @@ service_config_dir="/etc/systemd/system" tarbitrator_service_name="tarbitratord" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -45,24 +45,24 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_log() { # Remove link - ${csudo} rm -rf /arbitrator.log || : + ${csudo}rm -rf /arbitrator.log || : } function clean_service_on_systemd() { @@ -70,37 +70,37 @@ function clean_service_on_systemd() { if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "jh_iot's tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then echo "jh_iot's tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -124,7 +124,7 @@ clean_bin # Remove log file clean_log -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}jh_iot's arbitrator is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_arbi_kh.sh b/packaging/tools/remove_arbi_kh.sh index ec3254b01649add57f9485c59878059e086b2669..2d270ea0bef735e1c307970e4d5b45d6eca56622 100755 --- a/packaging/tools/remove_arbi_kh.sh +++ b/packaging/tools/remove_arbi_kh.sh @@ -19,7 +19,7 @@ service_config_dir="/etc/systemd/system" tarbitrator_service_name="tarbitratord" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -45,24 +45,24 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_log() { # Remove link - ${csudo} rm -rf /arbitrator.log || : + ${csudo}rm -rf /arbitrator.log || : } function clean_service_on_systemd() { @@ -70,37 +70,37 @@ function clean_service_on_systemd() { if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "KingHistorian's tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then echo "KingHistorian's tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -124,7 +124,7 @@ clean_bin # Remove log file clean_log -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}KingHistorian's arbitrator is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_arbi_power.sh b/packaging/tools/remove_arbi_power.sh index 27b08a47e87c28395faa004515702d9e1b51492a..459ca481e32954e8472f5f1c108a597fd59ff129 100755 --- a/packaging/tools/remove_arbi_power.sh +++ b/packaging/tools/remove_arbi_power.sh @@ -20,7 +20,7 @@ service_config_dir="/etc/systemd/system" tarbitrator_service_name="tarbitratord" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -46,24 +46,24 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_log() { # Remove link - ${csudo} rm -rf /arbitrator.log || : + ${csudo}rm -rf /arbitrator.log || : } function clean_service_on_systemd() { @@ -71,37 +71,37 @@ function clean_service_on_systemd() { if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "PowerDB tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then echo "PowerDB's tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -125,7 +125,7 @@ clean_bin # Remove log file clean_log -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}PowerDB's arbitrator is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_arbi_pro.sh b/packaging/tools/remove_arbi_pro.sh index 4bb435cc97e7b31341007ac56c6eb1bbe75a9fda..4a5edff1c6f9b006085977a2c3bf9c9e4fa24326 100755 --- a/packaging/tools/remove_arbi_pro.sh +++ b/packaging/tools/remove_arbi_pro.sh @@ -19,7 +19,7 @@ service_config_dir="/etc/systemd/system" tarbitrator_service_name="tarbitratord" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -45,25 +45,25 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_log() { # Remove link - ${csudo} rm -rf /arbitrator.log || : + ${csudo}rm -rf /arbitrator.log || : } function clean_service_on_systemd() { @@ -71,37 +71,37 @@ function clean_service_on_systemd() { if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "ProDB tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then echo "ProDB's tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -125,7 +125,7 @@ clean_bin # Remove log file clean_log -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}ProDB's arbitrator is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_arbi_tq.sh b/packaging/tools/remove_arbi_tq.sh index e0b401255f1071a21f0a5e09cd9b6e0e307ec5ba..f1b5bed44080f0631689098c6990a5cecdd186f1 100755 --- a/packaging/tools/remove_arbi_tq.sh +++ b/packaging/tools/remove_arbi_tq.sh @@ -20,7 +20,7 @@ service_config_dir="/etc/systemd/system" tarbitrator_service_name="tarbitratord" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -46,24 +46,24 @@ fi function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_log() { # Remove link - ${csudo} rm -rf /arbitrator.log || : + ${csudo}rm -rf /arbitrator.log || : } function clean_service_on_systemd() { @@ -71,37 +71,37 @@ function clean_service_on_systemd() { if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "TQ tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}rm -f ${tarbitratord_service_config} } function clean_service_on_sysvinit() { if pidof tarbitrator &> /dev/null; then echo "TQ's tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -125,7 +125,7 @@ clean_bin # Remove log file clean_log -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}TQ's arbitrator is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_client.sh b/packaging/tools/remove_client.sh index aad8d67d948d566b72820625391ba7592859c079..b7e5a327bfd3b7d81520737b252111889660084d 100755 --- a/packaging/tools/remove_client.sh +++ b/packaging/tools/remove_client.sh @@ -24,47 +24,47 @@ inc_link_dir="/usr/include" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi function kill_client() { #pid=$(ps -ef | grep "taos" | grep -v "grep" | awk '{print $2}') if [ -n "$(pidof taos)" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosdemo || : - ${csudo} rm -f ${bin_link_dir}/taosdump || : - ${csudo} rm -f ${bin_link_dir}/rmtaos || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/taos || : + ${csudo}rm -f ${bin_link_dir}/taosdemo || : + ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/rmtaos || : + ${csudo}rm -f ${bin_link_dir}/set_core || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } # Stop client. @@ -80,7 +80,7 @@ clean_log # Remove link configuration file clean_config -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}TDengine client is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_client_jh.sh b/packaging/tools/remove_client_jh.sh index a3f5dfd10debb0a28211b3682becd083d49ca9c6..491339fb450f9017004f312032ff5f2dbcaa4164 100755 --- a/packaging/tools/remove_client_jh.sh +++ b/packaging/tools/remove_client_jh.sh @@ -20,44 +20,44 @@ inc_link_dir="/usr/include" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi function kill_client() { if [ -n "$(pidof jh_taos)" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/jh_taos || : - ${csudo} rm -f ${bin_link_dir}/jhdemo || : - ${csudo} rm -f ${bin_link_dir}/jh_taosdump || : - ${csudo} rm -f ${bin_link_dir}/rmjh || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/jh_taos || : + ${csudo}rm -f ${bin_link_dir}/jhdemo || : + ${csudo}rm -f ${bin_link_dir}/jh_taosdump || : + ${csudo}rm -f ${bin_link_dir}/rmjh || : + ${csudo}rm -f ${bin_link_dir}/set_core || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } # Stop client. @@ -73,7 +73,7 @@ clean_log # Remove link configuration file clean_config -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}jh_iot client is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_client_kh.sh b/packaging/tools/remove_client_kh.sh index 6a44e875e3426b14400508b1bdbd7510c2ae49cb..56cf49ca820fcc3077c2253d89955048c5ffa273 100755 --- a/packaging/tools/remove_client_kh.sh +++ b/packaging/tools/remove_client_kh.sh @@ -20,44 +20,44 @@ inc_link_dir="/usr/include" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi function kill_client() { if [ -n "$(pidof khclient)" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/khclient || : - ${csudo} rm -f ${bin_link_dir}/khdemo || : - ${csudo} rm -f ${bin_link_dir}/khdump || : - ${csudo} rm -f ${bin_link_dir}/rmkh || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/khclient || : + ${csudo}rm -f ${bin_link_dir}/khdemo || : + ${csudo}rm -f ${bin_link_dir}/khdump || : + ${csudo}rm -f ${bin_link_dir}/rmkh || : + ${csudo}rm -f ${bin_link_dir}/set_core || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } # Stop client. @@ -73,7 +73,7 @@ clean_log # Remove link configuration file clean_config -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}KingHistorian client is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_client_power.sh b/packaging/tools/remove_client_power.sh index 75e9717e54b6e02ad5a5d8b28244caf89ab570fb..f16e7813ef894b23b01b89b365ad2038b5b1bb40 100755 --- a/packaging/tools/remove_client_power.sh +++ b/packaging/tools/remove_client_power.sh @@ -24,47 +24,47 @@ inc_link_dir="/usr/include" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi function kill_client() { #pid=$(ps -ef | grep "power" | grep -v "grep" | awk '{print $2}') if [ -n "$(pidof power)" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/power || : - ${csudo} rm -f ${bin_link_dir}/powerdemo || : - ${csudo} rm -f ${bin_link_dir}/powerdump || : - ${csudo} rm -f ${bin_link_dir}/rmpower || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/power || : + ${csudo}rm -f ${bin_link_dir}/powerdemo || : + ${csudo}rm -f ${bin_link_dir}/powerdump || : + ${csudo}rm -f ${bin_link_dir}/rmpower || : + ${csudo}rm -f ${bin_link_dir}/set_core || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } # Stop client. @@ -80,7 +80,7 @@ clean_log # Remove link configuration file clean_config -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}PowerDB client is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_client_pro.sh b/packaging/tools/remove_client_pro.sh index b7ddb27bf48c3e416523c021d42c6ae468fb04e2..3ed0cef1e98896f8160ae3d5a0c5e89bfc01500f 100755 --- a/packaging/tools/remove_client_pro.sh +++ b/packaging/tools/remove_client_pro.sh @@ -20,45 +20,45 @@ inc_link_dir="/usr/include" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi function kill_client() { if [ -n "$(pidof prodbc)" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/prodbc || : - ${csudo} rm -f ${bin_link_dir}/prodemo || : - ${csudo} rm -f ${bin_link_dir}/prodump || : - ${csudo} rm -f ${bin_link_dir}/rmprodb || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/prodbc || : + ${csudo}rm -f ${bin_link_dir}/prodemo || : + ${csudo}rm -f ${bin_link_dir}/prodump || : + ${csudo}rm -f ${bin_link_dir}/rmprodb || : + ${csudo}rm -f ${bin_link_dir}/set_core || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } # Stop client. @@ -74,7 +74,7 @@ clean_log # Remove link configuration file clean_config -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}ProDB client is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_client_tq.sh b/packaging/tools/remove_client_tq.sh index d701217c77e671a4ad24234bdfb4a196f5545970..a35eb9d46e4e33783b47fa33703764c10ee87b9b 100755 --- a/packaging/tools/remove_client_tq.sh +++ b/packaging/tools/remove_client_tq.sh @@ -24,47 +24,47 @@ inc_link_dir="/usr/include" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi function kill_client() { #pid=$(ps -ef | grep "tq" | grep -v "grep" | awk '{print $2}') if [ -n "$(pidof tq)" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/tq || : - ${csudo} rm -f ${bin_link_dir}/tqdemo || : - ${csudo} rm -f ${bin_link_dir}/tqdump || : - ${csudo} rm -f ${bin_link_dir}/rmtq || : - ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/tq || : + ${csudo}rm -f ${bin_link_dir}/tqdemo || : + ${csudo}rm -f ${bin_link_dir}/tqdump || : + ${csudo}rm -f ${bin_link_dir}/rmtq || : + ${csudo}rm -f ${bin_link_dir}/set_core || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } # Stop client. @@ -80,7 +80,7 @@ clean_log # Remove link configuration file clean_config -${csudo} rm -rf ${install_main_dir} +${csudo}rm -rf ${install_main_dir} echo -e "${GREEN}TQ client is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_jh.sh b/packaging/tools/remove_jh.sh index 6965ba388f99e8a2ac1c33def2f696f8d7c3898e..7b3abff42ad662160cf984adf73abeb51116a422 100755 --- a/packaging/tools/remove_jh.sh +++ b/packaging/tools/remove_jh.sh @@ -28,7 +28,7 @@ tarbitrator_service_name="tarbitratord" nginx_service_name="nginxd" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -54,78 +54,78 @@ fi function kill_process() { pid=$(ps -ef | grep "jh_taosd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/jh_taos || : - ${csudo} rm -f ${bin_link_dir}/jh_taosd || : - ${csudo} rm -f ${bin_link_dir}/jhdemo || : - ${csudo} rm -f ${bin_link_dir}/jh_taosdump || : - ${csudo} rm -f ${bin_link_dir}/rmjh || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/jh_taos || : + ${csudo}rm -f ${bin_link_dir}/jh_taosd || : + ${csudo}rm -f ${bin_link_dir}/jhdemo || : + ${csudo}rm -f ${bin_link_dir}/jh_taosdump || : + ${csudo}rm -f ${bin_link_dir}/rmjh || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } function clean_service_on_systemd() { service_config="${service_config_dir}/${service_name}.service" if systemctl is-active --quiet ${service_name}; then echo "jh_iot's jh_taosd is running, stopping it..." - ${csudo} systemctl stop ${service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${service_config} + ${csudo}systemctl disable ${service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${service_config} tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "jh_iot's tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/${nginx_service_name}.service" if [ -d ${bin_dir}/web ]; then if systemctl is-active --quiet ${nginx_service_name}; then echo "Nginx for jh_iot is running, stopping it..." - ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}rm -f ${nginx_service_config} fi fi } @@ -133,42 +133,42 @@ function clean_service_on_systemd() { function clean_service_on_sysvinit() { if pidof jh_taosd &> /dev/null; then echo "jh_iot's jh_taosd is running, stopping it..." - ${csudo} service jh_taosd stop || : + ${csudo}service jh_taosd stop || : fi if pidof tarbitrator &> /dev/null; then echo "jh_iot's tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/jh_taosd ]; then - ${csudo} chkconfig --del jh_taosd || : + ${csudo}chkconfig --del jh_taosd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/jh_taosd ]; then - ${csudo} insserv -r jh_taosd || : + ${csudo}insserv -r jh_taosd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/jh_taosd ]; then - ${csudo} update-rc.d -f jh_taosd remove || : + ${csudo}update-rc.d -f jh_taosd remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/jh_taosd || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/jh_taosd || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -196,10 +196,10 @@ clean_log # Remove link configuration file clean_config # Remove data link directory -${csudo} rm -rf ${data_link_dir} || : +${csudo}rm -rf ${data_link_dir} || : -${csudo} rm -rf ${install_main_dir} -${csudo} rm -rf ${install_nginxd_dir} +${csudo}rm -rf ${install_main_dir} +${csudo}rm -rf ${install_nginxd_dir} if [[ -e /etc/os-release ]]; then osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) else diff --git a/packaging/tools/remove_kh.sh b/packaging/tools/remove_kh.sh index cf6a93fdf2bf8884bda02b4f44058eb7f8d77210..0c830455c7ef4950384f456ed55a7dd9ca706bfb 100755 --- a/packaging/tools/remove_kh.sh +++ b/packaging/tools/remove_kh.sh @@ -28,7 +28,7 @@ tarbitrator_service_name="tarbitratord" nginx_service_name="nginxd" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -54,78 +54,78 @@ fi function kill_process() { pid=$(ps -ef | grep "khserver" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/khclient || : - ${csudo} rm -f ${bin_link_dir}/khserver || : - ${csudo} rm -f ${bin_link_dir}/khdemo || : - ${csudo} rm -f ${bin_link_dir}/khdump || : - ${csudo} rm -f ${bin_link_dir}/rmkh || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/khclient || : + ${csudo}rm -f ${bin_link_dir}/khserver || : + ${csudo}rm -f ${bin_link_dir}/khdemo || : + ${csudo}rm -f ${bin_link_dir}/khdump || : + ${csudo}rm -f ${bin_link_dir}/rmkh || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } function clean_service_on_systemd() { service_config="${service_config_dir}/${service_name}.service" if systemctl is-active --quiet ${service_name}; then echo "KingHistorian's khserver is running, stopping it..." - ${csudo} systemctl stop ${service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${service_config} + ${csudo}systemctl disable ${service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${service_config} tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "KingHistorian's tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/${nginx_service_name}.service" if [ -d ${bin_dir}/web ]; then if systemctl is-active --quiet ${nginx_service_name}; then echo "Nginx for KingHistorian is running, stopping it..." - ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}rm -f ${nginx_service_config} fi fi } @@ -133,42 +133,42 @@ function clean_service_on_systemd() { function clean_service_on_sysvinit() { if pidof khserver &> /dev/null; then echo "KingHistorian's khserver is running, stopping it..." - ${csudo} service khserver stop || : + ${csudo}service khserver stop || : fi if pidof tarbitrator &> /dev/null; then echo "KingHistorian's tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/khserver ]; then - ${csudo} chkconfig --del khserver || : + ${csudo}chkconfig --del khserver || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/khserver ]; then - ${csudo} insserv -r khserver || : + ${csudo}insserv -r khserver || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/khserver ]; then - ${csudo} update-rc.d -f khserver remove || : + ${csudo}update-rc.d -f khserver remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/khserver || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/khserver || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -196,10 +196,10 @@ clean_log # Remove link configuration file clean_config # Remove data link directory -${csudo} rm -rf ${data_link_dir} || : +${csudo}rm -rf ${data_link_dir} || : -${csudo} rm -rf ${install_main_dir} -${csudo} rm -rf ${install_nginxd_dir} +${csudo}rm -rf ${install_main_dir} +${csudo}rm -rf ${install_nginxd_dir} if [[ -e /etc/os-release ]]; then osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) else diff --git a/packaging/tools/remove_power.sh b/packaging/tools/remove_power.sh index 70d0095f978f8c7a2578c63110cdd118fef43e30..4216147bdf63b3e102d94a668abafd1de18c5ac1 100755 --- a/packaging/tools/remove_power.sh +++ b/packaging/tools/remove_power.sh @@ -31,7 +31,7 @@ tarbitrator_service_name="tarbitratord" nginx_service_name="nginxd" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -57,79 +57,79 @@ fi function kill_powerd() { pid=$(ps -ef | grep "powerd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/power || : - ${csudo} rm -f ${bin_link_dir}/powerd || : - ${csudo} rm -f ${bin_link_dir}/powerdemo || : - ${csudo} rm -f ${bin_link_dir}/powerdump || : - ${csudo} rm -f ${bin_link_dir}/rmpower || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/power || : + ${csudo}rm -f ${bin_link_dir}/powerd || : + ${csudo}rm -f ${bin_link_dir}/powerdemo || : + ${csudo}rm -f ${bin_link_dir}/powerdump || : + ${csudo}rm -f ${bin_link_dir}/rmpower || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } function clean_service_on_systemd() { power_service_config="${service_config_dir}/${power_service_name}.service" if systemctl is-active --quiet ${power_service_name}; then echo "PowerDB powerd is running, stopping it..." - ${csudo} systemctl stop ${power_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${power_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${power_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${power_service_config} + ${csudo}systemctl disable ${power_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${power_service_config} tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "PowerDB tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/${nginx_service_name}.service" if [ -d ${bin_dir}/web ]; then if systemctl is-active --quiet ${nginx_service_name}; then echo "Nginx for PowerDB is running, stopping it..." - ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}rm -f ${nginx_service_config} fi fi } @@ -137,42 +137,42 @@ function clean_service_on_systemd() { function clean_service_on_sysvinit() { if pidof powerd &> /dev/null; then echo "PowerDB powerd is running, stopping it..." - ${csudo} service powerd stop || : + ${csudo}service powerd stop || : fi if pidof tarbitrator &> /dev/null; then echo "PowerDB tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/powerd ]; then - ${csudo} chkconfig --del powerd || : + ${csudo}chkconfig --del powerd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/powerd ]; then - ${csudo} insserv -r powerd || : + ${csudo}insserv -r powerd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/powerd ]; then - ${csudo} update-rc.d -f powerd remove || : + ${csudo}update-rc.d -f powerd remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/powerd || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/powerd || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -200,10 +200,10 @@ clean_log # Remove link configuration file clean_config # Remove data link directory -${csudo} rm -rf ${data_link_dir} || : +${csudo}rm -rf ${data_link_dir} || : -${csudo} rm -rf ${install_main_dir} -${csudo} rm -rf ${install_nginxd_dir} +${csudo}rm -rf ${install_main_dir} +${csudo}rm -rf ${install_nginxd_dir} if [[ -e /etc/os-release ]]; then osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) else @@ -212,13 +212,13 @@ fi #if echo $osinfo | grep -qwi "ubuntu" ; then ## echo "this is ubuntu system" -# ${csudo} rm -f /var/lib/dpkg/info/tdengine* || : +# ${csudo}rm -f /var/lib/dpkg/info/tdengine* || : #elif echo $osinfo | grep -qwi "debian" ; then ## echo "this is debian system" -# ${csudo} rm -f /var/lib/dpkg/info/tdengine* || : +# ${csudo}rm -f /var/lib/dpkg/info/tdengine* || : #elif echo $osinfo | grep -qwi "centos" ; then ## echo "this is centos system" -# ${csudo} rpm -e --noscripts tdengine || : +# ${csudo}rpm -e --noscripts tdengine || : #fi echo -e "${GREEN}PowerDB is removed successfully!${NC}" diff --git a/packaging/tools/remove_pro.sh b/packaging/tools/remove_pro.sh index 1572a7f08c6083f7da3d81176f107e4cb977d4f9..f9e8069bb5bb14b44520d0bea3edf2225e6d6b06 100755 --- a/packaging/tools/remove_pro.sh +++ b/packaging/tools/remove_pro.sh @@ -28,7 +28,7 @@ tarbitrator_service_name="tarbitratord" nginx_service_name="nginxd" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -54,79 +54,79 @@ fi function kill_prodbs() { pid=$(ps -ef | grep "prodbs" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/prodbc || : - ${csudo} rm -f ${bin_link_dir}/prodbs || : - ${csudo} rm -f ${bin_link_dir}/prodemo || : - ${csudo} rm -f ${bin_link_dir}/prodump || : - ${csudo} rm -f ${bin_link_dir}/rmprodb || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/prodbc || : + ${csudo}rm -f ${bin_link_dir}/prodbs || : + ${csudo}rm -f ${bin_link_dir}/prodemo || : + ${csudo}rm -f ${bin_link_dir}/prodump || : + ${csudo}rm -f ${bin_link_dir}/rmprodb || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } function clean_service_on_systemd() { prodb_service_config="${service_config_dir}/${prodb_service_name}.service" if systemctl is-active --quiet ${prodb_service_name}; then echo "ProDB prodbs is running, stopping it..." - ${csudo} systemctl stop ${prodb_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${prodb_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${prodb_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${prodb_service_config} + ${csudo}systemctl disable ${prodb_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${prodb_service_config} tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "ProDB tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/${nginx_service_name}.service" if [ -d ${bin_dir}/web ]; then if systemctl is-active --quiet ${nginx_service_name}; then echo "Nginx for ProDB is running, stopping it..." - ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}rm -f ${nginx_service_config} fi fi } @@ -134,42 +134,42 @@ function clean_service_on_systemd() { function clean_service_on_sysvinit() { if pidof prodbs &> /dev/null; then echo "ProDB prodbs is running, stopping it..." - ${csudo} service prodbs stop || : + ${csudo}service prodbs stop || : fi if pidof tarbitrator &> /dev/null; then echo "ProDB tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/prodbs ]; then - ${csudo} chkconfig --del prodbs || : + ${csudo}chkconfig --del prodbs || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/prodbs ]; then - ${csudo} insserv -r prodbs || : + ${csudo}insserv -r prodbs || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/prodbs ]; then - ${csudo} update-rc.d -f prodbs remove || : + ${csudo}update-rc.d -f prodbs remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/prodbs || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/prodbs || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -197,10 +197,10 @@ clean_log # Remove link configuration file clean_config # Remove data link directory -${csudo} rm -rf ${data_link_dir} || : +${csudo}rm -rf ${data_link_dir} || : -${csudo} rm -rf ${install_main_dir} -${csudo} rm -rf ${install_nginxd_dir} +${csudo}rm -rf ${install_main_dir} +${csudo}rm -rf ${install_nginxd_dir} if [[ -e /etc/os-release ]]; then osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) else diff --git a/packaging/tools/remove_tq.sh b/packaging/tools/remove_tq.sh index eb83b92d1a5ef7e9e4ac498d98cc538a34da2a4f..e9a071f7d6b6bd5ae89c12cf8db5de014dbc2d52 100755 --- a/packaging/tools/remove_tq.sh +++ b/packaging/tools/remove_tq.sh @@ -31,7 +31,7 @@ tarbitrator_service_name="tarbitratord" nginx_service_name="nginxd" csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi initd_mod=0 @@ -57,125 +57,125 @@ fi function kill_tqd() { pid=$(ps -ef | grep "tqd" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function kill_tarbitrator() { pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then - ${csudo} kill -9 $pid || : + ${csudo}kill -9 $pid || : fi } function clean_bin() { # Remove link - ${csudo} rm -f ${bin_link_dir}/tq || : - ${csudo} rm -f ${bin_link_dir}/tqd || : - ${csudo} rm -f ${bin_link_dir}/tqdemo || : - ${csudo} rm -f ${bin_link_dir}/tqdump || : - ${csudo} rm -f ${bin_link_dir}/rmtq || : - ${csudo} rm -f ${bin_link_dir}/tarbitrator || : - ${csudo} rm -f ${bin_link_dir}/set_core || : - ${csudo} rm -f ${bin_link_dir}/run_taosd.sh || : + ${csudo}rm -f ${bin_link_dir}/tq || : + ${csudo}rm -f ${bin_link_dir}/tqd || : + ${csudo}rm -f ${bin_link_dir}/tqdemo || : + ${csudo}rm -f ${bin_link_dir}/tqdump || : + ${csudo}rm -f ${bin_link_dir}/rmtq || : + ${csudo}rm -f ${bin_link_dir}/tarbitrator || : + ${csudo}rm -f ${bin_link_dir}/set_core || : + ${csudo}rm -f ${bin_link_dir}/run_taosd.sh || : } function clean_lib() { # Remove link - ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : - #${csudo} rm -rf ${v15_java_app_dir} || : + ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo}rm -rf ${v15_java_app_dir} || : } function clean_header() { # Remove link - ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taosdef.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { # Remove link - ${csudo} rm -f ${cfg_link_dir}/* || : + ${csudo}rm -f ${cfg_link_dir}/* || : } function clean_log() { # Remove link - ${csudo} rm -rf ${log_link_dir} || : + ${csudo}rm -rf ${log_link_dir} || : } function clean_service_on_systemd() { tq_service_config="${service_config_dir}/${tq_service_name}.service" if systemctl is-active --quiet ${tq_service_name}; then echo "TQ tqd is running, stopping it..." - ${csudo} systemctl stop ${tq_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tq_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tq_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tq_service_config} + ${csudo}systemctl disable ${tq_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tq_service_config} tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then echo "TQ tarbitrator is running, stopping it..." - ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo}rm -f ${tarbitratord_service_config} if [ "$verMode" == "cluster" ]; then nginx_service_config="${service_config_dir}/${nginx_service_name}.service" if [ -d ${bin_dir}/web ]; then if systemctl is-active --quiet ${nginx_service_name}; then echo "Nginx for TQ is running, stopping it..." - ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null fi - ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null + ${csudo}systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null - ${csudo} rm -f ${nginx_service_config} + ${csudo}rm -f ${nginx_service_config} fi fi } function clean_service_on_sysvinit() { #restart_config_str="tq:2345:respawn:${service_config_dir}/tqd start" - #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + #${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || : if pidof tqd &> /dev/null; then echo "TQ tqd is running, stopping it..." - ${csudo} service tqd stop || : + ${csudo}service tqd stop || : fi if pidof tarbitrator &> /dev/null; then echo "TQ tarbitrator is running, stopping it..." - ${csudo} service tarbitratord stop || : + ${csudo}service tarbitratord stop || : fi if ((${initd_mod}==1)); then if [ -e ${service_config_dir}/tqd ]; then - ${csudo} chkconfig --del tqd || : + ${csudo}chkconfig --del tqd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} chkconfig --del tarbitratord || : + ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod}==2)); then if [ -e ${service_config_dir}/tqd ]; then - ${csudo} insserv -r tqd || : + ${csudo}insserv -r tqd || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} insserv -r tarbitratord || : + ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod}==3)); then if [ -e ${service_config_dir}/tqd ]; then - ${csudo} update-rc.d -f tqd remove || : + ${csudo}update-rc.d -f tqd remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo} update-rc.d -f tarbitratord remove || : + ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo} rm -f ${service_config_dir}/tqd || : - ${csudo} rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/tqd || : + ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &> /dev/null); then - ${csudo} init q || : + ${csudo}init q || : fi } @@ -203,10 +203,10 @@ clean_log # Remove link configuration file clean_config # Remove data link directory -${csudo} rm -rf ${data_link_dir} || : +${csudo}rm -rf ${data_link_dir} || : -${csudo} rm -rf ${install_main_dir} -${csudo} rm -rf ${install_nginxd_dir} +${csudo}rm -rf ${install_main_dir} +${csudo}rm -rf ${install_nginxd_dir} if [[ -e /etc/os-release ]]; then osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) else diff --git a/packaging/tools/set_core.sh b/packaging/tools/set_core.sh index f515fd3dc5ed4a26fc7f4120573d39303ea3d751..db95aeb34346b161d979b074e0cb50c017e0bc6d 100755 --- a/packaging/tools/set_core.sh +++ b/packaging/tools/set_core.sh @@ -15,7 +15,7 @@ corePath=$1 csudo="" if command -v sudo > /dev/null; then - csudo="sudo" + csudo="sudo " fi if [[ ! -n ${corePath} ]]; then @@ -31,10 +31,10 @@ if [[ ! -n ${corePath} ]]; then fi ulimit -c unlimited -${csudo} sed -i '/ulimit -c unlimited/d' /etc/profile ||: -${csudo} sed -i '$a\ulimit -c unlimited' /etc/profile ||: +${csudo}sed -i '/ulimit -c unlimited/d' /etc/profile ||: +${csudo}sed -i '$a\ulimit -c unlimited' /etc/profile ||: source /etc/profile -${csudo} mkdir -p ${corePath} ||: -${csudo} sysctl -w kernel.core_pattern=${corePath}/core-%e-%p ||: -${csudo} echo "${corePath}/core-%e-%p" | ${csudo} tee /proc/sys/kernel/core_pattern ||: +${csudo}mkdir -p ${corePath} ||: +${csudo}sysctl -w kernel.core_pattern=${corePath}/core-%e-%p ||: +${csudo}echo "${corePath}/core-%e-%p" | ${csudo}tee /proc/sys/kernel/core_pattern ||: diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 085b949cc102e3752abd41caacdf07985351e1db..0d43e101754e9ae3eb33440005790f238f6664a5 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -795,69 +795,69 @@ static int32_t arrangePointsByChildTableName(TAOS_SML_DATA_POINT* points, int nu static int32_t applyChildTableDataPointsWithInsertSQL(TAOS* taos, char* cTableName, char* sTableName, SSmlSTableSchema* sTableSchema, SArray* cTablePoints, size_t rowSize, SSmlLinesInfo* info) { int32_t code = TSDB_CODE_SUCCESS; - size_t numTags = taosArrayGetSize(sTableSchema->tags); - size_t numCols = taosArrayGetSize(sTableSchema->fields); - size_t rows = taosArrayGetSize(cTablePoints); + size_t numTags = taosArrayGetSize(sTableSchema->tags); + size_t numCols = taosArrayGetSize(sTableSchema->fields); + size_t rows = taosArrayGetSize(cTablePoints); SArray* tagsSchema = sTableSchema->tags; SArray* colsSchema = sTableSchema->fields; TAOS_SML_KV* tagKVs[TSDB_MAX_TAGS] = {0}; - for (int i= 0; i < rows; ++i) { - TAOS_SML_DATA_POINT * pDataPoint = taosArrayGetP(cTablePoints, i); + for (int i = 0; i < rows; ++i) { + TAOS_SML_DATA_POINT* pDataPoint = taosArrayGetP(cTablePoints, i); for (int j = 0; j < pDataPoint->tagNum; ++j) { TAOS_SML_KV* kv = pDataPoint->tags + j; tagKVs[kv->fieldSchemaIdx] = kv; } } - char* sql = malloc(tsMaxSQLStringLen+1); + char* sql = malloc(tsMaxSQLStringLen + 1); if (sql == NULL) { tscError("malloc sql memory error"); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - int32_t freeBytes = tsMaxSQLStringLen + 1 ; + int32_t freeBytes = tsMaxSQLStringLen + 1; int32_t totalLen = 0; totalLen += sprintf(sql, "insert into %s using %s (", cTableName, sTableName); for (int i = 0; i < numTags; ++i) { SSchema* tagSchema = taosArrayGet(tagsSchema, i); - totalLen += snprintf(sql+totalLen, freeBytes-totalLen, "%s,", tagSchema->name); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, "%s,", tagSchema->name); } --totalLen; - totalLen += snprintf(sql + totalLen, freeBytes-totalLen, ")"); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, ")"); - totalLen += snprintf(sql + totalLen, freeBytes-totalLen, " tags ("); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, " tags ("); -// for (int i = 0; i < numTags; ++i) { -// snprintf(sql+strlen(sql), freeBytes-strlen(sql), "?,"); -// } + // for (int i = 0; i < numTags; ++i) { + // snprintf(sql+strlen(sql), freeBytes-strlen(sql), "?,"); + // } for (int i = 0; i < numTags; ++i) { if (tagKVs[i] == NULL) { - totalLen += snprintf(sql + totalLen, freeBytes-totalLen, "NULL,"); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, "NULL,"); } else { - TAOS_SML_KV* kv = tagKVs[i]; - size_t beforeLen = totalLen; - int32_t len = 0; - converToStr(sql+beforeLen, kv->type, kv->value, kv->length, &len); + TAOS_SML_KV* kv = tagKVs[i]; + size_t beforeLen = totalLen; + int32_t len = 0; + converToStr(sql + beforeLen, kv->type, kv->value, kv->length, &len); totalLen += len; - totalLen += snprintf(sql+totalLen, freeBytes-totalLen, ","); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, ","); } } --totalLen; - totalLen += snprintf(sql + totalLen, freeBytes-totalLen, ") ("); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, ") ("); for (int i = 0; i < numCols; ++i) { SSchema* colSchema = taosArrayGet(colsSchema, i); - totalLen += snprintf(sql+totalLen, freeBytes-totalLen, "%s,", colSchema->name); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, "%s,", colSchema->name); } --totalLen; - totalLen += snprintf(sql + totalLen, freeBytes-totalLen, ") values "); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, ") values "); - TAOS_SML_KV** colKVs = malloc(numCols*sizeof(TAOS_SML_KV*)); + TAOS_SML_KV** colKVs = malloc(numCols * sizeof(TAOS_SML_KV*)); for (int r = 0; r < rows; ++r) { - totalLen += snprintf(sql + totalLen, freeBytes-totalLen, "("); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, "("); - memset(colKVs, 0, numCols*sizeof(TAOS_SML_KV*)); + memset(colKVs, 0, numCols * sizeof(TAOS_SML_KV*)); TAOS_SML_DATA_POINT* point = taosArrayGetP(cTablePoints, r); for (int i = 0; i < point->fieldNum; ++i) { @@ -867,28 +867,68 @@ static int32_t applyChildTableDataPointsWithInsertSQL(TAOS* taos, char* cTableNa for (int i = 0; i < numCols; ++i) { if (colKVs[i] == NULL) { - totalLen += snprintf(sql + totalLen, freeBytes-totalLen, "NULL,"); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, "NULL,"); } else { - TAOS_SML_KV* kv = colKVs[i]; - size_t beforeLen = totalLen; - int32_t len = 0; - converToStr(sql+beforeLen, kv->type, kv->value, kv->length, &len); + TAOS_SML_KV* kv = colKVs[i]; + size_t beforeLen = totalLen; + int32_t len = 0; + converToStr(sql + beforeLen, kv->type, kv->value, kv->length, &len); totalLen += len; - totalLen += snprintf(sql+totalLen, freeBytes-totalLen, ","); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, ","); } } --totalLen; - totalLen += snprintf(sql+totalLen, freeBytes - totalLen, ")"); + totalLen += snprintf(sql + totalLen, freeBytes - totalLen, ")"); } free(colKVs); sql[totalLen] = '\0'; - tscDebug("SML:0x%"PRIx64" insert child table table %s of super table %s sql: %s", info->id, cTableName, sTableName, sql); - TAOS_RES* res = taos_query(taos, sql); + tscDebug("SML:0x%" PRIx64 " insert child table table %s of super table %s sql: %s", info->id, cTableName, sTableName, + sql); + + bool tryAgain = false; + int32_t try = 0; + do { + TAOS_RES* res = taos_query(taos, sql); + code = taos_errno(res); + if (code != 0) { + tscError("SML:0x%"PRIx64 " taos_query return %d:%s", info->id, code, taos_errstr(res)); + } + + tscDebug("SML:0x%"PRIx64 " taos_query inserted %d rows", info->id, taos_affected_rows(res)); + info->affectedRows += taos_affected_rows(res); + taos_free_result(res); + + tryAgain = false; + if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID + || code == TSDB_CODE_VND_INVALID_VGROUP_ID + || code == TSDB_CODE_TDB_TABLE_RECONFIGURE + || code == TSDB_CODE_APP_NOT_READY + || code == TSDB_CODE_RPC_NETWORK_UNAVAIL) && try++ < TSDB_MAX_REPLICA) { + tryAgain = true; + } + + if (code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) { + TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE"); + int32_t code2 = taos_errno(res2); + if (code2 != TSDB_CODE_SUCCESS) { + tscError("SML:0x%" PRIx64 " insert child table by sql. reset query cache. error: %s", info->id, taos_errstr(res2)); + } + taos_free_result(res2); + if (tryAgain) { + taosMsleep(100 * (2 << try)); + } + } + + if (code == TSDB_CODE_APP_NOT_READY || code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { + if (tryAgain) { + taosMsleep( 100 * (2 << try)); + } + } + } while (tryAgain); + free(sql); - code = taos_errno(res); - info->affectedRows += taos_affected_rows(res); - taos_free_result(res); + return code; } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 90851179507747170c950712e794d62b4babb9f7..3032b27b9cab6005d9cde120ede7fde831df181f 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -191,7 +191,7 @@ bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType, } if (colType == TSDB_DATA_TYPE_BOOL && (var->i64 > 1 ||var->i64 < 0)) { break; - } + } tbufWriteInt64(&bw, var->i64); } else if (IS_UNSIGNED_NUMERIC_TYPE(colType)) { if (IS_SIGNED_NUMERIC_TYPE(var->nType) || IS_UNSIGNED_NUMERIC_TYPE(var->nType)) { @@ -603,11 +603,11 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { char buf[TSDB_TABLE_FNAME_LEN]; SStrToken sTblToken; sTblToken.z = buf; - + if (pInfo->type != TSDB_SQL_DROP_DNODE) { if ((escapeEnabled && (validateTableName(pzName->z, pzName->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS)) || ((!escapeEnabled) && (tscValidateName(pzName, escapeEnabled, &dbIncluded) != TSDB_CODE_SUCCESS))){ - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } } @@ -623,7 +623,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { code = tscSetTableFullName(&pTableMetaInfo->name, &sTblToken, pSql, dbIncluded); if(code != TSDB_CODE_SUCCESS) { - return code; + return code; } } else if (pInfo->type == TSDB_SQL_DROP_DNODE) { if (pzName->type == TK_STRING) { @@ -765,7 +765,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { char buf[TSDB_TABLE_FNAME_LEN]; SStrToken sTblToken; sTblToken.z = buf; - + if (validateTableName(pToken->z, pToken->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -788,7 +788,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { char buf[TSDB_TABLE_FNAME_LEN]; SStrToken sTblToken; sTblToken.z = buf; - + if (validateTableName(pToken->z, pToken->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -804,7 +804,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg1 = "invalid database name"; SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0); - + if (tscValidateName(pToken, false, NULL) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -2175,16 +2175,16 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS pQueryInfo->colList = taosArrayInit(4, POINTER_BYTES); } - + bool hasDistinct = false; - bool hasAgg = false; + bool hasAgg = false; size_t numOfExpr = taosArrayGetSize(pSelNodeList); - int32_t distIdx = -1; + int32_t distIdx = -1; for (int32_t i = 0; i < numOfExpr; ++i) { int32_t outputIndex = (int32_t)tscNumOfExprs(pQueryInfo); tSqlExprItem* pItem = taosArrayGet(pSelNodeList, i); if (hasDistinct == false) { - hasDistinct = (pItem->distinct == true); + hasDistinct = (pItem->distinct == true); distIdx = hasDistinct ? i : -1; } if(pItem->aliasName != NULL && validateColumnName(pItem->aliasName) != TSDB_CODE_SUCCESS){ @@ -2202,7 +2202,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS return code; } } else if (type == SQL_NODE_SQLFUNCTION) { - hasAgg = true; + hasAgg = true; if (hasDistinct) break; pItem->pNode->functionId = isValidFunction(pItem->pNode->Expr.operand.z, pItem->pNode->Expr.operand.n); @@ -2252,12 +2252,12 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS } } - //TODO(dengyihao), refactor as function - //handle distinct func mixed with other func + //TODO(dengyihao), refactor as function + //handle distinct func mixed with other func if (hasDistinct == true) { if (distIdx != 0 || hasAgg) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); - } + } if (joinQuery) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); } @@ -2267,11 +2267,11 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS if (pQueryInfo->pDownstream != NULL) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); } - + pQueryInfo->distinct = true; } - - + + // there is only one user-defined column in the final result field, add the timestamp column. size_t numOfSrcCols = taosArrayGetSize(pQueryInfo->colList); if ((numOfSrcCols <= 0 || !hasNoneUserDefineExpr(pQueryInfo)) && !tscQueryTags(pQueryInfo) && !tscQueryBlockInfo(pQueryInfo)) { @@ -2490,6 +2490,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t /*SExprInfo* pExpr = */ tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, &colSchema, TSDB_COL_TAG, getNewResColId(pCmd)); } + pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; } else { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; @@ -4693,7 +4694,12 @@ static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr, if (pExpr->value.nType == (uint32_t)-1) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } - + + //now allowing now +/- value in select expr + if (pExpr->tokenId == TK_TIMESTAMP) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + } + if (pExpr->type == SQL_NODE_VALUE) { *type = SQLEXPR_TYPE_VALUE; } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 874a022a7104860fce8f6389bcc933b36a2fef22..3c1d4f453c2f8be75b9eddfaf02f30b0b25f6ab8 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -5522,6 +5522,11 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in varDataSetLen(tagData, outLen); tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, tagVal, true); }else if(item->type == cJSON_Number){ + if(!isfinite(item->valuedouble)){ + tscError("json value is invalidate"); + retCode = tscSQLSyntaxErrMsg(errMsg, "json value number is illegal", NULL); + goto end; + } char tagVal[LONG_BYTES + CHAR_BYTES] = {0}; *tagVal = jsonType2DbType(item->valuedouble, item->type); // type char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES); diff --git a/src/connector/C#/src/test/Cases/Utils.cs b/src/connector/C#/src/test/Cases/Utils.cs index 1c2ab137930384c0a85ae2103ff6be0893d7733b..5a2962564fb9063e8994e549f0135cedb36b6ec5 100644 --- a/src/connector/C#/src/test/Cases/Utils.cs +++ b/src/connector/C#/src/test/Cases/Utils.cs @@ -3,7 +3,6 @@ using TDengineDriver; using System.Runtime.InteropServices; using System.Text; using System.Collections.Generic; - namespace Test.UtilsTools { public class UtilsTools diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java index d4c30115f851aa0f8b6f80994bbece609649428d..78420083a1d235036203bb3d57b2617663032d8d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java @@ -14,13 +14,43 @@ import java.math.BigDecimal; import java.sql.*; import java.time.Instant; import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.chrono.IsoChronology; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; +import java.time.format.ResolverStyle; +import java.time.temporal.ChronoField; import java.util.ArrayList; import java.util.Calendar; import java.util.List; public class RestfulResultSet extends AbstractResultSet implements ResultSet { + public static DateTimeFormatter rfc3339Parser = null; + + { + rfc3339Parser = new DateTimeFormatterBuilder() + .parseCaseInsensitive() + .appendValue(ChronoField.YEAR, 4) + .appendLiteral('-') + .appendValue(ChronoField.MONTH_OF_YEAR, 2) + .appendLiteral('-') + .appendValue(ChronoField.DAY_OF_MONTH, 2) + .appendLiteral('T') + .appendValue(ChronoField.HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(ChronoField.MINUTE_OF_HOUR, 2) + .appendLiteral(':') + .appendValue(ChronoField.SECOND_OF_MINUTE, 2) + .optionalStart() + .appendFraction(ChronoField.NANO_OF_SECOND, 2, 9, true) + .optionalEnd() + .appendOffset("+HH:MM", "Z").toFormatter() + .withResolverStyle(ResolverStyle.STRICT) + .withChronology(IsoChronology.INSTANCE); + } + private final Statement statement; // data private final List> resultSet = new ArrayList<>(); @@ -187,25 +217,41 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { } case UTC: { String value = row.getString(colIndex); - long epochSec = Timestamp.valueOf(value.substring(0, 19).replace("T", " ")).getTime() / 1000; - int fractionalSec = Integer.parseInt(value.substring(20, value.length() - 5)); - long nanoAdjustment; - if (value.length() > 31) { - // ns timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSSSSS+0x00 - nanoAdjustment = fractionalSec; - this.timestampPrecision = TimestampPrecision.NS; - } else if (value.length() > 28) { - // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x00 - nanoAdjustment = fractionalSec * 1000L; - this.timestampPrecision = TimestampPrecision.US; + if (value.lastIndexOf(":") > 19) { + ZonedDateTime parse = ZonedDateTime.parse(value, rfc3339Parser); + long nanoAdjustment; + if (value.length() > 32) { + // ns timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSSSSS+0x:00 + this.timestampPrecision = TimestampPrecision.NS; + } else if (value.length() > 29) { + // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x:00 + this.timestampPrecision = TimestampPrecision.US; + } else { + // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSS+0x:00 + this.timestampPrecision = TimestampPrecision.MS; + } + return Timestamp.from(parse.toInstant()); } else { - // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSS+0x00 - nanoAdjustment = fractionalSec * 1000_000L; - this.timestampPrecision = TimestampPrecision.MS; + long epochSec = Timestamp.valueOf(value.substring(0, 19).replace("T", " ")).getTime() / 1000; + int fractionalSec = Integer.parseInt(value.substring(20, value.length() - 5)); + long nanoAdjustment; + if (value.length() > 32) { + // ns timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSSSSS+0x00 + nanoAdjustment = fractionalSec; + this.timestampPrecision = TimestampPrecision.NS; + } else if (value.length() > 29) { + // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSSSSS+0x00 + nanoAdjustment = fractionalSec * 1000L; + this.timestampPrecision = TimestampPrecision.US; + } else { + // ms timestamp: yyyy-MM-ddTHH:mm:ss.SSS+0x00 + nanoAdjustment = fractionalSec * 1000_000L; + this.timestampPrecision = TimestampPrecision.MS; + } + ZoneOffset zoneOffset = ZoneOffset.of(value.substring(value.length() - 5)); + Instant instant = Instant.ofEpochSecond(epochSec, nanoAdjustment).atOffset(zoneOffset).toInstant(); + return Timestamp.from(instant); } - ZoneOffset zoneOffset = ZoneOffset.of(value.substring(value.length() - 5)); - Instant instant = Instant.ofEpochSecond(epochSec, nanoAdjustment).atOffset(zoneOffset).toInstant(); - return Timestamp.from(instant); } case STRING: default: { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java index cdcd2eec482cc39e940bf20f6ae636568257faf2..dada75e4a04b035cbe20da72075215c77f1c5883 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java @@ -72,6 +72,7 @@ public class RestfulStatement extends AbstractStatement { } this.database = sql.trim().replace("use", "").trim(); this.conn.setCatalog(this.database); + this.conn.setClientInfo(TSDBDriver.PROPERTY_KEY_DBNAME, this.database); result = false; } else if (SqlSyntaxValidator.isDatabaseUnspecifiedQuery(sql)) { executeOneQuery(sql); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ParameterBindTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ParameterBindTest.java index 46f201d1c0a525f52014d133e25fc0db4741050c..63c3a6318a611f7159c0ac16dc85cd5e05de47c0 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ParameterBindTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ParameterBindTest.java @@ -128,8 +128,8 @@ public class ParameterBindTest { @After public void after() { try { -// Statement stmt = conn.createStatement(); -// stmt.execute("drop database if exists test_pd"); + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists test_pd"); if (conn != null) conn.close(); } catch (SQLException e) { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java index 712cc0c8c1b0b094a20db0fe36d33f553878d71d..cc47a47f1cd2f0a0c8efdde5ab7afa39b395a16d 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java @@ -187,7 +187,6 @@ public class SchemalessInsertTest { public void after() { try (Statement stmt = conn.createStatement()) { stmt.execute("drop database if exists " + dbname); - stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java index 64b7ab1cabe2c5815ff87d9881873150f21049c6..c69a556ae4e6c6b31dbb106c7ff4a3e2352296ee 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBConnectionTest.java @@ -380,8 +380,12 @@ public class TSDBConnectionTest { @AfterClass public static void afterClass() throws SQLException { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists test"); + statement.close(); conn.close(); + } } } \ No newline at end of file diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java index 9f297955d687f3cfcc3acef626e1f905ecee6bdf..609523f522724a9bf49e7ded76d2855cbdda6ac1 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDriverTest.java @@ -1,6 +1,5 @@ package com.taosdata.jdbc; -import org.junit.BeforeClass; import org.junit.Test; import java.sql.*; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java index f44d647595e99ae00a355ca25f702cf2e0c1cc36..f508fbdeed5bf617cf81330985981b5715678472 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java @@ -7,6 +7,7 @@ import org.junit.Test; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.sql.SQLException; +import java.sql.SQLWarning; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -19,115 +20,111 @@ public class TSDBJNIConnectorTest { private static TSDBResultSetRowData rowData; @Test - public void test() { + public void test() throws SQLException { try { - try { - //change sleepSeconds when debugging with attach to process to find PID - int sleepSeconds = -1; - if (sleepSeconds > 0) { - RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); - String jvmName = runtimeBean.getName(); - long pid = Long.valueOf(jvmName.split("@")[0]); - System.out.println("JVM PID = " + pid); - - Thread.sleep(sleepSeconds * 1000); - } - } catch (Exception e) { - e.printStackTrace(); + //change sleepSeconds when debugging with attach to process to find PID + int sleepSeconds = -1; + if (sleepSeconds > 0) { + RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); + String jvmName = runtimeBean.getName(); + long pid = Long.valueOf(jvmName.split("@")[0]); + System.out.println("JVM PID = " + pid); + + Thread.sleep(sleepSeconds * 1000); } + } catch (Exception e) { + e.printStackTrace(); + } - // init - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR, "/etc/taos"); - TSDBJNIConnector.init(properties); - - // connect - TSDBJNIConnector connector = new TSDBJNIConnector(); - connector.connect("127.0.0.1", 6030, null, "root", "taosdata"); - - // setup - String setupSqlStrs[] = {"create database if not exists d precision \"us\"", - "create table if not exists d.t(ts timestamp, f int)", - "create database if not exists d2", - "create table if not exists d2.t2(ts timestamp, f int)", - "insert into d.t values(now+100s, 100)", - "insert into d2.t2 values(now+200s, 200)" - }; - for (String setupSqlStr : setupSqlStrs) { - long setupSql = connector.executeQuery(setupSqlStr); - - assertEquals(0, connector.getResultTimePrecision(setupSql)); - if (connector.isUpdateQuery(setupSql)) { - connector.freeResultSet(setupSql); - } + // init + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR, "/etc/taos"); + TSDBJNIConnector.init(properties); + + // connect + TSDBJNIConnector connector = new TSDBJNIConnector(); + connector.connect("127.0.0.1", 6030, null, "root", "taosdata"); + + // setup + String setupSqlStrs[] = {"create database if not exists d precision \"us\"", + "create table if not exists d.t(ts timestamp, f int)", + "create database if not exists d2", + "create table if not exists d2.t2(ts timestamp, f int)", + "insert into d.t values(now+100s, 100)", + "insert into d2.t2 values(now+200s, 200)" + }; + for (String setupSqlStr : setupSqlStrs) { + long setupSql = connector.executeQuery(setupSqlStr); + + assertEquals(0, connector.getResultTimePrecision(setupSql)); + if (connector.isUpdateQuery(setupSql)) { + connector.freeResultSet(setupSql); } + } - { - long sqlObj1 = connector.executeQuery("select * from d2.t2"); - assertEquals(0, connector.getResultTimePrecision(sqlObj1)); - List columnMetaDataList = new ArrayList<>(); - int code = connector.getSchemaMetaData(sqlObj1, columnMetaDataList); - rowData = new TSDBResultSetRowData(columnMetaDataList.size()); - assertTrue(next(connector, sqlObj1)); - assertEquals(0, connector.getResultTimePrecision(sqlObj1)); - connector.freeResultSet(sqlObj1); - } + { + long sqlObj1 = connector.executeQuery("select * from d2.t2"); + assertEquals(0, connector.getResultTimePrecision(sqlObj1)); + List columnMetaDataList = new ArrayList<>(); + int code = connector.getSchemaMetaData(sqlObj1, columnMetaDataList); + rowData = new TSDBResultSetRowData(columnMetaDataList.size()); + assertTrue(next(connector, sqlObj1)); + assertEquals(0, connector.getResultTimePrecision(sqlObj1)); + connector.freeResultSet(sqlObj1); + } - // executeQuery - long pSql = connector.executeQuery("select * from d.t"); + // executeQuery + long pSql = connector.executeQuery("select * from d.t"); - if (connector.isUpdateQuery(pSql)) { - connector.freeResultSet(pSql); - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY); - } + if (connector.isUpdateQuery(pSql)) { + connector.freeResultSet(pSql); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY); + } - assertEquals(1, connector.getResultTimePrecision(pSql)); + assertEquals(1, connector.getResultTimePrecision(pSql)); - // get schema - List columnMetaDataList = new ArrayList<>(); - int code = connector.getSchemaMetaData(pSql, columnMetaDataList); - if (code == TSDBConstants.JNI_CONNECTION_NULL) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); - } - if (code == TSDBConstants.JNI_RESULT_SET_NULL) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL); - } - if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0); - } + // get schema + List columnMetaDataList = new ArrayList<>(); + int code = connector.getSchemaMetaData(pSql, columnMetaDataList); + if (code == TSDBConstants.JNI_CONNECTION_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + } + if (code == TSDBConstants.JNI_RESULT_SET_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL); + } + if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0); + } + assertEquals(1, connector.getResultTimePrecision(pSql)); + int columnSize = columnMetaDataList.size(); + // print metadata + for (int i = 0; i < columnSize; i++) { +// System.out.println(columnMetaDataList.get(i)); + } + rowData = new TSDBResultSetRowData(columnSize); + // iterate resultSet + for (int i = 0; next(connector, pSql); i++) { assertEquals(1, connector.getResultTimePrecision(pSql)); - int columnSize = columnMetaDataList.size(); - // print metadata - for (int i = 0; i < columnSize; i++) { - System.out.println(columnMetaDataList.get(i)); - } - rowData = new TSDBResultSetRowData(columnSize); - // iterate resultSet - for (int i = 0; next(connector, pSql); i++) { - assertEquals(1, connector.getResultTimePrecision(pSql)); - System.out.println(); - } - // close resultSet - code = connector.freeResultSet(pSql); - if (code == TSDBConstants.JNI_CONNECTION_NULL) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); - } else if (code == TSDBConstants.JNI_RESULT_SET_NULL) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL); - } - // close statement - connector.executeQuery("use d"); - String[] lines = new String[]{ - "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", - "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000"}; - connector.insertLines(lines, SchemalessProtocolType.LINE, SchemalessTimestampType.NANO_SECONDS); - - // close connection - connector.closeConnection(); - - } catch (SQLException e) { - e.printStackTrace(); } + // close resultSet + code = connector.freeResultSet(pSql); + if (code == TSDBConstants.JNI_CONNECTION_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + } else if (code == TSDBConstants.JNI_RESULT_SET_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL); + } + // close statement + connector.executeQuery("use d"); + String[] lines = new String[]{ + "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", + "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000"}; + connector.insertLines(lines, SchemalessProtocolType.LINE, SchemalessTimestampType.NANO_SECONDS); + + // close connection + connector.executeQuery("drop database if exists d"); + connector.executeQuery("drop database if exists d2"); + connector.closeConnection(); } private static boolean next(TSDBJNIConnector connector, long pSql) throws SQLException { diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java index dc41d85cf38c5fbedb6e5f5c26d593c8c9d5c4d7..56e8b96bbd9dee496969a010b0385c4ecd7f1145 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBParameterMetaDataTest.java @@ -17,6 +17,7 @@ public class TSDBParameterMetaDataTest { private static PreparedStatement pstmt_select; private static ParameterMetaData parameterMetaData_insert; private static ParameterMetaData parameterMetaData_select; + private static final String dbname = "test_pstmt"; @Test public void getParameterCount() throws SQLException { @@ -152,9 +153,9 @@ public class TSDBParameterMetaDataTest { try { conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"); try (Statement stmt = conn.createStatement()) { - stmt.execute("drop database if exists test_pstmt"); - stmt.execute("create database if not exists test_pstmt"); - stmt.execute("use test_pstmt"); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); stmt.execute("create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64))"); stmt.execute("create table t1 using weather tags('beijing')"); } @@ -190,8 +191,12 @@ public class TSDBParameterMetaDataTest { pstmt_insert.close(); if (pstmt_select != null) pstmt_select.close(); - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java index 3d76e1f98d4f8aa1d0ba3d68395e4036c5b069e6..8cb4628884fdd85c1bfd6f24ac311d82687da5ab 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java @@ -1233,6 +1233,7 @@ public class TSDBPreparedStatementTest { try { Statement statement = conn.createStatement(); statement.execute("drop database if exists " + dbname); + statement.execute("drop database if exists dbtest"); statement.close(); if (conn != null) conn.close(); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java index f72cbbec8c1b4c0acad1c83ffcbcb35c1fb8ea7b..7b9083bf9be242f8bcb21565a47d6092675e2d6e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java @@ -668,8 +668,12 @@ public class TSDBResultSetTest { rs.close(); if (stmt != null) stmt.close(); - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists restful_test"); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java index 05c7b0feca21f3f5b9062f9cbc26921aa607732a..60edcc506e9fea7bc055322b7b00d0f9e9d75591 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java @@ -1,9 +1,6 @@ package com.taosdata.jdbc.cases; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; +import org.junit.*; import org.junit.runners.MethodSorters; import java.sql.*; @@ -16,36 +13,32 @@ public class InsertDbwithoutUseDbTest { private static final String host = "127.0.0.1"; private static Properties properties; private static final Random random = new Random(System.currentTimeMillis()); + private static final String dbname = "inWithoutDb"; @Test public void case001() throws SQLException { // prepare schema String url = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"; Connection conn = DriverManager.getConnection(url, properties); - try (Statement stmt = conn.createStatement()) { - stmt.execute("drop database if exists inWithoutDb"); - stmt.execute("create database if not exists inWithoutDb"); - stmt.execute("create table inWithoutDb.weather(ts timestamp, f1 int)"); - } + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("create table " + dbname + ".weather(ts timestamp, f1 int)"); + conn.close(); // execute insert - url = "jdbc:TAOS://127.0.0.1:6030/inWithoutDb?user=root&password=taosdata"; + url = "jdbc:TAOS://127.0.0.1:6030/" + dbname + "?user=root&password=taosdata"; conn = DriverManager.getConnection(url, properties); - try (Statement stmt = conn.createStatement()) { - int affectedRow = stmt.executeUpdate("insert into weather(ts, f1) values(now," + random.nextInt(100) + ")"); - Assert.assertEquals(1, affectedRow); - boolean flag = stmt.execute("insert into weather(ts, f1) values(now + 10s," + random.nextInt(100) + ")"); - Assert.assertEquals(false, flag); - ResultSet rs = stmt.executeQuery("select count(*) from weather"); - rs.next(); - int count = rs.getInt("count(*)"); - Assert.assertEquals(2, count); - - } catch (SQLException e) { - e.printStackTrace(); - } - + stmt = conn.createStatement(); + int affectedRow = stmt.executeUpdate("insert into weather(ts, f1) values(now," + random.nextInt(100) + ")"); + Assert.assertEquals(1, affectedRow); + boolean flag = stmt.execute("insert into weather(ts, f1) values(now + 10s," + random.nextInt(100) + ")"); + Assert.assertEquals(false, flag); + ResultSet rs = stmt.executeQuery("select count(*) from weather"); + rs.next(); + int count = rs.getInt("count(*)"); + Assert.assertEquals(2, count); conn.close(); } @@ -54,28 +47,25 @@ public class InsertDbwithoutUseDbTest { // prepare the schema final String url = "jdbc:TAOS-RS://" + host + ":6041/inWithoutDb?user=root&password=taosdata"; Connection conn = DriverManager.getConnection(url, properties); - try (Statement stmt = conn.createStatement()) { - stmt.execute("drop database if exists inWithoutDb"); - stmt.execute("create database if not exists inWithoutDb"); - stmt.execute("create table inWithoutDb.weather(ts timestamp, f1 int)"); - } - conn.close(); + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("create table " + dbname + ".weather(ts timestamp, f1 int)"); + stmt.close(); // execute - conn = DriverManager.getConnection(url, properties); - try (Statement stmt = conn.createStatement()) { - int affectedRow = stmt.executeUpdate("insert into weather(ts, f1) values(now," + random.nextInt(100) + ")"); - Assert.assertEquals(1, affectedRow); - boolean flag = stmt.execute("insert into weather(ts, f1) values(now + 10s," + random.nextInt(100) + ")"); - Assert.assertEquals(false, flag); - ResultSet rs = stmt.executeQuery("select count(*) from weather"); - rs.next(); - int count = rs.getInt("count(*)"); - Assert.assertEquals(2, count); - - } catch (SQLException e) { - e.printStackTrace(); - } + stmt = conn.createStatement(); + int affectedRow = stmt.executeUpdate("insert into weather(ts, f1) values(now," + random.nextInt(100) + ")"); + Assert.assertEquals(1, affectedRow); + boolean flag = stmt.execute("insert into weather(ts, f1) values(now + 10s," + random.nextInt(100) + ")"); + Assert.assertEquals(false, flag); + ResultSet rs = stmt.executeQuery("select count(*) from weather"); + rs.next(); + int count = rs.getInt("count(*)"); + Assert.assertEquals(2, count); + stmt.execute("drop database if exists " + dbname); + stmt.close(); + conn.close(); } @BeforeClass diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java index ac254bebf39f55b358883716e23ba72b695703f7..7cc1c811d136a974a8cd9b8d4b990fe206c9e98d 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java @@ -427,8 +427,12 @@ public class InsertSpecialCharacterJniTest { @AfterClass public static void afterClass() throws SQLException { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + dbName); + statement.close(); conn.close(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java index eedccec6f1ad3aecbaebbd525788a68e7c236511..81e424971c90e75a0ca3e8d14b82eefc45e417c8 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java @@ -391,8 +391,12 @@ public class InsertSpecialCharacterRestfulTest { @AfterClass public static void afterClass() throws SQLException { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists "+ dbName); + statement.close(); conn.close(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/JDBCTypeAndTypeCompareTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/JDBCTypeAndTypeCompareTest.java index eb3b2985dfaff1b956909a50ca23470279cb48ca..38e8d99afe4a9fbca8d7167df482b6c2ac6976d8 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/JDBCTypeAndTypeCompareTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/JDBCTypeAndTypeCompareTest.java @@ -1,19 +1,22 @@ package com.taosdata.jdbc.cases; +import org.junit.AfterClass; import org.junit.Test; import java.sql.*; public class JDBCTypeAndTypeCompareTest { + private static Connection conn; + private static final String dbname = "test"; @Test public void test() throws SQLException { - Connection conn = DriverManager.getConnection("jdbc:TAOS://192.168.17.156:6030/", "root", "taosdata"); + conn = DriverManager.getConnection("jdbc:TAOS://127.0.0.1:6030/", "root", "taosdata"); Statement stmt = conn.createStatement(); - stmt.execute("drop database if exists test"); - stmt.execute("create database if not exists test"); - stmt.execute("use test"); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); stmt.execute("create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10) )"); stmt.execute("insert into weather values(now, 1, 2, 3.0, 4.0, 5, 6, true, 'test','test')"); @@ -29,6 +32,19 @@ public class JDBCTypeAndTypeCompareTest { } stmt.close(); - conn.close(); + } + + @AfterClass + public static void afterClass() { + try { + if (null != conn) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.close(); + conn.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java index eb8f134227713e4c41224dc6a561916427290864..0889170e656910181fe39f844e585c11f0d78d5e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionJNITest.java @@ -47,7 +47,7 @@ public class MicroSecondPrecisionJNITest { Assert.assertEquals(timestamp2 % 1000_000l * 1000, nanos); ts = rs.getLong(1); - Assert.assertEquals(timestamp1, ts); + Assert.assertEquals(timestamp2, ts); } catch (SQLException e) { e.printStackTrace(); } @@ -79,8 +79,13 @@ public class MicroSecondPrecisionJNITest { @AfterClass public static void afterClass() { try { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database " + ms_timestamp_db); + statement.execute("drop database " + us_timestamp_db); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java index f418436a4afac5f16b27789eb43081f131bf1f92..48c5ef8a463452dc205c43247678bfd0f3e761a2 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MicroSecondPrecisionRestfulTest.java @@ -47,7 +47,7 @@ public class MicroSecondPrecisionRestfulTest { Assert.assertEquals(timestamp2 % 1000_000l * 1000, nanos); ts = rs.getLong(1); - Assert.assertEquals(timestamp1, ts); + Assert.assertEquals(timestamp2, ts); } } @@ -77,7 +77,7 @@ public class MicroSecondPrecisionRestfulTest { Assert.assertEquals(timestamp2 % 1000_000l * 1000, nanos); ts = rs.getLong(1); - Assert.assertEquals(timestamp1, ts); + Assert.assertEquals(timestamp2, ts); } } @@ -107,7 +107,7 @@ public class MicroSecondPrecisionRestfulTest { Assert.assertEquals(timestamp2 % 1000_000l * 1000, nanos); ts = rs.getLong(1); - Assert.assertEquals(timestamp1, ts); + Assert.assertEquals(timestamp2, ts); } } @@ -142,12 +142,21 @@ public class MicroSecondPrecisionRestfulTest { } @AfterClass - public static void afterClass() throws SQLException { - if (conn1 != null) - conn1.close(); - if (conn2 != null) - conn2.close(); - if (conn3 != null) - conn3.close(); + public static void afterClass() { + try { + if (conn1 != null) { + Statement statement = conn1.createStatement(); + statement.execute("drop database if exists " + ms_timestamp_db); + statement.execute("drop database if exists " + us_timestamp_db); + statement.close(); + conn1.close(); + } + if (conn2 != null) + conn2.close(); + if (conn3 != null) + conn3.close(); + }catch (SQLException e){ + e.printStackTrace(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java index 0bf8334079e630bf61b7955a37c74401da24a947..220ac0e7ce023229c1e897b9125a4ebb2cae3687 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/MultiConnectionWithDifferentDbTest.java @@ -1,5 +1,6 @@ package com.taosdata.jdbc.cases; +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -90,4 +91,16 @@ public class MultiConnectionWithDifferentDbTest { } } + @After + public void after() { + String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"; + try (Connection connection = DriverManager.getConnection(url); + Statement statement = connection.createStatement()) { + statement.execute("drop database if exists " + db1); + statement.execute("drop database if exists " + db2); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java index a84f5233974e9bd9acdbbe3ca8ae0404c11b34a1..c85c6f95a93df565cd5ff8eca91c0beeac3b3c02 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampJNITest.java @@ -1,9 +1,6 @@ package com.taosdata.jdbc.cases; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.*; import java.sql.*; import java.time.Instant; @@ -83,9 +80,9 @@ public class NanoSecondTimestampJNITest { // then long actual = rs.getLong(1); - Assert.assertEquals(ms, actual); + Assert.assertEquals(ns, actual); actual = rs.getLong("ts"); - Assert.assertEquals(ms, actual); + Assert.assertEquals(ns, actual); } @Test @@ -160,4 +157,18 @@ public class NanoSecondTimestampJNITest { } } + @AfterClass + public static void afterClass(){ + try { + if (null != conn){ + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.close(); + conn.close(); + } + }catch (SQLException e){ + e.printStackTrace(); + } + } + } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java index c8aaf5c6788d18e782e431ba4ed97fb69f4702ab..796f21ed21bb69e952042e89f61e0eb98fcf4273 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NanoSecondTimestampRestfulTest.java @@ -1,9 +1,6 @@ package com.taosdata.jdbc.cases; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.*; import java.sql.*; import java.time.Instant; @@ -83,9 +80,9 @@ public class NanoSecondTimestampRestfulTest { // then long actual = rs.getLong(1); - Assert.assertEquals(ms, actual); + Assert.assertEquals(ns, actual); actual = rs.getLong("ts"); - Assert.assertEquals(ms, actual); + Assert.assertEquals(ns, actual); } @Test @@ -160,4 +157,14 @@ public class NanoSecondTimestampRestfulTest { } } + @AfterClass + public static void afterClass() throws SQLException { + if (conn != null){ + try (Statement stmt = conn.createStatement()) { + stmt.execute("drop database if exists " + dbname); + } + conn.close(); + } + } + } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java index 6efd9f5ebee29a122c2106439117738c44241597..8bbc2fe077a1292b24ee7cb67158620c96f9a605 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetJNITest.java @@ -45,7 +45,11 @@ public class NullValueInResultSetJNITest { @After public void after() throws SQLException { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists test_null"); + statement.close(); conn.close(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java index f331a58583db832124465492d07f24f1772348ce..08f641b96e86398d72d9ab42ccaed57e2227ecdc 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetRestfulTest.java @@ -47,7 +47,11 @@ public class NullValueInResultSetRestfulTest { @After public void after() throws SQLException { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists test_null"); + statement.close(); conn.close(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java index 61d767b5cf2bcd2e478de74e5f4bb8d66ad21678..890505ac65cf02deb85dd362ebd700291317e849 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/NullValueInResultSetTest.java @@ -85,7 +85,11 @@ public class NullValueInResultSetTest { public static void afterClass() throws SQLException { if (conn_restful != null) conn_restful.close(); - if (conn_jni != null) + if (conn_jni != null) { + Statement statement = conn_jni.createStatement(); + statement.execute("drop database if exists test_null"); + statement.close(); conn_jni.close(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisionInNanoInJniTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisionInNanoInJniTest.java index 2d336135e5d1dc28db010387ab838f17d9b9a9cc..76053ccc41895fcdc00ffe9da2252bf63313894e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisionInNanoInJniTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisionInNanoInJniTest.java @@ -62,8 +62,12 @@ public class TimestampPrecisionInNanoInJniTest { @AfterClass public static void afterClass() { try { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + ns_timestamp_db); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } @@ -83,7 +87,7 @@ public class TimestampPrecisionInNanoInJniTest { int nanos = rs.getTimestamp(1).getNanos(); Assert.assertEquals(ts % 1000_000_000l, nanos); long test_ts = rs.getLong(1); - Assert.assertEquals(ts / 1000_000l, test_ts); + Assert.assertEquals(ts, test_ts); } @Test diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisonInNanoRestTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisonInNanoRestTest.java index cfd6a066acc2c2abd94e525fb69d4027a317134c..4aedf867d408536fde6896e01f61ef13873d1624 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisonInNanoRestTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TimestampPrecisonInNanoRestTest.java @@ -62,8 +62,12 @@ public class TimestampPrecisonInNanoRestTest { @AfterClass public static void afterClass() { try { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + ns_timestamp_db); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } @@ -83,7 +87,7 @@ public class TimestampPrecisonInNanoRestTest { int nanos = rs.getTimestamp(1).getNanos(); Assert.assertEquals(ts % 1000_000_000l, nanos); long test_ts = rs.getLong(1); - Assert.assertEquals(ts / 1000_000l, test_ts); + Assert.assertEquals(ts, test_ts); } @Test diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java index 0be6b90e7a9b5e1e7707b88c1c60d2751b7d245b..cff353093aca6772e96a88f1083bc428a49ab9b2 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java @@ -156,8 +156,12 @@ public class UnsignedNumberJniTest { @AfterClass public static void afterClass() throws SQLException { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists unsign_jni"); + statement.close(); conn.close(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java index 842dbfeff8478115df93b48cfe29fe376c4cff05..b3ca6871db7cbf0888737856e66d236c4cc80d49 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java @@ -14,6 +14,7 @@ public class UnsignedNumberRestfulTest { private static final String host = "127.0.0.1"; private static Connection conn; private static long ts; + private static final String dbname = "unsign_restful"; @Test public void testCase001() throws SQLException { @@ -148,9 +149,9 @@ public class UnsignedNumberRestfulTest { final String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"; conn = DriverManager.getConnection(url, properties); Statement stmt = conn.createStatement(); - stmt.execute("drop database if exists unsign_restful"); - stmt.execute("create database if not exists unsign_restful"); - stmt.execute("use unsign_restful"); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); stmt.execute("create table us_table(ts timestamp, f1 tinyint unsigned, f2 smallint unsigned, f3 int unsigned, f4 bigint unsigned)"); stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + ts + ", 127, 32767,2147483647, 9223372036854775807)"); stmt.close(); @@ -162,8 +163,12 @@ public class UnsignedNumberRestfulTest { @AfterClass public static void afterClass() { try { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java index 2e0448bc248bb2a962466e632443d4e6d918ab9f..c4f2cba446e6138679ae9f8b8efff3666c056deb 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java @@ -1,5 +1,6 @@ package com.taosdata.jdbc.cases; +import org.junit.AfterClass; import org.junit.Test; import java.sql.*; @@ -8,7 +9,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class UseNowInsertTimestampTest { - String url = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"; + private static String url = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"; @Test public void millisec() throws SQLException { @@ -55,13 +56,14 @@ public class UseNowInsertTimestampTest { @Test public void nanosec() throws SQLException { + long now_time = System.currentTimeMillis() * 1000_000L + System.nanoTime() % 1000_000L; try (Connection conn = DriverManager.getConnection(url)) { Statement stmt = conn.createStatement(); stmt.execute("drop database if exists test"); stmt.execute("create database if not exists test precision 'ns'"); stmt.execute("use test"); stmt.execute("create table weather(ts timestamp, f1 int)"); - stmt.execute("insert into weather values(now, 1)"); + stmt.execute("insert into weather values(" + now_time + ", 1)"); ResultSet rs = stmt.executeQuery("select * from weather"); rs.next(); @@ -74,4 +76,15 @@ public class UseNowInsertTimestampTest { stmt.execute("drop database if exists test"); } } + + @AfterClass + public static void afterClass() { + try (Connection conn = DriverManager.getConnection(url); + Statement stmt = conn.createStatement()) { + stmt.execute("drop database if exists test"); + } catch (SQLException e) { + e.printStackTrace(); + } + + } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BadLocaleSettingTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BadLocaleSettingTest.java index bbf71349b85c7bdc51fde30f293c7cd724de3699..7ad7c23136f8e24b0c7139e97fb4b46c04a98abb 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BadLocaleSettingTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BadLocaleSettingTest.java @@ -45,7 +45,11 @@ public class BadLocaleSettingTest { @AfterClass public static void afterClass() throws SQLException { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database " + dbName); + statement.close(); conn.close(); + } } } \ No newline at end of file diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BatchFetchTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BatchFetchTest.java index e8c799e86c61c6b4a7cb8b3396c6c3e09548ee0e..94a5382410ba05c1fbf3afb4f8bb73d6c5271c3a 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BatchFetchTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/BatchFetchTest.java @@ -79,4 +79,15 @@ public class BatchFetchTest { } return builder.toString(); } + + @AfterClass + public static void afterClass(){ + String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; + try (Connection conn = DriverManager.getConnection(url); + Statement stmt = conn.createStatement()) { + stmt.execute("drop database if exists test"); + } catch (SQLException e) { + e.printStackTrace(); + } + } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/CharsetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/CharsetTest.java index e28faeb280a9f9f9ae931e7b610910fb912278b3..41629189aea4658514bd317c90bc055340397a23 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/CharsetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/CharsetTest.java @@ -1,6 +1,7 @@ package com.taosdata.jdbc.confprops; import com.taosdata.jdbc.TSDBDriver; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Test; @@ -37,4 +38,18 @@ public class CharsetTest { } } + @AfterClass + public static void afterClass(){ + String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; + Properties props = new Properties(); + props.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + + try (Connection conn = DriverManager.getConnection(url, props); + Statement stmt = conn.createStatement()) { + stmt.execute("drop database if exists test"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimeZoneTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimeZoneTest.java index 6569aa5f085f5d389144a9e8ddc0787786f9fff3..bc19e63ba6e05c8170366de4375148ebde0138d0 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimeZoneTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimeZoneTest.java @@ -29,7 +29,7 @@ public class TimeZoneTest { } @Test - public void taosTimeZone() { + public void taosTimeZone() throws SQLException { // given Properties props = new Properties(); props.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); @@ -39,7 +39,7 @@ public class TimeZoneTest { Statement stmt = connection.createStatement(); stmt.execute("drop database if exists timezone_test"); - stmt.execute("create database if not exists timezone_test keep 365000"); + stmt.execute("create database if not exists timezone_test keep 36500"); stmt.execute("use timezone_test"); stmt.execute("create table weather(ts timestamp, temperature float)"); @@ -51,7 +51,7 @@ public class TimeZoneTest { System.out.println("ts: " + ts.getTime() + "," + ts); } - stmt.execute("insert into timezone_test.weather(ts, temperature, humidity) values('1970-01-02 00:00:00', 1.0, 2.0)"); + stmt.execute("insert into timezone_test.weather(ts, temperature) values('1970-01-02 00:00:00', 1.0)"); rs = stmt.executeQuery("select * from timezone_test.weather"); while (rs.next()) { @@ -63,8 +63,6 @@ public class TimeZoneTest { stmt.execute("drop database if exists timezone_test"); stmt.close(); - } catch (SQLException e) { - e.printStackTrace(); } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimestampFormatTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimestampFormatTest.java index 7e3701c153fa3f45852dd1a5860cf30910dc906d..a6f8cf7c0ad79d1a046a5075f05f6930ea1d19ce 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimestampFormatTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/confprops/TimestampFormatTest.java @@ -1,17 +1,17 @@ package com.taosdata.jdbc.confprops; import com.taosdata.jdbc.TSDBDriver; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.*; import java.sql.*; import java.time.Instant; +import java.util.Calendar; import java.util.Properties; public class TimestampFormatTest { private static final String host = "127.0.0.1"; private long ts = Instant.now().toEpochMilli(); + private Connection conn; @Test public void string() throws SQLException { @@ -154,13 +154,27 @@ public class TimestampFormatTest { @Before public void before() throws SQLException { String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"; - try (Connection conn = DriverManager.getConnection(url); - Statement stmt = conn.createStatement()) { - stmt.execute("drop database if exists test"); - stmt.execute("create database if not exists test"); - stmt.execute("use test"); - stmt.execute("create table weather(ts timestamp, temperature nchar(10))"); - stmt.execute("insert into weather values(" + ts + ", '北京')"); + conn = DriverManager.getConnection(url); + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists test"); + stmt.execute("create database if not exists test"); + stmt.execute("use test"); + stmt.execute("create table weather(ts timestamp, temperature nchar(10))"); + stmt.execute("insert into weather values(" + ts + ", '北京')"); + stmt.close(); + } + + @After + public void after() { + try { + if (null != conn) { + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists test"); + stmt.close(); + conn.close(); + } + } catch (SQLException e) { + e.printStackTrace(); } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java index 9fe51e7203fac7133783e47fd5b0cc07f33b2494..0a37e255a4ac8e8db2b07fc915ab7ba6dd54397c 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/DatabaseSpecifiedTest.java @@ -33,7 +33,6 @@ public class DatabaseSpecifiedTest { String loc = rs.getString("loc"); assertEquals("beijing", loc); } - connection.close(); } @Before @@ -59,8 +58,12 @@ public class DatabaseSpecifiedTest { @After public void after() { try { - if (connection != null) + if (connection != null) { + Statement statement = connection.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.close(); connection.close(); + } } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java index e7ce1d76f123a043d49eb64931c0d537d09664df..e4785a197e659977ae22745e14e664fd803464f7 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java @@ -383,8 +383,12 @@ public class RestfulConnectionTest { @AfterClass public static void afterClass() throws SQLException { - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists test"); + statement.close(); conn.close(); + } } } \ No newline at end of file diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java index 81d7f5b56c4b4e67b9573522ee031006a7e11a2b..c8ca1a5de7ac870c01d248a8b042cffefa4857b7 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulParameterMetaDataTest.java @@ -18,6 +18,7 @@ public class RestfulParameterMetaDataTest { private static PreparedStatement pstmt_select; private static ParameterMetaData parameterMetaData_insert; private static ParameterMetaData parameterMetaData_select; + private static final String dbname = "test_pstmt"; @Test public void getParameterCount() throws SQLException { @@ -148,9 +149,9 @@ public class RestfulParameterMetaDataTest { Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"); try (Statement stmt = conn.createStatement()) { - stmt.execute("drop database if exists test_pstmt"); - stmt.execute("create database if not exists test_pstmt"); - stmt.execute("use test_pstmt"); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); stmt.execute("create table weather(ts timestamp, f1 int, f2 bigint, f3 float, f4 double, f5 smallint, f6 tinyint, f7 bool, f8 binary(64), f9 nchar(64)) tags(loc nchar(64))"); stmt.execute("create table t1 using weather tags('beijing')"); } @@ -186,8 +187,12 @@ public class RestfulParameterMetaDataTest { pstmt_insert.close(); if (pstmt_select != null) pstmt_select.close(); - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulPreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulPreparedStatementTest.java index 4760a723e4b4e662326987290c2c630803f8f470..40d0e0214fe1016df8d42e9dfd8d31472165c798 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulPreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulPreparedStatementTest.java @@ -400,8 +400,12 @@ public class RestfulPreparedStatementTest { pstmt_select.close(); if (pstmt_without_parameters != null) pstmt_without_parameters.close(); - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists test_pstmt"); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java index f3011af799c987ed399920875ae512fd8533ec77..6e5851474f2697022eef5dc62be3f69ca5878df9 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java @@ -15,6 +15,7 @@ public class RestfulResultSetMetaDataTest { private static Statement stmt; private static ResultSet rs; private static ResultSetMetaData meta; + private static final String dbname = "restful_test"; @Test public void getColumnCount() throws SQLException { @@ -206,8 +207,12 @@ public class RestfulResultSetMetaDataTest { rs.close(); if (stmt != null) stmt.close(); - if (conn != null) + if (conn != null) { + Statement statement = conn.createStatement(); + statement.execute("drop database if exists " + dbname); + statement.close(); conn.close(); + } } catch (SQLException e) { e.printStackTrace(); } diff --git a/src/connector/nodejs/nodetaos/cinterface.js b/src/connector/nodejs/nodetaos/cinterface.js index fa0eb20055df38c2a8092637e30ae807e473fa30..2403ffa4c68ca9571f2ec583fa263765208bfb2b 100644 --- a/src/connector/nodejs/nodetaos/cinterface.js +++ b/src/connector/nodejs/nodetaos/cinterface.js @@ -14,7 +14,12 @@ const _ = require('lodash') const TaosObjects = require('./taosobjects'); module.exports = CTaosInterface; - +const TAOSFIELD = { + NAME_LENGTH: 65, + TYPE_OFFSET: 65, + BYTES_OFFSET: 66, + STRUCT_SIZE: 68, +} function convertTimestamp(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); let res = []; @@ -195,6 +200,24 @@ function convertNchar(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) return res; } +function convertJsonTag(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { + data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); + let res = []; + + let currOffset = 0; + while (currOffset < data.length) { + let len = data.readIntLE(currOffset, 2); + let dataEntry = data.slice(currOffset + 2, currOffset + len + 2); //one entry in a row under a column; + if (dataEntry[0] == 255 && dataEntry[1] == 255) { + res.push(null) + } else { + res.push(dataEntry.toString("utf-8")); + } + currOffset += nbytes; + } + return res; +} + // Object with all the relevant converters from pblock data to javascript readable data let convertFunctions = { [FieldTypes.C_BOOL]: convertBool, @@ -210,7 +233,8 @@ let convertFunctions = { [FieldTypes.C_TINYINT_UNSIGNED]: convertTinyintUnsigned, [FieldTypes.C_SMALLINT_UNSIGNED]: convertSmallintUnsigned, [FieldTypes.C_INT_UNSIGNED]: convertIntUnsigned, - [FieldTypes.C_BIGINT_UNSIGNED]: convertBigintUnsigned + [FieldTypes.C_BIGINT_UNSIGNED]: convertBigintUnsigned, + [FieldTypes.C_JSON_TAG]: convertJsonTag, } // Define TaosField structure @@ -219,8 +243,8 @@ var TaosField = Struct({ 'name': char_arr, }); TaosField.fields.name.type.size = 65; -TaosField.defineProperty('type', ref.types.char); -TaosField.defineProperty('bytes', ref.types.short); +TaosField.defineProperty('type', ref.types.uint8); +TaosField.defineProperty('bytes', ref.types.int16); //define schemaless line array var smlLine = ArrayType(ref.coerceType('char *')) @@ -390,14 +414,14 @@ CTaosInterface.prototype.useResult = function useResult(result) { let fields = []; let pfields = this.fetchFields(result); + if (ref.isNull(pfields) == false) { - pfields = ref.reinterpret(pfields, this.fieldsCount(result) * 68, 0); - for (let i = 0; i < pfields.length; i += 68) { - //0 - 63 = name //64 - 65 = bytes, 66 - 67 = type + pfields = ref.reinterpret(pfields, this.fieldsCount(result) * TAOSFIELD.STRUCT_SIZE, 0); + for (let i = 0; i < pfields.length; i += TAOSFIELD.STRUCT_SIZE) { fields.push({ - name: ref.readCString(ref.reinterpret(pfields, 65, i)), - type: pfields[i + 65], - bytes: pfields[i + 66] + name: ref.readCString(ref.reinterpret(pfields, TAOSFIELD.NAME_LENGTH, i)), + type: pfields[i + TAOSFIELD.TYPE_OFFSET], + bytes: pfields[i + TAOSFIELD.BYTES_OFFSET] + pfields[i + TAOSFIELD.BYTES_OFFSET + 1] * 256 }) } } @@ -532,13 +556,12 @@ CTaosInterface.prototype.fetchFields_a = function fetchFields_a(result) { let pfieldscount = this.numFields(result); let fields = []; if (ref.isNull(pfields) == false) { - pfields = ref.reinterpret(pfields, 68 * pfieldscount, 0); - for (let i = 0; i < pfields.length; i += 68) { - //0 - 64 = name //65 = type, 66 - 67 = bytes + pfields = ref.reinterpret(pfields, pfieldscount * TAOSFIELD.STRUCT_SIZE, 0); + for (let i = 0; i < pfields.length; i += TAOSFIELD.STRUCT_SIZE) { fields.push({ - name: ref.readCString(ref.reinterpret(pfields, 65, i)), - type: pfields[i + 65], - bytes: pfields[i + 66] + name: ref.readCString(ref.reinterpret(pfields, TAOSFIELD.NAME_LENGTH, i)), + type: pfields[i + TAOSFIELD.TYPE_OFFSET], + bytes: pfields[i + TAOSFIELD.BYTES_OFFSET] + pfields[i + TAOSFIELD.BYTES_OFFSET + 1] * 256 }) } } @@ -594,13 +617,12 @@ CTaosInterface.prototype.consume = function consume(subscription) { let fields = []; let pfields = this.fetchFields(result); if (ref.isNull(pfields) == false) { - pfields = ref.reinterpret(pfields, this.numFields(result) * 68, 0); - for (let i = 0; i < pfields.length; i += 68) { - //0 - 63 = name //64 - 65 = bytes, 66 - 67 = type + pfields = ref.reinterpret(pfields, this.numFields(result) * TAOSFIELD.STRUCT_SIZE, 0); + for (let i = 0; i < pfields.length; i += TAOSFIELD.STRUCT_SIZE) { fields.push({ - name: ref.readCString(ref.reinterpret(pfields, 64, i)), - bytes: pfields[i + 64], - type: pfields[i + 66] + name: ref.readCString(ref.reinterpret(pfields, TAOSFIELD.NAME_LENGTH, i)), + bytes: pfields[TAOSFIELD.TYPE_OFFSET], + type: pfields[i + TAOSFIELD.BYTES_OFFSET] + pfields[i + TAOSFIELD.BYTES_OFFSET + 1] * 256 }) } } @@ -684,23 +706,23 @@ CTaosInterface.prototype.closeStream = function closeStream(stream) { * @returns TAOS_RES * */ -CTaosInterface.prototype.schemalessInsert = function schemalessInsert(connection,lines, protocal, precision) { +CTaosInterface.prototype.schemalessInsert = function schemalessInsert(connection, lines, protocal, precision) { let _numLines = null; let _lines = null; - - if(_.isString(lines)){ + + if (_.isString(lines)) { _numLines = 1; _lines = Buffer.alloc(_numLines * ref.sizeof.pointer); - ref.set(_lines,0,ref.allocCString(lines),ref.types.char_ptr); + ref.set(_lines, 0, ref.allocCString(lines), ref.types.char_ptr); } - else if(_.isArray(lines)){ + else if (_.isArray(lines)) { _numLines = lines.length; _lines = Buffer.alloc(_numLines * ref.sizeof.pointer); - for(let i = 0; i < _numLines ; i++){ - ref.set(_lines,i*ref.sizeof.pointer,ref.allocCString(lines[i]),ref.types.char_ptr) + for (let i = 0; i < _numLines; i++) { + ref.set(_lines, i * ref.sizeof.pointer, ref.allocCString(lines[i]), ref.types.char_ptr) } } - else{ + else { throw new errors.InterfaceError("Unsupport lines input") } return this.libtaos.taos_schemaless_insert(connection, _lines, _numLines, protocal, precision); diff --git a/src/connector/nodejs/nodetaos/constants.js b/src/connector/nodejs/nodetaos/constants.js index 551cfce71677fbd6635a76884474e1b1aeac7ab9..b055e0ed01522348556475fa72e8bf34a9d3fe70 100644 --- a/src/connector/nodejs/nodetaos/constants.js +++ b/src/connector/nodejs/nodetaos/constants.js @@ -6,13 +6,13 @@ const SCHEMALESS_PROTOCOL = { TSDB_SML_JSON_PROTOCOL: 3 } const SCHEMALESS_PRECISION = { - TSDB_SML_TIMESTAMP_NOT_CONFIGURED : 0, - TSDB_SML_TIMESTAMP_HOURS : 1, - TSDB_SML_TIMESTAMP_MINUTES : 2, - TSDB_SML_TIMESTAMP_SECONDS : 3, - TSDB_SML_TIMESTAMP_MILLI_SECONDS : 4, - TSDB_SML_TIMESTAMP_MICRO_SECONDS : 5, - TSDB_SML_TIMESTAMP_NANO_SECONDS : 6 + TSDB_SML_TIMESTAMP_NOT_CONFIGURED: 0, + TSDB_SML_TIMESTAMP_HOURS: 1, + TSDB_SML_TIMESTAMP_MINUTES: 2, + TSDB_SML_TIMESTAMP_SECONDS: 3, + TSDB_SML_TIMESTAMP_MILLI_SECONDS: 4, + TSDB_SML_TIMESTAMP_MICRO_SECONDS: 5, + TSDB_SML_TIMESTAMP_NANO_SECONDS: 6 } const typeCodesToName = { 0: 'Null', @@ -30,6 +30,7 @@ const typeCodesToName = { 12: 'Smallint Unsigned', 13: 'Int Unsigned', 14: 'Bigint Unsigned', + 15: 'Json', } /** @@ -80,6 +81,7 @@ module.exports = { C_SMALLINT_UNSIGNED: 12, C_INT_UNSIGNED: 13, C_BIGINT_UNSIGNED: 14, + C_JSON_TAG: 15, // NULL value definition // NOTE: These values should change according to C definition in tsdb.h C_BOOL_NULL: 2, diff --git a/src/connector/nodejs/nodetaos/taosresult.js b/src/connector/nodejs/nodetaos/taosresult.js index 4138ebbec6e1b792691d17a25b7c18d35b6a922a..1ea5abee9f6c3c2754081ad82ecdb51c3b5bd4d3 100644 --- a/src/connector/nodejs/nodetaos/taosresult.js +++ b/src/connector/nodejs/nodetaos/taosresult.js @@ -29,19 +29,19 @@ function TaosResult(data, fields) { TaosResult.prototype.pretty = function pretty() { let fieldsStr = ""; let sizing = []; - this.fields.forEach((field,i) => { - if (field._field.type == 8 || field._field.type == 10){ + this.fields.forEach((field, i) => { + if (field._field.type == 8 || field._field.type == 10 ) { sizing.push(Math.max(field.name.length, field._field.bytes)); } else { sizing.push(Math.max(field.name.length, suggestedMinWidths[field._field.type])); } - fieldsStr += fillEmpty(Math.floor(sizing[i]/2 - field.name.length / 2)) + field.name + fillEmpty(Math.ceil(sizing[i]/2 - field.name.length / 2)) + " | "; + fieldsStr += fillEmpty(Math.floor(sizing[i] / 2 - field.name.length / 2)) + field.name + fillEmpty(Math.ceil(sizing[i] / 2 - field.name.length / 2)) + " | "; }); - var sumLengths = sizing.reduce((a,b)=> a+=b,(0)) + sizing.length * 3; + var sumLengths = sizing.reduce((a, b) => a += b, (0)) + sizing.length * 3; console.log("\n" + fieldsStr); - console.log(printN("=",sumLengths)); + console.log(printN("=", sumLengths)); this.data.forEach(row => { let rowStr = ""; row.data.forEach((entry, i) => { @@ -62,16 +62,21 @@ const suggestedMinWidths = { 2: 4, 3: 6, 4: 11, - 5: 12, + 5: 20, 6: 24, 7: 24, 8: 10, 9: 25, 10: 10, + 11: 4, + 12: 6, + 13: 11, + 14: 20, + 15: 20, } function printN(s, n) { let f = ""; - for (let i = 0; i < n; i ++) { + for (let i = 0; i < n; i++) { f += s; } return f; diff --git a/src/connector/nodejs/package.json b/src/connector/nodejs/package.json index d7eba48a463643dd293960251f6eebcb253d93c4..3d8dfc7e0135d8d5e8ba0eacf110d527f9e3f7bf 100644 --- a/src/connector/nodejs/package.json +++ b/src/connector/nodejs/package.json @@ -7,7 +7,7 @@ "test": "test" }, "scripts": { - "test": "node test/test.js && node test/testMicroseconds.js && node test/testNanoseconds.js && node test/testUnsignedType.js && node test/testSchemalessInsert.js " + "test": "node test/test.js && node test/testMicroseconds.js && node test/testNanoseconds.js && node test/testUnsignedType.js && node test/testSchemalessInsert.js && node test/testJsonTag.js" }, "repository": { "type": "git", diff --git a/src/connector/nodejs/test/testJsonTag.js b/src/connector/nodejs/test/testJsonTag.js new file mode 100644 index 0000000000000000000000000000000000000000..a922afb8e6b6614b208a6ba7cd82a8d00f983282 --- /dev/null +++ b/src/connector/nodejs/test/testJsonTag.js @@ -0,0 +1,280 @@ +const taos = require('../tdengine'); +var conn = taos.connect({ host: "127.0.0.1", user: "root", password: "taosdata", config: "/etc/taos", port: 10 }); +var c1 = conn.cursor(); + +function executeUpdate(sql) { + console.log(sql); + c1.execute(sql); +} +function executeQuery(sql, flag = "all") { + console.log(sql); + c1.execute(sql) + var data = c1.fetchall(); + if (flag == "metadata" || flag == "all") { + // Latest query's Field metadata is stored in cursor.fields + console.log(c1.fields); + } 2 + if (flag == "data" || flag == "all") { + // Latest query's result data is stored in cursor.data, also returned by fetchall. + console.log(c1.data); + } + console.log(""); +} + +function prettyQuery(sql) { + try { + c1.query(sql).execute().then(function (result) { + result.pretty(); + }); + } + catch (err) { + conn.close(); + throw err; + } +} + +function executeError(sql) { + console.log(sql); + try { + c1.execute(sql) + } catch (e) { + console.log(e.message); + console.log(""); + } +} + +executeUpdate("create database if not exists nodedb keep 36500;"); +executeUpdate("use nodedb;"); +console.log("# STEP 1 prepare data & validate json string"); +executeUpdate("create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json);"); +executeUpdate("insert into jsons1_1 using jsons1 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 1, false, 'json1', '涛思数据') (1591060608000, 23, true, '涛思数据', 'json')"); +executeUpdate("insert into jsons1_2 using jsons1 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060628000, 2, true, 'json2', 'sss')"); +executeUpdate("insert into jsons1_3 using jsons1 tags('{\"tag1\":false,\"tag2\":\"beijing\"}') values (1591060668000, 3, false, 'json3', 'efwe')"); +executeUpdate("insert into jsons1_4 using jsons1 tags('{\"tag1\":null,\"tag2\":\"shanghai\",\"tag3\":\"hello\"}') values (1591060728000, 4, true, 'json4', '323sd')"); +executeUpdate("insert into jsons1_5 using jsons1 tags('{\"tag1\":1.232, \"tag2\":null}') values(1591060928000, 1, false, '涛思数据', 'ewe')"); +executeUpdate("insert into jsons1_6 using jsons1 tags('{\"tag1\":11,\"tag2\":\"\",\"tag2\":null}') values(1591061628000, 11, false, '涛思数据','')"); +executeUpdate("insert into jsons1_7 using jsons1 tags('{\"tag1\":\"涛思数据\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '涛思数据', 'dws')"); + +console.log("## test duplicate key using the first one. elimate empty key"); +executeUpdate("CREATE TABLE if not exists jsons1_8 using jsons1 tags('{\"tag1\":null, \"tag1\":true, \"tag1\":45, \"1tag$\":2, \" \":90}')"); + +console.log("## test empty json string, save as jtag is NULL"); +executeUpdate("insert into jsons1_9 using jsons1 tags('\t') values (1591062328000, 24, NULL, '涛思数据', '2sdw')"); +executeUpdate("CREATE TABLE if not exists jsons1_10 using jsons1 tags('')"); +executeUpdate("CREATE TABLE if not exists jsons1_11 using jsons1 tags(' ')"); +executeUpdate("CREATE TABLE if not exists jsons1_12 using jsons1 tags('{}')"); +executeUpdate("CREATE TABLE if not exists jsons1_13 using jsons1 tags('null')"); + +console.log("## test invalidate json"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('\"efwewf\"')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('3333')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('33.33')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('false')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('[1,true]')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{222}')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"fe\"}')"); +executeQuery("select * from jsons1;", "data"); + +console.log("## test invalidate json key, key must can be printed assic char="); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":[1,true]}')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":{}}')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"。loc\":\"fff\"}')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\":\"fff\"}')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\t\":\"fff\"}')"); +executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"涛思数据\":\"fff\"}')"); + +console.log("# STEP 2 alter table json tag"); +executeError("ALTER STABLE jsons1 add tag tag2 nchar(20)"); +executeError("ALTER STABLE jsons1 drop tag jtag"); +executeError("ALTER TABLE jsons1_1 SET TAG jtag=4"); +executeUpdate("ALTER TABLE jsons1_1 SET TAG jtag='{\"tag1\":\"femail\",\"tag2\":35,\"tag3\":true}'") + +console.log("# STEP 3 query table"); +console.log("## test error syntax"); +executeError("select * from jsons1 where jtag->tag1='beijing'"); +executeError("select * from jsons1 where jtag->'location'"); +executeError("select * from jsons1 where jtag->''"); +executeError("select * from jsons1 where jtag->''=9"); +executeError("select -> from jsons1"); +executeError("select * from jsons1 where contains"); +executeError("select * from jsons1 where jtag->"); +executeError("select jtag->location from jsons1"); +executeError("select jtag contains location from jsons1"); +executeError("select * from jsons1 where jtag contains location"); +executeError("select * from jsons1 where jtag contains''"); +executeError("select * from jsons1 where jtag contains 'location'='beijing'"); + +console.log("## test select normal column"); +executeQuery("select dataint from jsons1"); + +console.log("## test select json tag"); +executeQuery("select * from jsons1", "data") +executeQuery("select jtag from jsons1", "data"); +executeQuery("select jtag from jsons1 where jtag is null", "data"); +executeQuery("select jtag from jsons1 where jtag is not null", "data"); +executeQuery("select jtag from jsons1_8", "data"); +executeQuery("select jtag from jsons1_1", "data"); + +console.log("## test jtag is NULL"); +executeQuery("select jtag from jsons1_9", "data"); + +console.log("## test select json tag->'key', value is string"); +executeQuery("select jtag->'tag1' from jsons1_1", "data"); +executeQuery("select jtag->'tag2' from jsons1_6", "data"); + +console.log("### test select json tag->'key', value is int"); +executeQuery("select jtag->'tag2' from jsons1_1", "data"); + +console.log("### test select json tag->'key', value is bool"); +executeQuery("select jtag->'tag3' from jsons1_1", "data"); + +console.log("### test select json tag->'key', value is null"); +executeQuery("select jtag->'tag1' from jsons1_4", "data"); + +console.log("### test select json tag->'key', value is double"); +executeQuery("select jtag->'tag1' from jsons1_5", "data"); + +console.log("### test select json tag->'key', key is not exist"); +executeQuery("select jtag->'tag10' from jsons1_4", "data"); +executeQuery("select jtag->'tag1' from jsons1", "data"); + +console.log("### test header name"); +executeQuery("select jtag->'tag1' from jsons1", "metadata"); + +console.log("## test where with json tag"); +executeError("select * from jsons1_1 where jtag is not null"); +executeError("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'"); +executeError("select * from jsons1 where jtag->'tag1'={}"); + +console.log("### where json value is string"); +executeQuery("select * from jsons1 where jtag->'tag2'='beijing'", "data"); +executeQuery("select dataint,tbname,jtag->'tag1',jtag from jsons1 where jtag->'tag2'='beijing'"); +executeQuery("select * from jsons1 where jtag->'tag1'='beijing'", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'='涛思数据'", "data"); +executeQuery("select * from jsons1 where jtag->'tag2'>'beijing'", "data"); +executeQuery("select * from jsons1 where jtag->'tag2'>='beijing'", "data"); +executeQuery("select * from jsons1 where jtag->'tag2'<'beijing'", "data"); +executeQuery("select * from jsons1 where jtag->'tag2'<='beijing'", "data"); +executeQuery("select * from jsons1 where jtag->'tag2'!='beijing'", "data"); +executeQuery("select * from jsons1 where jtag->'tag2'=''", "data"); + +console.log("### where json value is int"); +executeQuery("select * from jsons1 where jtag->'tag1'=5", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'=10", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'<54", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'<=11", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'>4", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'>=5", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'!=5", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'!=55", "data"); + +console.log("### where json value is double"); +executeQuery("select * from jsons1 where jtag->'tag1'=1.232", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'<1.232", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'<=1.232", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'>1.23", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'>=1.232", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'!=1.232", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'!=3.232", "data"); +executeError("select * from jsons1 where jtag->'tag1'/0=3", "data"); +executeError("select * from jsons1 where jtag->'tag1'/5=1", "data"); + +console.log("### where json value is bool"); +executeQuery("select * from jsons1 where jtag->'tag1'=true", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'=false", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'!=false", "data"); +executeError("select * from jsons1 where jtag->'tag1'>false"); + +console.log("### where json value is null"); +executeQuery("select * from jsons1 where jtag->'tag1'=null"); //only json suport =null. This synatx will change later. + +console.log("### where json is null"); +executeQuery("select * from jsons1 where jtag is null", "data"); +executeQuery("select * from jsons1 where jtag is not null", "data"); + +console.log("### where json key is null"); +executeQuery("select * from jsons1 where jtag->'tag_no_exist'=3", "data") + +console.log("### where json value is not exist"); +executeQuery("select * from jsons1 where jtag->'tag1' is null", "data"); +executeQuery("select * from jsons1 where jtag->'tag4' is null", "data"); +executeQuery("select * from jsons1 where jtag->'tag3' is not null", "data") + +console.log("### test contains"); +executeQuery("select * from jsons1 where jtag contains 'tag1'", "data") +executeQuery("select * from jsons1 where jtag contains 'tag3'", "data") +executeQuery("select * from jsons1 where jtag contains 'tag_no_exist'", "data") + +console.log("### test json tag in where condition with and/or"); +executeQuery("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='beijing'", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'=false or jtag->'tag2'='beijing'", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35", "data"); +executeQuery("select * from jsons1 where jtag->'tag1' is not null and jtag contains 'tag3'", "data"); +executeQuery("select * from jsons1 where jtag->'tag1'='femail' and jtag contains 'tag3'", "data"); + +console.log("### test with tbname/normal column"); +executeQuery("select * from jsons1 where tbname = 'jsons1_1'", "data") +executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3'", "data") +executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=3", "data") +executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=23", "data") + +console.log("### test where condition like"); +executeQuery("select *,tbname from jsons1 where jtag->'tag2' like 'bei%'", "data"); +executeQuery("select *,tbname from jsons1 where jtag->'tag1' like 'fe%' and jtag->'tag2' is not null", "data"); + +console.log("### test where condition in no support in"); +executeError("select * from jsons1 where jtag->'tag1' in ('beijing')"); + +console.log("### test where condition match"); +executeQuery("select * from jsons1 where jtag->'tag1' match 'ma'", "data"); +executeQuery("select * from jsons1 where jtag->'tag1' match 'ma$'", "data"); +executeQuery("select * from jsons1 where jtag->'tag2' match 'jing$'", "data"); +executeQuery("select * from jsons1 where jtag->'tag1' match '收到'", "data"); + +console.log("### test distinct"); +executeUpdate("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"涛思数据\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '涛思数据', 'dws')", "data"); +executeQuery("select distinct jtag->'tag1' from jsons1", "data"); +executeQuery("select distinct jtag from jsons1", "data"); + +console.log("### test dumplicate key with normal colomn"); +executeUpdate("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"涛思数据\"}') values(1591060828000, 4, false, 'jjsf', \"涛思数据\")"); +executeQuery("select *,tbname,jtag from jsons1 where jtag->'datastr' match '涛思' and datastr match 'js'", "data"); +executeQuery("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14'", "data"); + +console.log("## test join"); +executeUpdate("create table if not exists jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)") +executeUpdate("insert into jsons2_1 using jsons2 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 2, false, 'json2', '你是2')") +executeUpdate("insert into jsons2_2 using jsons2 tags('{\"tag1\":5,\"tag2\":null}') values (1591060628000, 2, true, 'json2', 'sss')") +executeUpdate("create table if not exists jsons3(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)") +executeUpdate("insert into jsons3_1 using jsons3 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 3, false, 'json3', '你是3')") +executeUpdate("insert into jsons3_2 using jsons3 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060638000, 2, true, 'json3', 'sss')") + +executeQuery("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'", "data"); +executeQuery("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'", "metadata"); + +console.log("## test group by & order by json tag"); + +executeQuery("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc", "data"); +executeQuery("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc", "data"); + +console.log("## test stddev with group by json tag"); +executeQuery("select stddev(dataint) from jsons1 group by jtag->'tag1'", "data"); +executeQuery("select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'", "metadata"); + +console.log("## test top/bottom with group by json tag"); +executeQuery("select top(dataint,100) from jsons1 group by jtag->'tag1'", "metadata"); + +console.log("## subquery with json tag"); +executeQuery("select * from (select jtag, dataint from jsons1)", "metadata"); +executeQuery("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)", "metadata"); +executeQuery("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)", "metada"); +executeQuery("select ts,tbname,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts)", "data") + + +executeUpdate("drop database nodedb;"); + + +setTimeout(() => conn.close(), 2000); diff --git a/src/connector/nodejs/test/testUnsignedType.js b/src/connector/nodejs/test/testUnsignedType.js index 14b102972a898c582e0011698bfd7b3cd771bc42..3f0b0c20459959fe7ea863757220ea77fe377694 100644 --- a/src/connector/nodejs/test/testUnsignedType.js +++ b/src/connector/nodejs/test/testUnsignedType.js @@ -1,14 +1,6 @@ const taos = require('../tdengine'); var conn = taos.connect({ host: "127.0.0.1", user: "root", password: "taosdata", config: "/etc/taos", port: 10 }); var c1 = conn.cursor(); -executeUpdate("create database if not exists nodedb;"); -executeUpdate("use nodedb;"); -executeUpdate("create table if not exists unsigntest(ts timestamp,ut tinyint unsigned,us smallint unsigned,ui int unsigned,ub bigint unsigned,bi bigint);"); -executeUpdate("insert into unsigntest values (now, 254,65534,4294967294,18446744073709551614,9223372036854775807);"); -executeUpdate("insert into unsigntest values (now, 0,0,0,0,-9223372036854775807);"); -executeQuery("select * from unsigntest;"); -executeUpdate("drop database if exists nodedb;"); - function executeUpdate(sql) { console.log(sql); c1.execute(sql); @@ -21,5 +13,28 @@ function executeQuery(sql) { // Latest query's result data is stored in cursor.data, also returned by fetchall. console.log(c1.data); } + +function prettyQuery(sql){ + try { + c1.query(sql).execute().then(function(result){ + result.pretty(); + }); + } + catch (err) { + conn.close(); + throw err; + } +} + +executeUpdate("create database nodedb;"); +executeUpdate("use nodedb;"); +executeUpdate("create table unsigntest(ts timestamp,ut tinyint unsigned,us smallint unsigned,ui int unsigned,ub bigint unsigned,bi bigint);"); +executeUpdate("insert into unsigntest values (now, 254,65534,4294967294,18446744073709551614,9223372036854775807);"); +executeUpdate("insert into unsigntest values (now, 0,0,0,0,-9223372036854775807);"); +executeQuery("select * from unsigntest;"); +prettyQuery("select * from unsigntest;"); +executeUpdate("drop database nodedb;"); + + setTimeout(()=>conn.close(),2000); diff --git a/src/kit/taos-tools b/src/kit/taos-tools index 0b4a16e96b5cc9cb6e4f8cacf6a1f3028c91adb0..dca4059d87c3f5c678a5e946978d40daec204e27 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit 0b4a16e96b5cc9cb6e4f8cacf6a1f3028c91adb0 +Subproject commit dca4059d87c3f5c678a5e946978d40daec204e27 diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 838aa577ae0fe396f3e80d2fca9066de10d3bc7a..fd6d60c034c702e12a5d996f5b130e54bf3c6a4f 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -298,7 +298,7 @@ void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t o if (have) continue; - if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_DROPPING) { + if (/*pVgroup->status == TAOS_VG_STATUS_CREATING ||*/ pVgroup->status == TAOS_VG_STATUS_DROPPING) { mDebug("vgId:%d, not exist in dnode:%d and status is %s, do nothing", pVgroup->vgId, pDnode->dnodeId, vgroupStatus[pVgroup->status]); } else { diff --git a/src/plugins/taosadapter b/src/plugins/taosadapter index 88346a2e4e2e9282d2ec8b8c5264ca1ec23698a1..826f3d3b7820a5c007d301854d56db003b424d0a 160000 --- a/src/plugins/taosadapter +++ b/src/plugins/taosadapter @@ -1 +1 @@ -Subproject commit 88346a2e4e2e9282d2ec8b8c5264ca1ec23698a1 +Subproject commit 826f3d3b7820a5c007d301854d56db003b424d0a diff --git a/src/query/inc/tdigest.h b/src/query/inc/tdigest.h index 625311eaabebec1f3d3b8303f34a361ba0129094..f9b615318f5c33f0cf386653367ddfe36ae759f8 100644 --- a/src/query/inc/tdigest.h +++ b/src/query/inc/tdigest.h @@ -29,7 +29,7 @@ #define DOUBLE_MAX 1.79e+308 #define ADDITION_CENTROID_NUM 2 -#define COMPRESSION 400 +#define COMPRESSION 300 #define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1 + ADDITION_CENTROID_NUM) #define GET_THRESHOLD(compression) (7.5 + 0.37 * compression - 2e-4 * pow(compression, 2)) #define TDIGEST_SIZE(compression) (sizeof(TDigest) + sizeof(SCentroid)*GET_CENTROID(compression) + sizeof(SPt)*GET_THRESHOLD(compression)) diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index 2a2ccf9cae0f9e2aab60bddca7c27a8ceb719239..9bdb0efc4d3ed7769aa99ded02e460fe0624ae27 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -279,6 +279,7 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) { if (isQueryKilled(pQInfo)) { qDebug("QInfo:0x%"PRIx64" it is already killed, abort", pQInfo->qId); + setQueryKilled(pQInfo); pQInfo->runtimeEnv.outputBuf = NULL; return doBuildResCheck(pQInfo); } diff --git a/src/tfs/src/tfs.c b/src/tfs/src/tfs.c index 43ccb324b235c2bfed6b121ed2049474cc5ecb74..b3aabe177bd4c34151cbe2778825bed6262679ab 100644 --- a/src/tfs/src/tfs.c +++ b/src/tfs/src/tfs.c @@ -265,7 +265,10 @@ int tfsMkdirRecurAt(const char *rname, int level, int id) { if (errno == ENOENT) { // Try to create upper char *s = strdup(rname); - + if (strcmp(s, ".") == 0){ // TD-12238, if mkdir failed, rname will be ".", it will be always failed, so need to jump recursion + free(s); + return -1; + } // Make a copy of dirname(s) because the implementation of 'dirname' differs on different platforms. // Some platform may modify the contents of the string passed into dirname(). Others may return a pointer to // internal static storage space that will be overwritten by next call. For case like that, we should not use diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 8dc2d4c993e001c95f63d72c60db8b8fe3ac3df8..7d1076abbf1eb0c35385b769bfc6a88cfd8a21a7 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -356,7 +356,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p epSet.inUse = 0; epSet.numOfEps = 1; epSet.port[0] = port; - strcpy(epSet.fqdn[0], serverFqdn); + tstrncpy(epSet.fqdn[0], serverFqdn, sizeof(epSet.fqdn[0])); reqMsg.msgType = TSDB_MSG_TYPE_NETWORK_TEST; reqMsg.pCont = rpcMallocCont(pktLen); @@ -364,7 +364,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p reqMsg.code = 0; reqMsg.handle = NULL; // rpc handle returned to app reqMsg.ahandle = NULL; // app handle set by client - strcpy(reqMsg.pCont, "nettest"); + tstrncpy((char*)reqMsg.pCont, "nettest", pktLen); rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg); @@ -606,7 +606,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen, epSet.inUse = 0; epSet.numOfEps = 1; epSet.port[0] = port; - strcpy(epSet.fqdn[0], host); + tstrncpy(epSet.fqdn[0], host, sizeof(epSet.fqdn[0])); reqMsg.msgType = TSDB_MSG_TYPE_NETWORK_TEST; reqMsg.pCont = rpcMallocCont(pkgLen); @@ -614,8 +614,8 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen, reqMsg.code = 0; reqMsg.handle = NULL; // rpc handle returned to app reqMsg.ahandle = NULL; // app handle set by client - strcpy(reqMsg.pCont, "nettest speed"); - + tstrncpy((char*)reqMsg.pCont, "nettest speed", pkgLen); + rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg); int code = 0; diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index c15197b7537601c0f0ca72420a6711547d1ed0ed..02498e222212fada5b7a9f39fbcfe5c76494a651 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -57,36 +57,32 @@ int32_t strdequote(char *z) { return j + 1; // only one quote, do nothing } - +// delete escape character: \\, \', \" int32_t strRmquote(char *z, int32_t len){ - // delete escape character: \\, \', \" - char delim = z[0]; - if (delim != '\'' && delim != '\"') { - return len; + char delim = 0; + int32_t cnt = 0; + int32_t j = 0; + for (size_t k = 0; k < len; ++k) { + if (!delim && (z[k] == '\'' || z[k] == '"')){ // find the start ' or " + delim = z[k]; } - int32_t cnt = 0; - int32_t j = 0; - for (uint32_t k = 1; k < len - 1; ++k) { - if (z[k] == '\\' || (z[k] == delim && z[k + 1] == delim)) { - if ((z[k] == '\\' && z[k + 1] == '_') || (z[k] == '\\' && z[k + 1] == '%')) { - //match '_' self - } else { - z[j] = z[k + 1]; - cnt++; - j++; - k++; - continue; - } - } - - z[j] = z[k]; + if ((z[k] == '\\' && z[k + 1] == '_') || (z[k] == '\\' && z[k + 1] == '%')) { + //match '_' '%' self + }else if(z[k] == '\\'){ + z[j] = z[k + 1]; + cnt++; j++; + k++; + continue; + }else if(z[k] == delim){ + continue; } - - z[j] = 0; - - return len - 2 - cnt; + z[j] = z[k]; + j++; + } + z[j] = 0; + return j; } int32_t strRmquoteEscape(char *z, int32_t len) { diff --git a/src/util/tests/stringTest.cpp b/src/util/tests/stringTest.cpp index 95fba0cd3e2b62da2b2dadb0b7e592aef5893543..e304ccaec6753ed627418ea8bf2fd428ae710859 100644 --- a/src/util/tests/stringTest.cpp +++ b/src/util/tests/stringTest.cpp @@ -6,6 +6,44 @@ #include "taos.h" #include "tutil.h" +TEST(testCase, str_rmquote_test) { + char t1[] = "\"\".dd"; + int32_t len = strRmquote(t1, strlen(t1)); + printf("t1:%s, len:%d\n", t1, len); + EXPECT_EQ(3, len); + EXPECT_STRCASEEQ(t1, ".dd"); + + char t2[] = "\"fsd\\\"fs\".dd"; + len = strRmquote(t2, strlen(t2)); + printf("t2:%s, len:%d\n", t2, len); + EXPECT_EQ(9, len); + EXPECT_STRCASEEQ(t2, "fsd\"fs.dd"); + + char t3[] = "fs\\_d\\%.d\\d"; + len = strRmquote(t3, strlen(t3)); + printf("t3:%s, len:%d\n", t3, len); + EXPECT_EQ(10, len); + EXPECT_STRCASEEQ(t3, "fs\\_d\\%.dd"); + + char t4[] = "\"fs\\_d\\%\".dd"; + len = strRmquote(t4, strlen(t4)); + printf("t4:%s, len:%d\n", t4, len); + EXPECT_EQ(10, len); + EXPECT_STRCASEEQ(t4, "fs\\_d\\%.dd"); + + char t5[] = "\"fs\\_d\\%\""; + len = strRmquote(t5, strlen(t5)); + printf("t5:%s, len:%d\n", t5, len); + EXPECT_EQ(7, len); + EXPECT_STRCASEEQ(t5, "fs\\_d\\%"); + + char t6[] = "'fs\\_d\\%'"; + len = strRmquote(t6, strlen(t6)); + printf("t6:%s, len:%d\n", t6, len); + EXPECT_EQ(7, len); + EXPECT_STRCASEEQ(t6, "fs\\_d\\%"); +} + TEST(testCase, string_dequote_test) { char t1[] = "'abc'"; int32_t len = strdequote(t1); diff --git a/tests/develop-test/0-management/3-tag/json_tag.py b/tests/develop-test/0-management/3-tag/json_tag.py index dc7affe870f4462526aa1095311278d280abe77f..b6a15ca770ea7e4885973a03bfc8e3bd08c3f54d 100644 --- a/tests/develop-test/0-management/3-tag/json_tag.py +++ b/tests/develop-test/0-management/3-tag/json_tag.py @@ -75,6 +75,10 @@ class TDTestCase: tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\t\":\"fff\"}')") tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"试试\":\"fff\"}')") + # test invalidate json value, value number can not be inf,nan TD-12166 + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"k\":1.8e308}')") + tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"k\":-1.8e308}')") + #test length limit char1= ''.join(['abcd']*64) char3= ''.join(['abcd']*1022) diff --git a/tests/develop-test/1-insert/0-sql/basic.py b/tests/develop-test/1-insert/0-sql/basic.py deleted file mode 100644 index 273ff8ba488db609cfa4aa5978c689288d14750b..0000000000000000000000000000000000000000 --- a/tests/develop-test/1-insert/0-sql/basic.py +++ /dev/null @@ -1,68 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -from util.log import * -from util.cases import * -from util.sql import * - - -class TDTestCase: - def caseDescription(self): - ''' - case1: insert 倒序插入 - case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 - case3: [TD-XXXX]insert语句在values之间加入多个逗号 - ''' - return - - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tdSql.prepare() - - ret = tdSql.execute('create table tb (ts timestamp, speed int)') - - insertRows = 10 - tdLog.info("insert %d rows" % (insertRows)) - for i in range(0, insertRows): - ret = tdSql.execute( - 'insert into tb values (now + %dm, %d)' % - (i, i)) - - tdLog.info("insert earlier data") - tdSql.execute('insert into tb values (now - 5m , 10)') - tdSql.execute('insert into tb values (now - 6m , 10)') - tdSql.execute('insert into tb values (now - 7m , 10)') - tdSql.execute('insert into tb values (now - 8m , 10)') - - tdSql.query("select * from tb") - tdSql.checkRows(insertRows + 4) - - # test case for https://jira.taosdata.com:18080/browse/TD-3716: - tdSql.error("insert into tb(now, 1)") - # test case for TD-10717 - tdSql.error("insert into tb values(now,1),,(now+1s,1)") - tdSql.execute("insert into tb values(now+2s,1),(now+3s,1),(now+4s,1)") - tdSql.query("select * from tb") - tdSql.checkRows(insertRows + 4 +3) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/examples/JDBC/connectionPools/pom.xml b/tests/examples/JDBC/connectionPools/pom.xml index 91f1cb36f28840b7d5eeb428aca3f940365ed59d..aad2923b823c1fcf2cb87eba4f18865fede063a1 100644 --- a/tests/examples/JDBC/connectionPools/pom.xml +++ b/tests/examples/JDBC/connectionPools/pom.xml @@ -53,7 +53,7 @@ org.apache.logging.log4j log4j-core - 2.15.0 + 2.17.0 diff --git a/tests/examples/JDBC/taosdemo/pom.xml b/tests/examples/JDBC/taosdemo/pom.xml index c6e61f5d22ca83c5d56deef7db9354913a3321b1..23c74ef1b72e0f2fd8b2a647a798872062a9c216 100644 --- a/tests/examples/JDBC/taosdemo/pom.xml +++ b/tests/examples/JDBC/taosdemo/pom.xml @@ -88,7 +88,7 @@ org.apache.logging.log4j log4j-core - 2.15.0 + 2.17.0 diff --git a/tests/pytest/fulltest-connector.sh b/tests/pytest/fulltest-connector.sh index eb685bd2146508a55d470c45bd3b4780997de64c..89361e5ea1917e877373dc856f926a1a9d32dde9 100755 --- a/tests/pytest/fulltest-connector.sh +++ b/tests/pytest/fulltest-connector.sh @@ -1,9 +1,10 @@ #!/bin/bash ulimit -c unlimited #======================p1-start=============== -#======================p1-end=============== # restful test for python # python3 test.py -f restful/restful_bind_db1.py # python3 test.py -f restful/restful_bind_db2.py -python3 ./test.py -f client/nettest.py \ No newline at end of file +python3 ./test.py -f client/nettest.py + +#======================p1-end=============== diff --git a/tests/pytest/fulltest-insert.sh b/tests/pytest/fulltest-insert.sh index 6a2a027c818ecc018829436b63e86a9d96629e5b..85b36bda29a047c788eb00b991bb890a2c270bac 100755 --- a/tests/pytest/fulltest-insert.sh +++ b/tests/pytest/fulltest-insert.sh @@ -1,7 +1,6 @@ #!/bin/bash ulimit -c unlimited #======================p1-start=============== -#======================p1-end=============== python3 testCompress.py python3 testNoCompress.py @@ -24,6 +23,10 @@ python3 ./test.py -f import_merge/importBlock2TPO.py python3 ./test.py -f import_merge/importBlock2T.py python3 ./test.py -f import_merge/importBlockbetween.py python3 ./test.py -f import_merge/importCacheFileHO.py + +#======================p1-end=============== +#======================p2-start=============== + python3 ./test.py -f import_merge/importCacheFileHPO.py python3 ./test.py -f import_merge/importCacheFileH.py python3 ./test.py -f import_merge/importCacheFileS.py @@ -45,6 +48,10 @@ python3 ./test.py -f import_merge/importDataLastTPO.py python3 ./test.py -f import_merge/importDataLastT.py python3 ./test.py -f import_merge/importDataS.py python3 ./test.py -f import_merge/importDataSub.py + +#======================p2-end=============== +#======================p3-start=============== + python3 ./test.py -f import_merge/importDataTO.py python3 ./test.py -f import_merge/importDataTPO.py python3 ./test.py -f import_merge/importDataT.py @@ -66,6 +73,10 @@ python3 ./test.py -f import_merge/importSpan.py python3 ./test.py -f import_merge/importSRestart.py python3 ./test.py -f import_merge/importSubRestart.py python3 ./test.py -f import_merge/importTailOverlap.py + +#======================p3-end=============== +#======================p4-start=============== + python3 ./test.py -f import_merge/importTailPartOverlap.py python3 ./test.py -f import_merge/importTail.py python3 ./test.py -f import_merge/importToCommit.py @@ -87,6 +98,8 @@ python3 ./test.py -f insert/double.py python3 ./test.py -f insert/smallint.py python3 ./test.py -f insert/tinyint.py python3 ./test.py -f insert/date.py + + python3 ./test.py -f insert/binary.py python3 ./test.py -f insert/nchar.py #python3 ./test.py -f insert/nchar-boundary.py @@ -142,6 +155,13 @@ python3 ./test.py -f update/merge_commit_data-0.py python3 ./test.py -f wal/addOldWalTest.py python3 ./test.py -f wal/sdbComp.py +#======================p4-end=============== +#======================p5-start=============== +python3 ./test.py -f ../system-test/1-insert/0-sql/basic.py +python3 ./test.py -f ../develop-test/1-insert/0-sql/basic.py +python3 ./test.py -f ../develop-test/1-insert/0-sql/batchInsert.py + +#======================p5-end=============== diff --git a/tests/pytest/fulltest-others.sh b/tests/pytest/fulltest-others.sh index e0b0851a22de16dbc3e6aea17937121573eb9997..a081833ddb323ad1becfc24f48fdaaebac26b328 100755 --- a/tests/pytest/fulltest-others.sh +++ b/tests/pytest/fulltest-others.sh @@ -1,7 +1,6 @@ #!/bin/bash ulimit -c unlimited #======================p1-start=============== -#======================p1-end=============== #python3 ./test.py -f dbmgmt/database-name-boundary.py python3 test.py -f dbmgmt/nanoSecondCheck.py @@ -13,6 +12,9 @@ python3 ./test.py -f tsdb/tsdbComp.py python3 ./test.py -f user/user_create.py python3 ./test.py -f user/pass_len.py +#======================p1-end=============== +#======================p2-start=============== + # perfbenchmark python3 ./test.py -f perfbenchmark/bug3433.py #python3 ./test.py -f perfbenchmark/bug3589.py @@ -22,6 +24,10 @@ python3 ./test.py -f perfbenchmark/bug3433.py python3 ./test.py -f alter/alter_table_crash.py python3 ./test.py -f alter/alterTabAddTagWithNULL.py python3 ./test.py -f alter/alterTimestampColDataProcess.py + +#======================p2-end=============== +#======================p3-start=============== + python3 ./test.py -f alter/alter_table.py python3 ./test.py -f alter/alter_debugFlag.py python3 ./test.py -f alter/alter_keep.py @@ -29,6 +35,9 @@ python3 ./test.py -f alter/alter_cacheLastRow.py python3 ./test.py -f alter/alter_create_exception.py python3 ./test.py -f alter/alterColMultiTimes.py +#======================p3-end=============== +#======================p4-start=============== + python3 ./test.py -f account/account_create.py # client @@ -40,9 +49,13 @@ python3 ./test.py -f client/taoshellCheckCase.py # python3 ./test.py -f client/change_time_1_1.py # python3 ./test.py -f client/change_time_1_2.py python3 client/twoClients.py - python3 testMinTablesPerVnode.py # topic python3 ./test.py -f topic/topicQuery.py +#======================p4-end=============== +#======================p5-start=============== +python3 ./test.py -f ../system-test/0-management/1-stable/create_col_tag.py +python3 ./test.py -f ../develop-test/0-management/3-tag/json_tag.py +#======================p5-end=============== diff --git a/tests/pytest/fulltest-query.sh b/tests/pytest/fulltest-query.sh index 04e1eb7c527a69fdadf78985062ee2ba02d41517..b36694017c405991271340c91d21da7ca2e1b21b 100755 --- a/tests/pytest/fulltest-query.sh +++ b/tests/pytest/fulltest-query.sh @@ -1,8 +1,6 @@ #!/bin/bash ulimit -c unlimited #======================p1-start=============== -#======================p1-end=============== - # timezone python3 ./test.py -f TimeZone/TestCaseTimeZone.py @@ -40,6 +38,10 @@ python3 ./test.py -f tag_lite/bool_binary.py python3 ./test.py -f tag_lite/bool_int.py python3 ./test.py -f tag_lite/bool.py python3 ./test.py -f tag_lite/change.py + +#======================p1-end=============== +#======================p2-start=============== + python3 ./test.py -f tag_lite/column.py python3 ./test.py -f tag_lite/commit.py python3 ./test.py -f tag_lite/create.py @@ -64,6 +66,9 @@ python3 ./test.py -f tag_lite/alter_tag.py python3 ./test.py -f tag_lite/drop_auto_create.py python3 ./test.py -f tag_lite/json_tag_extra.py +#======================p2-end=============== +#======================p3-start=============== + #query python3 ./test.py -f query/distinctOneColTb.py python3 ./test.py -f query/filter.py @@ -113,6 +118,10 @@ python3 ./test.py -f query/subqueryFilter.py python3 ./test.py -f query/nestedQuery/queryInterval.py python3 ./test.py -f query/queryStateWindow.py # python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py + +#======================p3-end=============== +#======================p4-start=============== + python3 ./test.py -f query/nestquery_last_row.py python3 ./test.py -f query/nestedQuery/nestedQuery.py python3 ./test.py -f query/nestedQuery/nestedQuery_datacheck.py @@ -159,6 +168,9 @@ python3 test.py -f subscribe/singlemeter.py #python3 test.py -f subscribe/stability.py python3 test.py -f subscribe/supertable.py +#======================p4-end=============== +#======================p5-start=============== + # functions python3 ./test.py -f functions/all_null_value.py python3 ./test.py -f functions/function_avg.py -r 1 @@ -198,3 +210,10 @@ python3 ./test.py -f functions/function_percentile2.py python3 ./test.py -f functions/variable_httpDbNameMandatory.py + +######## system-test +#python3 ./test.py -f ../system-test/2-query/9-others/TD-11389.py # this case will run when this bug fix TD-11389 + + +#======================p5-end=============== + diff --git a/tests/pytest/fulltest-tools.sh b/tests/pytest/fulltest-tools.sh index cac445501229f0b54f1464a07583d05cbf4c88a4..d1f83e9fb289f36d52340b0ed942c912f361c2de 100755 --- a/tests/pytest/fulltest-tools.sh +++ b/tests/pytest/fulltest-tools.sh @@ -1,7 +1,6 @@ #!/bin/bash ulimit -c unlimited #======================p1-start=============== -#======================p1-end=============== # tools python3 test.py -f tools/taosdumpTest.py @@ -10,12 +9,18 @@ python3 test.py -f tools/taosdumpTest2.py python3 test.py -f tools/taosdemoTest.py python3 test.py -f tools/taosdemoTestWithoutMetric.py python3 test.py -f tools/taosdemoTestWithJson.py + +#======================p1-end=============== +#======================p2-start=============== + python3 test.py -f tools/taosdemoTestLimitOffset.py python3 test.py -f tools/taosdemoTestTblAlt.py python3 test.py -f tools/taosdemoTestSampleData.py python3 test.py -f tools/taosdemoTestInterlace.py # python3 test.py -f tools/taosdemoTestQuery.py python3 ./test.py -f tools/taosdemoTestdatatype.py +#======================p2-end=============== +#======================p3-start=============== # nano support python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py @@ -24,17 +29,24 @@ python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosub python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py python3 test.py -f tools/taosdumpTestNanoSupport.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py +#======================p3-end=============== +#======================p4-start=============== + python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertAllType.py python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py + #python3 test.py -f tools/taosdemoAllTest/TD-10539/create_taosdemo.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertShell.py +#======================p4-end=============== +#======================p5-start=============== +#======================p5-end=============== diff --git a/tests/pytest/tools/taosdemoTestTblAlt.py b/tests/pytest/tools/taosdemoTestTblAlt.py index 7587ab9eb3e89275451864d28ccf985bcaac949a..444aab519bf7089b792125ffa3caa6de5ad4eb8d 100644 --- a/tests/pytest/tools/taosdemoTestTblAlt.py +++ b/tests/pytest/tools/taosdemoTestTblAlt.py @@ -30,6 +30,7 @@ class TDTestCase: self.numberOfRecords = 1000000 def getBuildPath(self): + buildPath="" selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -38,7 +39,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files and "taosBenchmark" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] @@ -48,7 +49,7 @@ class TDTestCase: def insertDataAndAlterTable(self, threadID): buildPath = self.getBuildPath() if (buildPath == ""): - tdLog.exit("taosd not found!") + tdLog.exit("taosd or staosBenchmark not found!") else: tdLog.info("taosd found in %s" % buildPath) binPath = buildPath + "/build/bin/" diff --git a/tests/pytest/tools/taosdumpTest2.py b/tests/pytest/tools/taosdumpTest2.py index 839988375b652b0cfad09d8a6de7697de19609ea..c60fb42266c6d23ad9aeabc9bf9f48ac5feec17b 100644 --- a/tests/pytest/tools/taosdumpTest2.py +++ b/tests/pytest/tools/taosdumpTest2.py @@ -69,7 +69,7 @@ class TDTestCase: os.system("rm /tmp/*.sql") os.system( - "%staosdump --databases db -o /tmp -B 32766 -L 1048576" % + "%staosdump --databases db -o /tmp -B 16384 -L 1048576" % binPath) tdSql.execute("drop database db") diff --git a/tests/pytest/tools/taosdumpTest3.py b/tests/pytest/tools/taosdumpTest3.py index d13c502fd5887d47b5094ef5bd08691372f9648b..ed83fe1ffb39f24f6eb7073d91bcaf62437527c3 100644 --- a/tests/pytest/tools/taosdumpTest3.py +++ b/tests/pytest/tools/taosdumpTest3.py @@ -137,7 +137,6 @@ class TDTestCase: # verify ns os.system("%staosdump -o ./taosdumptest/tmp6 dp3 st0_0" % binPath) - assert os.system("%staosdump -o ./taosdumptest/tmp6 dp3 st0_0 -C ns " % binPath) != 0 # verify -D:--database os.system("%staosdump -o ./taosdumptest/tmp5 --databases dp1,dp2 " % binPath) diff --git a/tests/script/general/parser/col_arithmetic_query.sim b/tests/script/general/parser/col_arithmetic_query.sim index 9b0dc8e964cf39909b803fe5ea20a7bdff8ceb59..fa1bf5e54fc1570f21160161371833b1e701f846 100644 --- a/tests/script/general/parser/col_arithmetic_query.sim +++ b/tests/script/general/parser/col_arithmetic_query.sim @@ -660,6 +660,19 @@ sql select c2-c2 from $tb sql select first(c1)-last(c1), spread(c2), max(c3) - min(c3), avg(c4)*count(c4) from $tb +# arithmetic operation with now [d.21]=============================================================== +sql_error select now from $tb +sql_error select now + 123 from $tb +sql_error select 123 + now from $tb +sql_error select now - 123 from $tb +sql_error select 123 - now from $tb +sql_error select now * 123 from $tb +sql_error select 123 * now from $tb +sql_error select now / 123 from $tb +sql_error select 123 / now from $tb +sql_error select now % 123 from $tb +sql_error select 123 % now from $tb +sql_error select 12 * now / 12 + 12 - 12 * 12 from $tb #====================================================super table query================================================== diff --git a/tests/script/general/parser/nestquery.sim b/tests/script/general/parser/nestquery.sim index a721e19b99f95274c658497a0fcbeb097903edf2..3653efe0be35340c3aa68b678f63de7f0a0dda10 100644 --- a/tests/script/general/parser/nestquery.sim +++ b/tests/script/general/parser/nestquery.sim @@ -941,6 +941,17 @@ if $data02 != 0 then return -1 endi +print ==============> TD-11969 +sql create database test11969; +sql use test11969; +sql create stable st (ts timestamp , id int ) tags (ind int ); +sql insert into sub1 using st tags(1) values(now ,1); +sql insert into sub1 using st tags(1) values(now ,2); +sql insert into sub2 using st tags(2) values(now ,3); +sql insert into sub2 using st tags(2) values(now ,4); +sql_error select max(ts_inter) ,tbname from (select elapsed(ts) ts_inter ,tbname from st interval (1s) group by tbname) order by ts +sql drop database test11969 + print ==========================================> TD-11097 sql create database td11097 sql use td11097 @@ -1144,4 +1155,5 @@ if $data51 != @43@ then return -1 endi sql drop database td11097 + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim index 258b59f4ae5ffd75878bca469efc226a6d2d0825..be8d691f59e1fbd00e41b5bd625e09bfc6783845 100644 --- a/tests/script/general/parser/select_with_tags.sim +++ b/tests/script/general/parser/select_with_tags.sim @@ -961,9 +961,9 @@ sql create database test11943; sql use test11943; sql create stable st (ts timestamp , id int ) tags (ind int ); sql insert into sub1 using st tags(1) values(now ,1); -sql insert into sub1 using st tags(1) values(now ,2); -sql insert into sub2 using st tags(2) values(now ,3); -sql insert into sub2 using st tags(2) values(now ,4); +sql insert into sub1 using st tags(1) values(now+1s ,2); +sql insert into sub2 using st tags(2) values(now+2s ,3); +sql insert into sub2 using st tags(2) values(now+3s ,4); sql select tbname ,max(id)+5 from sub1; if $data00 != @sub1@ then return -1 diff --git a/tests/system-test/0-management/1-stable/create_col_tag.py b/tests/system-test/0-management/1-stable/create_col_tag.py index d195e73321ea24a8b9de1f2ca5f9c07f9182dd65..826e68f3211e80b4b8dc029895b9145a70f654c6 100644 --- a/tests/system-test/0-management/1-stable/create_col_tag.py +++ b/tests/system-test/0-management/1-stable/create_col_tag.py @@ -23,10 +23,10 @@ from util.sql import tdSql class TDTestCase: def caseDescription(self): ''' - case1:The escape char "`" can be used for both tag name and column name - case2:create stable(column&tag); insert data; show stable; show create table; add stable(column&tag);change stable(tag);drop stable(column&tag);modify stable(column&tag)(binary和nchar);drop stable; - case3:create stable_child; insert data; show stable_child; show create stable_child; drop stable_child; - case4:create regular_table(column); insert data; show regular_table; show create regular_table; add regular_table(column);drop regular_table(column);modify regular_table(column)(binary和nchar);drop regular_table; + case1:The escape char "`" can be used for both tag name and column name + case2:create stable(column&tag); insert data; show stable; show create table; add stable(column&tag);change stable(tag);drop stable(column&tag);modify stable(column&tag)(binary and nchar);drop stable; + case3:create stable_child; insert data; show stable_child; show create stable_child; drop stable_child; + case4:create regular_table(column); insert data; show regular_table; show create regular_table; add regular_table(column);drop regular_table(column);modify regular_table(column)(binary and nchar);drop regular_table; ''' return diff --git a/tests/system-test/1-insert/0-sql/basic.py b/tests/system-test/1-insert/0-sql/basic.py deleted file mode 100644 index 3604224c512d4a9f85de30a9069136801d343503..0000000000000000000000000000000000000000 --- a/tests/system-test/1-insert/0-sql/basic.py +++ /dev/null @@ -1,67 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -from util.log import * -from util.cases import * -from util.sql import * - - -class TDTestCase: - def caseDescription(self): - ''' - case1: insert 倒序插入 - case2: 语法解析错误同时meta请求也发出去了导致callback中处理逻辑失效 - case3: [TD-XXXX]insert语句在values之间加入多个逗号 - ''' - return - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tdSql.prepare() - - ret = tdSql.execute('create table tb (ts timestamp, speed int)') - - insertRows = 10 - tdLog.info("insert %d rows" % (insertRows)) - for i in range(0, insertRows): - ret = tdSql.execute( - 'insert into tb values (now + %dm, %d)' % - (i, i)) - - tdLog.info("insert earlier data") - tdSql.execute('insert into tb values (now - 5m , 10)') - tdSql.execute('insert into tb values (now - 6m , 10)') - tdSql.execute('insert into tb values (now - 7m , 10)') - tdSql.execute('insert into tb values (now - 8m , 10)') - - tdSql.query("select * from tb") - tdSql.checkRows(insertRows + 4) - - # test case for https://jira.taosdata.com:18080/browse/TD-3716: - tdSql.error("insert into tb(now, 1)") - # test case for TD-10717 - tdSql.error("insert into tb values(now,1),,(now+1s,1)") - tdSql.execute("insert into tb values(now+2s,1),(now+3s,1),(now+4s,1)") - tdSql.query("select * from tb") - tdSql.checkRows(insertRows + 4 +3) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase())