#! /bin/bash
#
# Copyright (c) 2020, AT&T Intellectual Property.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-only

source "$(cd "$(dirname "${0}")" && pwd -P)"/../tech-support.functions

LOG_DIR="/var/log/sssd"

header SSSD

if systemctl -q is-active sssd; then
    if which sssctl > /dev/null; then
        time_out "sssctl domain-list"
    fi
else
    echo "SSSD is not running"
fi

do_cmd journalctl --no-pager -u sssd -n 250

if [ -d "$LOG_DIR" ]; then
    for file in $(IFS=$'\n'; ls -1 "$LOG_DIR"); do
        [[ "$file" != *.log ]] && continue
        [[ "$file" == *tacplus* ]] && continue
        [ -s "$LOG_DIR/$file" ] || continue
        do_cmd tail -n 250 "$LOG_DIR/$file"
    done
fi
