Building a cluster: shocks, cavities, and cooling filaments in the group–group merger NGC 6338