diff --git a/install.provision.inc b/install.provision.inc
index dd0eb1f..d951021 100644
--- a/install.provision.inc
+++ b/install.provision.inc
@@ -72,7 +72,7 @@ function drush_civicrm_post_provision_install($url = null) {
     if (function_exists("drush_user_create")) {
       $url = drush_get_option('uri', false);
   
-      $civicron_cronpassword = md5(uniqid(rand(), true));
+      $civicron_password = md5(uniqid(rand(), true));
   
       drush_set_option('mail', 'civicrm-no-reply@' . $url);
       drush_set_option('password', $civicron_password);
@@ -81,22 +81,42 @@ function drush_civicrm_post_provision_install($url = null) {
       drush_set_option('civicrm_cron_username', 'civicron', 'site');
       drush_set_option('civicrm_cron_password', $civicron_password, 'site');
   
+      // enable civicrm module before setting up civicron role,
+      //  as we need it to expose its permissions
+      drush_pm_enable('civicrm');
+
       // Create civicron role
-      db_query("INSERT INTO {role} (name) VALUES ('%s')", 'civicron');
+      if (function_exists('user_role_save')) {
+        // D7
+        $civicron_role = new stdClass;
+        $civicron_role->name = 'civicron';
+        user_role_save($civicron_role);
+      }
+      else {
+        db_query("INSERT INTO {role} (name) VALUES ('%s')", array('civicron'));
+      }
   
       drush_user_add_role('civicron', 'civicron');
   
       // Assign permissions to civicron role
-      db_query("INSERT INTO {permission} (rid, perm)
-                VALUES (3, 'access CiviCRM, access CiviContribute, access CiviEvent, access CiviMail, access CiviMail subscribe/unsubscribe pages, access CiviMember, access CiviPledge, access CiviReport, access Contact Dashboard, access Report Criteria, access all custom data, add contacts, edit all contacts, edit all events, edit contributions, edit event participants, view all activities, view all contacts, view all notes')");
+      $all_roles = user_roles(); // effectively same for D6/7
+      $civicron_rid = array_search('civicron', $all_roles);
+      if (function_exists('user_role_grant_permissions')) {
+        // D7
+        $all_perms = user_permission_get_modules();
+        $civi_perms = array_keys($all_perms, 'civicrm'); // todo: this is just the main civicrm module
+        user_role_grant_permissions($civicron_rid, $civi_perms);
+      }
+      else {
+        $civicrm_permissions = 'access CiviCRM, access CiviContribute, access CiviEvent, access CiviMail, access CiviMail subscribe/unsubscribe pages, access CiviMember, access CiviPledge, access CiviReport, access Contact Dashboard, access Report Criteria, access all custom data, add contacts, edit all contacts, edit all events, edit contributions, edit event participants, view all activities, view all contacts, view all notes';
+        db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", array($civicron_rid, $civicrm_permissions));
+      }
     } else {
       drush_log(dt("Not running drush 4.x or above, so cannot create civicron user and role. If you want to run the CiviCRM crons using drush, you will have to create them manually. Once you have done so, you can edit the site's sites/example.org/drushrc.php and set the correct username and password for the cron."));
       drush_set_option('civicrm_cron_username', 'civicron', 'site');
       drush_set_option('civicrm_cron_password', NULL, 'site');
     }
 
-    drush_pm_enable('civicrm');
-
     // Fix some paths (which, after enabling the module, seem broken..?)
     $uri = drush_get_option('uri', false);
     $base_url = 'http://' . d()->uri;
@@ -107,8 +127,14 @@ function drush_civicrm_post_provision_install($url = null) {
     );
 
     foreach ($paths as $key => $val) {
-      db_query("UPDATE {civicrm_option_value} set value = '%s' where name = '%s'", $val, $key);
+      switch (drush_drupal_major_version()) {
+        case 6:
+          db_query("UPDATE {civicrm_option_value} set value = '%s' where name = '%s'", array($val, $key));
+        break;
+        case 7:
+          db_query("UPDATE {civicrm_option_value} set value = :val where name = :key", array(':val' => $val, ':key' => $key));
+        break;
+      }
     }
   }
 }
-
diff --git a/verify.provision.inc b/verify.provision.inc
index dff9cd3..9387ed2 100644
--- a/verify.provision.inc
+++ b/verify.provision.inc
@@ -23,9 +23,9 @@ function drush_civicrm_provision_verify($url = null) {
  * in the civicrm_domain table
  */
 function drush_civicrm_pre_provision_verify($url = NULL) {
-  $packages = drush_get_option('packages', 'platform');
+  $packages = drush_get_option('packages', array(), 'platform');
 
-  if (!array_key_exists('civicrm', $packages['modules'])) {
+  if (empty($packages) || !array_key_exists('civicrm', $packages['modules'])) {
     return;
   }
 
@@ -41,9 +41,9 @@ function drush_civicrm_pre_provision_verify($url = NULL) {
  */
 function drush_civicrm_post_provision_verify($url = NULL) {
   if (d()->type == 'site') {
-    $packages = drush_get_option('packages', 'platform');
+    $packages = drush_get_option('packages', array(), 'platform');
 
-    if (!array_key_exists('civicrm', $packages['modules'])) {
+    if (empty($packages) || !array_key_exists('civicrm', $packages['modules'])) {
       drush_log(dt("CiviCRM not installed?"));
       return;
     }
