#!/bin/bash

# Remove httpd proxy

# Exit on any errors
set -e

source "/etc/openshift/node.conf"
source ${CARTRIDGE_BASE_PATH}/abstract/info/lib/util

function print_help {
    echo "Usage: $0 app-name namespace uuid"
    echo "Remove httpd proxy for an application"

    echo "$0 $@" | logger -p local0.notice -t openshift_origin_remove_httpd_proxy
    exit 1
}

while getopts 'd' OPTION
do
    case $OPTION in
        d) set -x
        ;;
        ?) print_help
        ;;
    esac
done

[ $# -eq 3 ] || print_help

namespace=`basename $2`
application="$1"
uuid=$3

oo-frontend-disconnect \
    --with-container-uuid "$uuid" \
    --with-container-name "$application" \
    --with-namespace "$namespace" \
    --path ""
