Make a much better server.sh. Everything is broken out into functions and there's a wrapping control flow for the commands and arguments.