#!/bin/bash

if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
    set -x
fi
set -eu
set -o pipefail

for i in cloudera-scm-agent \
cloudera-scm-server \
cloudera-scm-server-db \
hadoop-hdfs-datanode \
hadoop-hdfs-namenode \
hadoop-hdfs-secondarynamenode \
hadoop-mapreduce-historyserver \
hadoop-yarn-nodemanager \
hadoop-yarn-resourcemanager \
hive-metastore \
hive-server2 \
hive-webhcat-server \
hue \
oozie \
postgresql
do
    if [ "$DISTRO_NAME" = "ubuntu" ]; then
        update-rc.d -f $i remove
    else
        chkconfig $i off
    fi
done

if [ $DIB_CDH_VERSION != "5.0" ]; then
    for i in impala-catalog \
        impala-server \
        impala-state-store \
        solr-server \
        spark-history-server
    do
        if [ "$DISTRO_NAME" = "ubuntu" ]; then
            update-rc.d -f $i remove
        else
            chkconfig $i off
        fi
    done
fi
