more robust shell code for install/clean-install