it should work like this: you call the emulator before the sync command in the script. Then after the emulator exits, the script should go on and process the next lines which should then sync. I believe this should do... I am not an expert on bash scripting but I believe they work similar to .bat scripts in dos except more advanced...
EDIT: Btw: You do not need the first line of your script as it should be a comment which is indicated by the #... this only tells the system to use the standard shell (the /bin/sh one) and I think it is not needed to succeed, only for the completeness of the code.