cdn域名检测与同步

cdn域名检测与同步

[root@ansible-server-xxxtyt cdn_config]# cat rsync_cdn_domainName.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
current_domainName=`awk -F= '/^domainName/{print $2}' $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 "当前节点组机器存在不同的域名,信息如下:" -reset -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 [ "$current_domainName" != "$domain_name" ];then
                        printf "\033[36m%-30s\033[0m\033[35m%-20s\033[0m\n" $host $domain_name
                else
                        printf "%-30s%-20s\n" $host $domain_name
                fi
        done
        exit 21
else
        sed -i 's/\(^domainName.*=\).*/\1'$cdn_domainName'/gi' $cdn_conf
fi

[root@ansible-server-xxxtyt cdn_config]# cat cdn_domainName.property 
##Don't delete the file
domainName=img.longgaoyun.com