script to rebuild agent