4 Marines and gunman die in attack on two military sites