testpackage.sh 5.1 KB
Newer Older
haoranc's avatar
haoranc 已提交
1 2 3 4 5 6 7 8 9
#!/bin/sh


packgeName=$1
version=$2
originPackageName=$3
originversion=$4
testFile=$5
subFile="taos.tar.gz"
haoranc's avatar
haoranc 已提交
10
password=$6
haoranc's avatar
haoranc 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

if [ ${testFile} = "server" ];then
    tdPath="TDengine-server-${version}"
    originTdpPath="TDengine-server-${originversion}"
    installCmd="install.sh"
elif [ ${testFile} = "client" ];then
    tdPath="TDengine-client-${version}"
    originTdpPath="TDengine-client-${originversion}"
    installCmd="install_client.sh"    
elif [ ${testFile} = "tools" ];then
    tdPath="taosTools-${version}"
    originTdpPath="taosTools-${originversion}"
    installCmd="install-taostools.sh"
fi

haoranc's avatar
haoranc 已提交
26 27 28 29 30 31
function cmdInstall {
comd=$1
if command -v ${comd} ;then
    echo "${comd} is already installed" 
else 
    if command -v apt ;then
haoranc's avatar
haoranc 已提交
32
        apt-get install ${comd} -y 
haoranc's avatar
haoranc 已提交
33
    elif command -v yum ;then
haoranc's avatar
haoranc 已提交
34
        yum -y install ${comd} 
haoranc's avatar
haoranc 已提交
35 36 37 38 39 40
        echo "you should install ${comd} manually"
    fi
fi
}


haoranc's avatar
haoranc 已提交
41 42 43 44
echo "Uninstall all components of TDeingne"

if command -v rmtaos ;then
    echo "uninstall all components of TDeingne:rmtaos"
haoranc's avatar
haoranc 已提交
45
    rmtaos 
haoranc's avatar
haoranc 已提交
46 47 48 49 50 51
else 
    echo "os doesn't include TDengine "
fi

if command -v rmtaostools ;then
    echo "uninstall all components of TDeingne:rmtaostools"
haoranc's avatar
haoranc 已提交
52
    rmtaostools
haoranc's avatar
haoranc 已提交
53 54 55 56
else 
    echo "os doesn't include rmtaostools "
fi

haoranc's avatar
haoranc 已提交
57 58 59

cmdInstall tree
cmdInstall wget
haoranc's avatar
haoranc 已提交
60
cmdInstall sshpass
haoranc's avatar
haoranc 已提交
61

haoranc's avatar
haoranc 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
echo "new workroom path"
installPath="/usr/local/src/packageTest"
oriInstallPath="/usr/local/src/packageTest/3.1"

if [ ! -d ${installPath} ] ;then
    mkdir -p ${installPath}
else  
    echo "${installPath} already exists"
fi


if [ ! -d ${oriInstallPath} ] ;then
    mkdir -p ${oriInstallPath}
else  
    echo "${oriInstallPath} already exists"
fi




haoranc's avatar
haoranc 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
echo "download  installPackage"
# cd ${installPath}
# wget https://www.taosdata.com/assets-download/3.0/${packgeName}
# cd  ${oriInstallPath}
# wget https://www.taosdata.com/assets-download/3.0/${originPackageName}

cd ${installPath}
if [ ! -f  {packgeName}  ];then
    sshpass -p ${password} scp 192.168.1.131:/nas/TDengine3/v${version}/community/${packgeName}  .
fi
if [ ! -f  debAuto.sh  ];then
    echo '#!/usr/bin/expect ' >  debAuto.sh
    echo 'set timeout 3 ' >>  debAuto.sh
    echo 'pset packgeName [lindex $argv 0]' >>  debAuto.sh
    echo 'spawn dpkg -i ${packgeName}' >>  debAuto.sh
    echo 'expect "*one:"' >>  debAuto.sh
    echo 'send  "\r"' >>  debAuto.sh
    echo 'expect "*skip:"' >>  debAuto.sh
    echo 'send  "\r" ' >>  debAuto.sh
fi

haoranc's avatar
haoranc 已提交
103
if [[ ${packgeName} =~ "deb" ]];then
haoranc's avatar
haoranc 已提交
104
    cd ${installPath}
