Configure Modules from a Script I'm interested in created a sort of "deploy" script. I basically want it to take a fresh drupal install (plus my versioned work in sites/) and disable and enable modules as needed and then automatically configure the site.

The first part is easy with a simple script and drush. The second part is the part I'm not so sure of. I can manipulate the database directly (again, using drush) and run queries against it, but I wonder if that is a bad way to do it since the schema of modules can change when they are updated (though I think core will stay mostly the same in 7.x).

I'd like to be able to script things like the CSS/JS aggregation settings or the Facebook APP ID/Secret in fboauth. Is there any "safe" way to do this without worrying about module updates breaking the script?
Unfortunately, there is no "right" solution for Drupal 7; in Drupal 8, the configuration management initiative hopes to solve this problem.  There are a few things that you can look at to help you out.


Features: http://drupal.org/project/features:  Take database settings and write them to code, making a new module containing your settings.  Use "strongarm" module (http://drupal.org/project/strongarm) to be able to save items from the variables table in your features.  Once you have your features module, you can copy it to another site and run 'drush fr' to "revert" the feature (copy code back into the database).
Deploy: http://drupal.org/project/deploy: The counterpart of Features, it allows you to move content from one Drupal site to another.
drush generate-profile: http://drupal.org/node/1368242: Work in progress: given an existing site, creates a profile that will recreate that site.  Create your features first, then run generate-profile.  In its current state, it does a good job of creating your makefile and setting up the modules you need, but the template files that generate the profile code are not finished or working yet.  I am still working on this command, as time allows.