fix a few typos and portability problems with init scripts

this is related to issue #1815