#!/bin/sh

case "$1" in
    configure|abort-deconfigure|abort-remove)
        # Check if existing profile is not already patched
        if ! grep -q "<bash>" /etc/profile; then
            echo '# <bash>

# Source all scripts in /etc/profile.d/
for i in /etc/profile.d/*.sh; do
    [ -r $i ] && source $i
done
unset i

# </bash>' >>/etc/profile
        fi
        ;;
    upgrade)
        ;;
esac

if [ "$1" == "configure" ]; then
    if [ -z "$2" ]; then
        if ! grep -q /bin/bash /etc/shells 2>/dev/null; then
            echo "/bin/bash" >> /etc/shells
        fi

        tmpf="/tmp/__bash__.txt"
        cat >$tmpf <<EOF
Now you can run it as /bin/bash, but if you want to make it your
default shell, please run the 'bash-setup' command from a terminal
window. This will perform a few additional steps in order to launch
bash automatically when you open a new terminal window.

You must run bash-setup for every user account you use (e.g. if you're
using the root account, you will have to run bash-setup as root too).
EOF
        maemo-confirm-text 'Thank you for installing bash!' $tmpf
        rm -f $tmpf
    fi
fi

#DEBHELPER#
