OGG运维优化脚本(十二)-信息同步类--信息上传
文件: upload.sh
创新互联建站专注于山阳企业网站建设,成都响应式网站建设公司,商城网站开发。山阳网站建设公司,为山阳等地区提供建站服务。全流程按需设计,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务
路径:$HOME/ggscript/ggupload
功能:该脚本不会直接使用,为满足其他脚本进行信息上传而设计,在脚本内直接调用上传相应的文件信息
他会读取系统信息配置文件sysinfo内的系统配置信息
范例
[detest#]
Ip-MTMyLjEyMS4xMDEuODYK
UserName-Z2dzCg==
PassWord-Z2dzxxxxxx
Port-MjIK
path-L2RhdGExL2dncy9nZ3NlcnZlci9kaXJkZWYK
[#detest]
以上信息以base64进行加密,保证信息安全,获取IP 用户名,密码,以及端口路径
并将相应的文件下发至对应的机器
#!/bin/bash if [ $# -eq 0 ]; then echo "info host file checkf" exit 2 fi if [ $# -eq 1 ]; then echo "info host file checkf" exit 2 fi if [ $# -eq 1 ]; then echo "info host file checkf" exit 2 fi host=$1 file=$2 checkf=$3 cd $HOME/ggscript/ggupload #sed '/"$host"/,/5/p' $checkf > infotmp cat $HOME/ggscript/ggupload/$checkf | awk '/'$host'#/,/#'$host'/{if(i>1)print x;x=$0;i++}' > $HOME/ggscript/ggupload/infotmp ip=`cat $HOME/ggscript/ggupload/infotmp|grep -w "Ip"|cut -d "-" -f 2` pw=`cat $HOME/ggscript/ggupload/infotmp|grep -w "PassWord"|cut -d "-" -f 2` port=`cat $HOME/ggscript/ggupload/infotmp|grep -w "Port"|cut -d "-" -f 2` us=`cat $HOME/ggscript/ggupload/infotmp|grep -w "UserName"|cut -d "-" -f 2` path=`cat $HOME/ggscript/ggupload/infotmp|grep -w "path"|cut -d "-" -f 2` echo "code" echo "ip=$ip" echo "pw=$pw" echo "port=$port" echo "user= $us" echo "path=$path" echo $ip > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out ip=`cat out` echo $pw > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out pw=`cat out` echo $port > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out port=`cat out` echo $us > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out us=`cat out` echo $path > tmp perl -MMIME::Base64 -ne 'print decode_base64($_)' < tmp > out path=`cat out` #echo "decode" #echo "ip=$ip" #echo "pw=$pw" #echo "port=$port" #echo "user=$us" #echo "path=$path" while [ ${#port} -le 1 ] do port=22 done #echo $ip $pw $port $path expect -c " spawn scp -r -P $port $file $us@$ip:$path expect { \"*assword\" {set timeout 300; send \"$pw\r\";} \"yes/no\" {send \"yes\r\"; exp_continue;} } expect eof"
分享名称:OGG运维优化脚本(十二)-信息同步类--信息上传
当前地址:http://myzitong.com/article/jsegje.html