#!/bin/sh

case "$1" in
    remove)
        # Restore default shell for accounts, if needed
        getent passwd | grep -q "^root:.*:/bin/bash" && \
            ( chsh -s /bin/sh root || exit 1 )
        getent passwd | grep -q "^user:.*:/bin/bash" && \
            ( chsh -s /bin/sh user || exit 1 )

        # Remove /bin/bash from /etc/shells
        if grep -q "/bin/bash" /etc/shells 2>/dev/null; then
            tmpf=`mktemp "/tmp/__bash3.XXXXXX"`
            grep -v "/bin/bash" /etc/shells >$tmpf && \
                mv -f $tmpf /etc/shells
            rm -f $tmpf
        fi

        # Check if existing profile is patched
        if grep -q "<bash>" /etc/profile; then
            sed -e '/<bash>/,/<\/bash>/d' /etc/profile >/tmp/__maemo_bash__ && \
            mv -f /tmp/__maemo_bash__ /etc/profile
        fi
        ;;
esac

#DEBHELPER#
