#!/bin/bash

# Removes the batch processing service (cron) support from the application.

function print_help {
    echo "Usage: $0 app-name namespace uuid"

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

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


[ $# -eq 3 ] || print_help

cartridge_type="cron-1.4"
source "/etc/openshift/node.conf"
source ${CARTRIDGE_BASE_PATH}/abstract/info/lib/util

setup_embedded_deconfigure "$1" $2 $3
import_env_vars

if [ -d $OPENSHIFT_HOMEDIR/$cartridge_type ]; then
  disable_cgroups

  super_run_as_user "$CARTRIDGE_BASE_PATH/$cartridge_type/info/bin/app_ctl.sh disable"
  runcon -l s0-s0:c0.c1023 rm -rf "$OPENSHIFT_HOMEDIR/$cartridge_type"

  enable_cgroups
fi

