Move core setup code to controller class

Just moving code.

And a small fix in isHtaccessWorking function to prevent endless recursion when installing.

@icewind1991 @karlitschek @butonic @bantu @DeepDiver1975