The $HOMEDIR is populated prior in the script. I think you can use there the real path of your database home dir.