University of Oregon

Bash – Add drupal site name to PS1

I updated my bash prompt (PS1) the other day. Now it displays what site I’m in.
I recently posted my former change: An improved PS1 for Git in Bash.
Now I added an extra bit of code that inserts the current ‘site’.
It looks like this:

vid@server:( currentdir (origin [master])$ 


Reset a password on a Parallels VM

I forgot the password to a RedHat 6 Parallels VM recently.

It’s a VM that we use to test changes to Aegir prior to working on the live hub.

Max Bronsema created and shared this VM a few years ago.
Unfortunately for me, I changed the original password at some point and now I’m locked out. But not to fret; the good news comes in the form of parallels control commands:

$ prlctl set ... --userpasswd ...

Here were my steps to reset the two user passwords (Note: names and ID’s have been changed to protect the some-such or another); Ref:

  • Open the Red Hat Enterprise Linux 6 (1) VM
  • Open Terminal
  • Reset the password for Admin and then AegirUser
    # prlctl = parallels control
    # list all running vm’s
    $ prlctl list –all | grep running
  • You may see something like this:
    {3e21f02b-9d52-4ebe-a079-675dc822d723} running - Red Hat Enterprise Linux 6 (1)
  • Use that machine ID to reset the passwords for your user accounts:
    $ prlctl set INSERT_MACHINE_ID –userpasswd Admin:tempPassWord
    authentication tokens updated successfully.
    $ prlctl set INSERT_MACHINE_ID –userpasswd AegirUser:tempPassWord
    authentication tokens updated successfully.
  • Then login as each user and reset their password

That’s a handy tool. Thanks Parallels!

Un-track files in git

Recently I realized I wanted to un-track a few files in one of my git repositories for a drupal 6 site. These were files that weren’t portable between the prod, staging and dev servers.
One example would be the drushrc file. Aegir creates this file and it contains info specific to the server the site is on.
So I went looking for a way to un-track but keep the file.
I learned from experience that ‘git rm’ (the remove command) is not quite right, but if you add ‘–cached’ to the command you’re all set.

So, if you have a file being tracked by git and you want to get rid of it you can use this command

git rm --cached file/name


In addition, you should add the file to your .gitignore document.

Now when you run,

git status


git commit

the offending file wont be included.


Aegir: Adding external databases / injecting data in the settings.php file

I’ve been using Aegir a lot lately and it’s nice to find built-in work-arounds when you need one.
I needed to add an external database to my drupal site. As it turns out you can create a local.settings.php file in your site folder, and extend your settings.php file. See Injecting into settings.php for a full description.

Aegir manages the settings.php file. So any changes you make there will be overwritten. But we have control over the local.settings.php file.
As an example, I needed to include an external database that I incorporate into my site via TableWizard. To achieve that I created this local.settings.php file:

[code:php] ‘mysqli’,
‘database’ => ‘hr_ee_forms’,
‘username’ => ‘hr_reader’,
‘password’ => ‘******’,
‘host’ => ‘hrpub’,
‘port’ => ‘3306’,
$db_url[‘uo_ee_forms’] = $databases[‘uo_ee_forms’][‘default’][‘driver’] . ‘://’ . $databases[‘uo_ee_forms’][‘default’][‘username’] . ‘:’ . $databases[‘uo_ee_forms’][‘default’][‘password’] . ‘@’ . $databases[‘uo_ee_forms’][‘default’][‘host’] . ‘:’ . $databases[‘uo_ee_forms’][‘default’][‘port’] . ‘/’. $databases[‘uo_ee_forms’][‘default’][‘database’];

$db_prefix = array(
‘default’ => ”,
‘org_level’ => ”,/*org_chart*/
‘uo_oa’ => ”/*uo_ee_forms*/

The above code adds an external DB that TableWizard can read, providing access to the data via views.

Note that I had to ‘hard code’ the values. We can’t take advantage of the stored $_server vars that Aegir keeps in the vhost file. For ex:

$databases[‘default’][‘default’] = array(
‘driver’ => $_SERVER[‘db_type’],
‘database’ => $_SERVER[‘db_name’],
‘username’ => $_SERVER[‘db_user’],
‘password’ => $_SERVER[‘db_passwd’],
‘host’ => $_SERVER[‘db_host’],
‘port’ => $_SERVER[‘db_port’],

Those are available in the settings.php file but unset before the our local.settings.php file is run.

There’s also an option for a file that can apply settings to all your sites.