Your basic problem is that the chroot and su start up new processes, they don't affect the process that invokes them. The chroot creates a new process to run the su command in, and the su command ends up creating a new shell process. It's this new shell that has the changed root directory. When you exit that shell it resumes executing your script, which never had is root changed. The ./setup.py command is then executed in the wrong context.
The solution is to execute the commands in the process that su creates. Something like:
#!/bin/bash
/usr/sbin/chroot /opt/gluu-server-2.4.2/ su -l -c "
cd /install/community-edition-setup/;
./setup.py -n -u -a -s -f setup.properties"
This may not work if ./setup.py needs to interact with the user or otherwise needs a controlling terminal. In that case you may need something like:
#!/bin/bash
/usr/sbin/chroot /opt/gluu-server-2.4.2/ /bin/bash -l -c "
cd /install/community-edition-setup/;
./setup.py -n -u -a -s -f setup.properties"
In this case the script would already need to be running as root, but you normally need to be root invoke the chroot command anyways.