Add retries to install scripts

This'll retry install script three times before actually failing. Useful
if there are network timeouts or similar issues (see #1089 and #1077).