Refactor .travis/install.sh.

Fixes #1439.

Probably a few more bits that can be refactored but it's a start.
The new indent level here looks wrong.