removed bashisms and actually tested the process with protecteduser This script works so far (for me)