refactor install script

this splits up the install script in a few smaller parts that are fetched on the fly with curl.
for now, there should be no changes in what the script does, only how it is organized. I hope this makes the structure a little clearer and more maintainable/extendable.

I will take care of #4047 here, too (not yet).