#! /bin/bash

# Usage:
#   cfk-stop <service>
#
#   Stops and removes the container for a cfk service.
#   Note that if the service is monitored with upstart,
#   it will likely be restarted (upstart monitoring can
#   be dsiabled with `stop <service>`)

CONTAINER=$1

eval $(cfk-env)

# Load any service-specific environment
if [ -f /etc/default/$CONTAINER ]; then
  eval $(cat /etc/default/$CONTAINER | sed 's/^/export /')
fi

# Clean up the instance
cd /usr/src/cfk
docker-compose stop $CONTAINER
docker-compose rm -f $CONTAINER

