Port to POSIX shell

So that it can be used on systems without bash / where bash is not used
for startup because of speed.