#!/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

APP_HOME="$GEAR_BASE_DIR/$uuid"


if only_cart_on_gear $cartridge_type; then
    rm -rf "/etc/httpd/conf.d/openshift/${uuid}_${namespace}_${application}.conf" "/etc/httpd/conf.d/openshift/${uuid}_${namespace}_${application}"
fi