haoranc's avatar
haoranc 已提交
105 106 107 108 109 110 111
    dpkg -r taostools
    dpkg -r tdengine
    if [[ ${packgeName} =~ "TDengine" ]];then
        echo "./debAuto.sh ${packgeName}" &&   chmod 755 debAuto.sh &&  ./debAuto.sh ${packgeName}
    else
        echo "dpkg  -i ${packgeName}" &&   dpkg  -i ${packgeName}

haoranc's avatar
haoranc 已提交
112
elif [[ ${packgeName} =~ "rpm" ]];then
haoranc's avatar
haoranc 已提交
113
    cd ${installPath}
haoranc's avatar
haoranc 已提交
114
    echo "rpm ${packgeName}"  && rpm -ivh ${packgeName}  --quiet 
haoranc's avatar
haoranc 已提交
115
elif [[ ${packgeName} =~ "tar" ]];then
haoranc's avatar
haoranc 已提交
116 117 118 119
    cd  ${oriInstallPath}
    if [ ! -f  {originPackageName}  ];then
        sshpass -p ${password} scp 192.168.1.131:/nas/TDengine3/v${originversion}/community${originPackageName} .
    fi
haoranc's avatar
haoranc 已提交
120
    echo "tar -xvf ${originPackageName}" && tar -xvf ${originPackageName} 
haoranc's avatar
haoranc 已提交
121

haoranc's avatar
haoranc 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134
    cd ${installPath} 
    echo "tar -xvf ${packgeName}" && tar -xvf ${packgeName} 


    if [ ${testFile} != "tools" ] ;then
        cd ${installPath}/${tdPath} && tar vxf ${subFile}
        cd  ${oriInstallPath}/${originTdpPath}  && tar vxf ${subFile}
    fi

    echo "check installPackage File"

    cd ${installPath} 

haoranc's avatar
haoranc 已提交
135 136
    tree ${oriInstallPath}/${originTdpPath} >  ${oriInstallPath}/${originPackageName}_checkfile
    tree ${installPath}/${tdPath} > ${installPath}/${packgeName}_checkfile
haoranc's avatar
haoranc 已提交
137

haoranc's avatar
haoranc 已提交
138
    diff  ${installPath}/${packgeName}_checkfile ${oriInstallPath}/${originPackageName}_checkfile  > ${installPath}/diffFile.log
haoranc's avatar
haoranc 已提交
139 140 141 142 143 144 145 146 147 148 149 150 151
    diffNumbers=`cat ${installPath}/diffFile.log |wc -l `
    if [ ${diffNumbers} != 0 ];then
        echo "The number and names of files have changed from the previous installation package"
        echo `cat ${installPath}/diffFile.log`
        exit -1
    fi

    cd ${installPath}/${tdPath}
    if [ ${testFile} = "server" ];then
        bash ${installCmd}  -e no  
    else
        bash ${installCmd} 
    fi
haoranc's avatar
haoranc 已提交
152
    if [[ ${packgeName} =~ "Lite" ]] &&  [[ ${packgeName} =~ "tar" ]]  ;then
haoranc's avatar
haoranc 已提交
153
        cd ${installPath}
haoranc's avatar
haoranc 已提交
154 155
        sshpass -p ${password}   scp 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz .
        # wget https://www.taosdata.com/assets-download/3.0/taosTools-2.1.2-Linux-x64.tar.gz
haoranc's avatar
haoranc 已提交
156 157
        tar xvf taosTools-2.1.2-Linux-x64.tar.gz
        cd taosTools-2.1.2 && bash install-taostools.sh
haoranc's avatar
haoranc 已提交
158 159 160 161 162 163 164 165
    elif [[ ${packgeName} =~ "Lite" ]] &&  [[ ${packgeName} =~ "deb" ]] ;then
        cd ${installPath}
        sshpass -p ${password}   scp 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.deb .
        dpkg -i taosTools-2.1.2-Linux-x64.deb 
    elif [[ ${packgeName} =~ "Lite" ]] &&  [[ ${packgeName} =~ "rpm" ]]  ;then
        cd ${installPath}
        sshpass -p ${password}   scp 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.rpm .
        rpm -ivh taosTools-2.1.2-Linux-x64.rpm --quiet 
haoranc's avatar
haoranc 已提交
166
    fi
haoranc's avatar
haoranc 已提交
167

haoranc's avatar
haoranc 已提交
168
fi  
haoranc's avatar
haoranc 已提交
169