Fix up if statements in bash scripts and allow generate-json.sh to be used generically.