Slightly modified add_index script from gitlabhq fork