bm检测打开关闭cdn

bm检测打开关闭cdn

cat test_cdn.sh 
#!/bin/bash
# Author : royoy
# Date   : 07/2019
# Desc   : check,open,close cdn for xxxtyt

salt_bin="/bin/salt"
xxxtyt_huidu="xxxtyt_huidu_10.5.66.3"
xxxtyt_node="rsync"
rsync_opt="xxxtyt-sync-cdn-config"
remote_script="/data/shell/test_cdn.sh"
cdn_opt="$1"

exec_module(){
        [ "x$1" = "xcheck_cdn" ] && {
                $salt_bin "$xxxtyt_huidu" cmd.run "$remote_script $1"
        } || {
                #$salt_bin "$xxxtyt_huidu" cmd.run "$remote_script $1" || exit 39
                $salt_bin -N "$xxxtyt_node" cmd.script salt://scripts/rsync.sh "$2" || exit 36
                if [ "x$3" != "x" ];then $salt_bin "$xxxtyt_huidu" cmd.run "$remote_script $3";fi
        }
}

manage_cdn(){
        [ "x$1" = "xcheck_cdn" ] && {
                exec_module "$1"
        } || {
                [ "x$1" = "xopen_cdn" ] && {
                        #exec_module "$1" "$rsync_opt" "close_cdn"
                        exec_module "$1" "$rsync_opt" ""
                } || {
                        [ "x$1" = "xclose_cdn" ] && exec_module "$1" "$rsync_opt" ""  || exit 6
                }
        }
}

# Interactive mode
while [[ $# -eq 0 ]]
do
        stty erase ^H
        font "Please input an option for CDN of xxxtyt: (c|check) ( o|open ) ( d|close ) ( q|e|quit|exit )" -n
        read OPTARG
        case $OPTARG in
                check|c)
                        manage_cdn "check_cdn"
                        ;;
                open|o)
                        manage_cdn "open_cdn"
                        ;;
                close|d)
                        manage_cdn "close_cdn"
                        ;;
                exit|quit|q|e)
                        exit
        esac
done

# Auto mode
[[ "check_cdn open_cdn close_cdn" =~ "$cdn_opt" ]] && manage_cdn "$cdn_opt"