Q: How to install and uninstall a script sourced in all interactive shells via yum on Centos? I would like to package, install and uninstall a rpm which can add a contextual warning message at all interactive shells startup for all users (actually, at least both bash ssh session and bash gnome terminal). Basically, the code would display the warning message if a file is missing.
Well, the candidates are /etc/bashrc, /etc/profile, /etc/profile.d/myscript.sh, /etc/skel/.bash_profile, /etc/skel/.bashrc.
The easiest way would be to install something in /etc/profile.d but it doesn't really address my need (ssh bash session).
I think the right place is /etc/skel/.bashrc + exisiting .bashrc but I don't feel safe with appending/removing my code to/from these files... My understanding is that yum and rpm puts and remove files; they are not designed to safely modify text files.
I would like something like /etc/bashrc.d/ ...
Where should I safely install the warning message so it can be available in all  interactive shells and safely uninstalled? By safely, I mean without deleting anything unwanted. 

A: The file /etc/bashrc is marked as %config(noreplace) file in the setup rpm. This means that if you update it, yum will not replace it.  When upgrading a package, if there is an updated /etc/bashrc, yum will create /etc/bashrc.rpmnew.  So you can modify it safely if you wish.
But it appears that won't be necessary.  Take a look at /etc/bashrc on your centos/rhel/fedora/etc system, and you will find:
if ! shopt -q login_shell ; then # We're not a login shell
[...]
    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            if [ "$PS1" ]; then
                . "$i"
            else
                . "$i" >/dev/null
            fi
        fi
    done
[...]

That code ensures that the files in /etc/profile.d are run both for login shells (in which case they are run from /etc/profile instead) and for non-login shells (in which case this loop takes care of running them).
In other words, you already have an /etc/bashrc.d, and it's called /etc/profile.d.
