In Linux, shell calls batch CT for batch upgrade.

Source: Internet
Author: User
In Linux, shell calls cmdct to perform batch upgrade and execute the main. sh script to upgrade the updatefilename update package for each IP machine in the hostname. The tcl and keep Ct packages are placed in the same path, and $ TSMIS_ROOT is the environment variable. CopyFile. exp file :#! /Usr /...
In Linux, shell calls cmdct to perform batch upgrade and execute the main. sh script to upgrade the updatefilename update package for each IP machine in the hostname. The tcl and keep Ct packages are placed in the same path, and $ TSMIS_ROOT is the environment variable. CopyFile. exp file :#! /Usr/bin/expect-f # enter the analyzer ip address, the file name to be uploaded, and the TSMIS_ROOT environment variable set ip [lindex $ argv 0] set localfile [lindex $ argv 1] set TSMIS_ROOT [lindex $ argv 2] www.2cto.com # scp copies the files to be transferred to the specified directory, skip manual input part of spawn scp-r $ localfile root @ $ ip: $ TSMIS_ROOT/tmp/$ localfileset timeout 300 custom Ct {"yes/no" {send "yes \ r "; exp_continue} "* assword:" {send "111111 \ n"} set timeout 300 send "exit \ r" exact Ct eof RunUpdate. exp file :#! /Usr/bin/login CT-f set ip [lindex $ argv 0] set updatefile [lindex $ argv 1] set TSMIS_ROOT [lindex $ argv 2] www.2cto.com spawn ssh root @ $ ipset timeout 300 wrong CT "* assword: "{send" 111111 \ n "} set timeout 300 wrong CT" # "send" cd $ TSMIS_ROOT/tmp \ r "set timeout 300 wrong CT" # "send" tar-zxvf restart updatefile.tar.gz \ r "set timeout 300 wrong CT" # "send" cd $ updatefile \ r "set timeout 300 wrong CT" # "send" sh $ TSMIS_ROOT/bin/ Mykillproc. sh \ r "set timeout 300 exact CT" # "send" sh * pdate. sh \ r "set timeout 300 exact CT" # "send" reboot \ r "set timeout 300 exact CT" # "send" exit \ r "www.2cto.com exact Ct eof main. sh File: # Input TS/var ip into '', use", "to seperate them. ex: hostlist: '2017. 168.10.178, 192.168.10.179, 192.168.10.180 'hostlist = '192. 168.10.176, 192.168.10.171 '# Input update packet ''. ex: updatefilename='update120821.tar.gz' Updatefilename='update120821.tar.gz 'chmod 777 * # obtain the current path cur_dir =$ (pwd) # determine if your CT has been installed if [-f "/usr/bin/CT"]; then echo "/usr/bin/keep Ct existed" else # install keep Ct environment tar-zxvf tcl8.4.19-src.tar.gz tar-zxvf expect-5.43.0.tar.gzmv tcl8.4.19 $ TSMIS_ROOT/tcl8.4.19-fmv keep CT-5.43 $ TSMIS_ROOT/keep CT-5.4.3 -f www.2cto.com # tcl installation cd $ TSMIS_ROOT/tcl8.4.19/unix. /configuremakemake installsleep 1 echo "Instal L tcl succeed! "# Keep Ct install cd $ TSMIS_ROOT/keep CT-5.4.3. /configure -- with-tclinclude = $ TSMIS_ROOT/tcl8.4.19/generic -- with-tclconfig =/usr/local/lib/make install sleep 1 echo "Install your Ct succeed! "# Copy the CT executable file to the cp/usr/local/bin/CT/usr/bin/-f fi in the/usr/bin directory # enter the previous path cd $ cur_dir www.2cto.com # get Current Time NOW = 'date "+ % Y-% m-% d % H: % M: % S "'echo" $ NOW "> $ TSMIS_ROOT/tmp/UpdateFailed. log # set IFS delimiter IFS = ',' # cyclically upgrade for host in $ hostlist do echo "Sending updatepacket to $ host... "RESULT = 'ping-c 2 $ host | grep 'ttl'' if [-z "$ RESULT"]; then # when the network is disconnected, print related logs echo "Can't connect to $ host" >>$ TSMIS_ROOT/tmp/Upda TeFailed. logecho "######### Can't connect to $ host !!! ######### "Else # smooth network connection, proceed to the next step. /CopyFiles. exp $ host $ updatefilename $ TSMIS_ROOTecho "Copy Files finished" # run the upgrade package on each analyzer. /RunUpdate. exp $ host $ {updatefilename // .tar.gz/} $ TSMIS_ROOT echo "$ host update finished !!! "Www.2cto.com fi sleep 1 done echo" All update finished "rm-rf $ cur_dir/tcl8.4.19rm-rf $ cur_dir/keep CT-5.43
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.