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

# The following variables are referenced in the sourced script
# /usr/share/pki/scripts/operations, to the error is invalid

# shellcheck disable=SC2034
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}"
PKI_SYSTEMD_TARGET="pki-${pki_instance_type}d"

# 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)
        (>&2 echo "WARNING: pkidaemon status has been deprecated. Use pki-server status instead.")
        registry_status
        exit $?
        ;;
    start)
        start
        exit $?
        ;;
    stop)
        echo "invalid action ($command)"
        print_usage
        ;;
    restart)
        echo "invalid action ($command)"
        print_usage
        ;;
    *)
        echo "unknown action ($command)"
        echo
        usage
        echo "where valid instance names include:"
        list_instances
        exit ${default_error}
        ;;
esac

