[BZ 1148186] More updates for the initial commit:
1) Only assign the pwd to RHQ_AGENT_HOME not already defined
2) Use a temp variable to extract pwd before dirname