#!/bin/sh
# RPM post-install hook for lshell

set -eu

# Ensure service group and log directory exist.
if ! getent group lshell >/dev/null 2>&1; then
    groupadd -r lshell
fi

mkdir -p /var/log/lshell
chown root:lshell /var/log/lshell
chmod 0770 /var/log/lshell

# On fresh install, add lshell to /etc/shells if needed.
if [ "${1:-0}" = "1" ] && [ -f /etc/shells ]; then
    if ! grep -q '^/usr/bin/lshell$' /etc/shells; then
        printf '%s\n' '/usr/bin/lshell' >> /etc/shells
    fi
fi

exit 0
