#!/bin/sh
#
# --- BEGIN COPYRIGHT BLOCK ---
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2012 Red Hat, Inc.
# All rights reserved.
# --- END COPYRIGHT BLOCK ---
#

PROG_NAME=`basename $0`
SERVICE_NAME="pkidaemon"
SERVICE_PROG="/bin/systemctl"

command="$1"
pki_instance_type="tomcat"
pki_instance_id="$2"

PKI_REGISTRY="/etc/sysconfig/pki/${pki_instance_type}"
PKI_TYPE="${pki_instance_type}"

# Source the PKI function library
. /usr/share/pki/scripts/operations

print_usage()
{
    echo
    usage
    echo "where valid instance names include:"
    list_instances
    exit ${default_error}
}

# See how we were called.
case $command in
    status)
        registry_status
        exit $?
        ;;
    start)
        start
        exit $?
        ;;
    stop)
        if $debian; then
            stop
        else
            echo "invalid action ($command)"
            print_usage
        fi
        ;;
    restart)
        if $debian; then
            restart
        else
            echo "invalid action ($command)"
            print_usage
        fi
        ;;
    *)
        echo "unknown action ($command)"
        echo
        usage
        echo "where valid instance names include:"
        list_instances
        exit ${default_error}
        ;;
esac

