Refactored server wait into bash script