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

set -eu

# Only run cleanup on erase (0), not upgrade.
if [ "${1:-1}" != "0" ]; then
    exit 0
fi

if [ -f /etc/shells ]; then
    tmpfile=/etc/shells.lshell.$$
    grep -v '^/usr/bin/lshell$' /etc/shells > "${tmpfile}" || true
    cat "${tmpfile}" > /etc/shells
    rm -f "${tmpfile}"
fi

rm -f /etc/lshell.conf-rpm

exit 0
