2.how-to-upgrade-obproxy-to-obproxy-ce-3.2.3.md 2.5 KB
Newer Older
F
v1.6.0  
frf12 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
# How do I upgrade an OBProxy to obproxy-ce 3.2.3?

The open source OBProxy component is formally renamed as obproxy-ce. Therefore, the error `No such package obproxy-3.2.3` will be reported if you run the following command for an upgrade:

```shell
obd cluster upgrade <deploy name> -c obproxy -V 3.2.3
```

You need to run the following **script** as the execution user of OBD to modify the metadata, and then run the following command to upgrade the OBProxy:

```shell
obd cluster upgrade <deploy name> -c obproxy-ce -V 3.2.3
```

## script

```bash
OBD_HOME=${OBD_HOME:-${HOME}}/.obd
obproxy_repository=${OBD_HOME}/repository/obproxy
obproxy_ce_repository=${OBD_HOME}/repository/obproxy-ce

function shadow_repo() {
    repository_path=$1
    ce_repository_path=$2
    [[ $repository_path =~ ^/  ]] && a=$repository_path || a=`pwd`/$repository_path
    while [ -h $a ]
    do
        b=`ls -ld $a|awk '{print $NF}'`
        c=`ls -ld $a|awk '{print $(NF-2)}'`
        [[ $real_patn =~ ^/ ]] && a=$b  || a=`dirname $c`/$b
    done
    instance_hash=`basename $a`
    ce_version_path=`dirname ${ce_repository_path}`
    ln -sf ${ce_version_path}/${instance_hash} ${ce_repository_path}
}

function copy_repository() {
    VS=(`ls $obproxy_repository`)
    for version in ${VS[@]}; do
        version_path="${obproxy_repository}/${version}"
        ce_version_path="${obproxy_ce_repository}/${version}"
        repositories=(`ls $version_path`)
        mkdir -p $ce_version_path
        for repository in ${repositories[@]}; do
            repository_path="${version_path}/${repository}"
            ce_repository_path="${ce_version_path}/${repository}"
            if [ -d "$ce_repository_path" ]; 
            then
                echo "${ce_repository_path} exist"
            else
                if [ -L ${repository_path} ];
                then 
                    shadow_repo ${repository_path} ${ce_repository_path}
                else
                    cp -r ${repository_path} ${ce_repository_path}
                fi
            fi
        done
    done
}

function change_cluster_meta() {
    cluster_home_path=${OBD_HOME}/cluster
    CS=(`ls ${cluster_home_path}`)
    for cluster in ${CS[@]}; do
        cluster_path=${cluster_home_path}/$cluster
        if [ -f ${cluster_path}/.data ]; then
            sed -i 's/^  obproxy:/  obproxy-ce:/g' ${cluster_path}/.data
        fi
        sed -i 's/^obproxy:/obproxy-ce:/' ${cluster_path}/*.yaml
    done
}

copy_repository && change_cluster_meta && echo 'ok'
```