auto_generate.sh full code pasted