When using an external data volume, it's a better practice to check for a non-zero and existing config.php instead of the data directory itself:
if [[ ! -s "$APPLICATION_HOME/config.php" ]]; then
This way it's much more obvious when the configuration will be reset and why.