This is script stuff. To give you a simple idea what happens try this.
cd to a tmp dir, "mkdir 123", "cd 123". Now "rm -rf ../123" and try to execute a script a few dirs up: "sh /usr/local/sbin/ipsec --version".
You'll see the familiar shell-init/getcwd error.
Do you have a mangled IPSEC_DIR var or did you edit the scripts?
If you want to TS this you could start ipsec scripts as "sh -x <script>" instead of "sh <script>" and redirect output to a logfile.
Grep for the error message and you've got an idea what happens or where to look.