split generate.sh into two halves
hard code TMP as /tmp