proto-shell: move all proto init code to a separate function