Move the upgrade logic to \OC\Updater

This cleans up the ajax file and makes it easy to perform the upgrade from somewhere else (i.e. a cli script)

for #3617 

cc @karlitschek @MTGap @DeepDiver1975