First, if you try to add files, please attach it instead of posting. User edit after you post your text. It makes our job easier.
I apply the changes to a new jboss-init_redhat.sh and attach it, hope that help. You might diff it to yours (I hoe I have the same 5.1.0 version as you)