add exit code index and print errors to stderr
update bash syntax when setting variable defaults
use mktemp for creating logfile
remove reference to outdated config variable to would prevent CREATE_DATABASE working
avoid subshell to find hostname
stop using variables for common binaries
use set -e and set -u
do not treat unbound variables as errors
fix indenting