use $ENVFILE to reference ENVFILE
fixed script variable names

use ...DIR rather than ...PATH throughout
use error() rather than echo()