Note that there are some explanatory texts on larger screens.

plurals
  1. POBash Script to Update Admin User Password for Multiple Drupal Sites on a Server spread over Multiple Versions
    primarykey
    data
    text
    <p>I have a server that runs quite a few Drupal sites. Some of these are older and running Drupal 5, while some are newer and running Drupal 6. We're also beginning to implement Drupal 7.</p> <p>Our organization uses one standard Website Administration password that we distribute internally only to our employees for maintenance of these websites. This may or may not be the best security practice, but it is how we do things at this time. Please assume that this won't change.</p> <p>The problem we have is that when we have employee turnover, we must change this password and apply the change to every site we run in order to make sure that the employee cannot deface any of our clients' sites. This is more critical for firings, but we also do it for resignations as a best practice.</p> <p>In the past, I ran a basic PHP script that used mysql_list_dbs on our Database server to iterate through every database and change the pass field of the users table where the name = admin. BasicallY:</p> <pre><code>while ($row = mysql_fetch_object(mysql_list_dbs($sql_connection))) { mysql_query("UPDATE users SET pass=MD5('$newpassword') WHERE name='admin'", $row-&gt;Database); } </code></pre> <p>This worked perfectly fine but it has two problems:</p> <ol> <li>It's hacky and I hate hacky stuff. I'd rather do things that make use of the "official way" of doing things</li> <li>Drupal 7 uses a different hashing system than D5 and D6 did, so this won't work for Drupal 7 sites. Now I have to check first that the existing value of pass matches the hash of the old password before updating so that I don't accidentally break a Drupal 7 site. In the meantime, I haven't yet figured out how to implement this for Drupal 7 sites.</li> </ol> <p>So I'm looking for an alternative solution. I really think that I need to use a bash script that either iterates through Virtual Hosts from httpd.conf or uses find or something and one way or another, cd's into every site install directory inside very installation platform's "sites" folder (we have a pretty messy setup*) and runs drush upwd admin --password=$newpassword</p> <p>This would be completely platform independent and would allow Drupal to define what happens when the password is changed.</p> <p>I realize that Aegir may actually be a good solution for this, but we're not ready to implement Aegir quite yet, and I'm looking for more of a quick and dirty intermediate solution. I appreciate any input you might have.</p> <p>*Just a sample of our messy setup:</p> <pre><code>/www /cliena /drupal-5.x /sites /clienta.com &lt;-- contains settings.php for Client A /clientb /drupal-5.x &lt;-- contains old code base for Drupal 5 site that's been migrated I shoudld probably have my drush/bash script ignore these sections.... /drupal-6.x &lt;-- contains code base for current Drupal 6 site /sites /clientb.com &lt;-- contains settings.php for Client B /clientc /drupal-6.x /sites /default &lt;-- contains settings.php for clientc.com /sub1.clientc.com &lt;-- contains settings.php for sub1.clientc.com /sub2.clientc.com &lt;-- contains settings.php for sub2.clientc.com /sub3.clientc.com &lt;-- contains settings.php for sub3.clientc.com /client_sites /drupal-5.x /sites /clientd.com &lt;-- contains settings.php for clientd.com /cliente.com &lt;-- contains settings.php for cliente.com /clientf.com &lt;-- contains settings.php for clientf.com </code></pre> <p>... and so forth... you get the picture. a Migration to Aegir is in order, but it'll take a while to clean this up.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload