2、dm自动配置ip转换

#!/bin/bash

case $1 in
xiaomi)
        echo "=======================小米端 wifi 接入===================="
        sbc_address_port=5061;
        ;;
xiaoyuan)
        echo "===================小源 app 端 接入==================="
        sbc_address_port=5260;
        ;;
*)
        echo " please input xiaomi or xiaoyuan";
        exit 1;
        ;;
esac

docker cp urcs-as-dm:/home/urcs-as-dm/application-user-config.yml ./

arr=(`egrep -o "[0-9.]+\.[0-9.]+\.[0-9.]+\.[0-9.]+\:[0-9]{4,5}" application-user-config.yml`)

echo pblic-ip:${PUBLIC_IP}

for element in ${arr[*]}
do

        al_arr=(`echo $element | tr ':' ' '`)

        if [ "${al_arr[1]}" == "5260" -o "${al_arr[1]}" == "5061" ]; then
                sed -i s/$element/${PUBLIC_IP}:${sbc_address_port}/g application-user-config.yml
                echo "$element/${PUBLIC_IP}:${sbc_address_port}"
        fi

        if [ "${al_arr[1]}" == "8086" -o "${al_arr[1]}" == "8088" ]; then
                sed -i s/$element/${PUBLIC_IP}:${al_arr[1]}/g application-user-config.yml
                echo "$element/${PUBLIC_IP}:${al_arr[1]}"
        fi
done
docker cp application-user-config.yml urcs-as-dm:/home/urcs-as-dm/application-user-config.yml

 

你可能感兴趣的:(shell)