cloud foundry 中 url map/unmap

cloud foundry 中遇到url较多的应用进程,真是令人头疼的一件事,只能抽时间写个自动map和unmap的小脚本。

#!/bin/bash
# ********* USEAGE *************

# Time:2017/5/17
# version:V 1.0.0
# auth: songfucai
# content:user to map or unmap app's url
# note:
#     1.only suitable for china zuul
# *****************************

####map-route function
function mapRoute()
{
echo -n "Please type in the name of the application need to map-route....."
read mapapp
if [[ $mapapp == "exit" ]];then
    exit 1
fi
if read -t 30 -p "Whether to confirm to map-route ${mapapp} ?[y|n]:" yn
then
    if [[ $yn == [Yy] ]];then
         cf  map-route  $mapapp     domain  -n  host
         cf a|grep appname
    elif [[ $yn == [Nn] ]];then
            exit 0
    elif [[ $yn == "exit" ]];then
        exit 1
    else [[ $yn != [YyNn] ]]
        unmapRoute;
 
    fi
else
    echo " "
    echo -e "e[0;33;1mTimeOut ...e[0m"
    exit 1
fi 
}

####unmap-route function
function unmapRoute()
{
echo -n "Please type in the name of the application need to unmap-route....."
read unmapapp
if [[ $unmapapp == "exit" ]];then
    exit 1
fi
if read -t 30 -p "Whether to confirm to unmap-route ${unmapapp} ?[y|n]:" yn
then
    if [[ $yn == [Yy] ]];then
        cf  unmap-route  $unmapapp   domain  -n  host
        cf a|grep appname

    elif [[ $yn == [Nn] ]];then
        exit 0
    elif [[ $yn == "exit" ]];then
        exit 1
    else [[ $yn != [YyNn] ]]
        mapRoute;
    fi
else
    echo " "
    echo -e "e[0;33;1mTimeOut ...e[0m"
    exit 1
fi     
}

echo "only suitable for china zone appname....."
mapRoute;
unmapRoute;
原文地址:https://www.cnblogs.com/husbandmen/p/7054963.html