cat rsync_domainName_to_local.sh
#!/bin/bash
# Author : royoy
# Ver : v1
# Date : 10/2019
salt_bin=/bin/salt
cdn_node=front_web
cdn_conf=/data/shell/cdn_config/cdn_domainName.property
exec_script=scripts/examine_cdn_domainName.sh
local_domainName=`awk -F= '/^domainName/{print $2;exit}' $cdn_conf`
cdn_domainName=`$salt_bin -N "$cdn_node" cmd.script salt://${exec_script} |sed -n '/stdout:/{n;p}' |sort -u |tr -d ' '`
if [ `echo $cdn_domainName | sed 's/\s/\n/g' |wc -l` -ne 1 ];then
font -f 10 \= -red "当前节点组机器存在不同的域名,信息如下:" -r -f 10 \= -n
$salt_bin -N "$cdn_node" cmd.script salt://${exec_script} |sed -n '/xxxtyt/{h;:z;n;/stdout/!bz;{n;H;g;s/\n//;p}}' |sort -t: -k2 |while read host domain_name
do
if [ "x$local_domainName" != "x$domain_name" ];then
font -cyan -srw 30 "$host" -r -yel -t -slw 20 "$domain_name" -r -n
else
font -srw 30 "$host" -t -slw 20 "$domain_name" -n
fi
done
exit 21
else
sed -i 's/\(^domainName.*=\).*/\1'$cdn_domainName'/gi' $cdn_conf
fi