davea's blog

Script to clean puppet dashboard

#!/bin/bash

# this script does cleanup on puppet dashboard
# - removes old entries
# - optimizes the database
# - clears the logs

dash=/usr/share/puppet-dashboard

renv="RAILS_ENV=production"

cd ${dash}

# prune the database of entries older than 15 days
`which rake` ${renv} reports:prune upto=15 unit=day

# optimize the database
`which rake` ${renv} db:raw:optimize

# clear the logs
`which rake` ${renv} log:clear

find /var/lib/puppet/reports/ -type f -mtime +45 -atime +45 -print0 | xargs -0 rm

Submitted by davea on Tue, 2013-08-06 15:23.

rpmbuild and command-line defines

I recently updated Bacula to the latest version and this required building the RPM. Now when I built this rpm before, I remember that it required some command-line arguments to determine what database and architecture to build for. After spending some time (the first time) looking for these, I just gave up and hacked the spec file to get it to build. Of course, about a week later, I stumbled across something on the net that explained what I needed to do.

Months pass...

Submitted by davea on Sun, 2009-08-30 08:59.

Using Views (version 1) in Drupal to get to data

Lately, I have been involved with several projects that required some custom PHP coding. Anyone that has worked with Drupal for length of time knows about the awesome Views Module. It is the query builder for Drupal, all through the web GUI. Views 2 is even better but this blog deals with Views 1. The Views Module allows the embedding of view output into any page by the following code:
$view = views_build_view('embed', views_get_view('view_name'), array ($sArgument), 0, NULL, 0, 0, NULL);
This will return HTML that you can put anywhere.
Submitted by davea on Tue, 2009-02-10 23:07. categories [ ]

Theming Drupal ecommerce

Well, I had a breakthrough today with ecommmerce.

Theming ecommerce has always been hard. Ecommerce checkout is basically a bunch of forms that are merged together in a non-drupal way. It has to do with the custom apis that come with ecommerce.

For example, in the cart module, to show the review form, the module searches for any other module having a _review_form function within it. It then takes the output of that function and merges it with the $form array for checkout_review_form.

Submitted by davea on Thu, 2009-02-05 07:59. categories [ ]

Apache Responds with Wrong Certificate

I ran into a situation where a client was accessing a test site and ended up getting a certificate from another site on the same server. Here is the setup:

Submitted by davea on Tue, 2008-07-01 23:17. categories [ ]

Drupal, Securepages and Secure Certificates

I think that I have finally determined a solution that works for the sites I maintain. This seems to solve almost all the problems that I have encountered:

  1. Install the non-ssl site in the sites directory: nonsecure.example.com
  2. Create a new directory in /sites/ for the ssl site: secure.example.com
  3. Copy the settings file from the nonsecure to the secure directory. Change the base_url to be the secure site's URL
  4. Create symlinks FROM the nonsecure directory to the secure directory:
  5. ln -s nonsecure.example.com/themes secure.example.com/
Submitted by davea on Wed, 2008-01-02 22:31.

Drupal and Secure Logins using mod_rewrite and manually setting the cookie Part 2

So you may have tried to do this according to my first blog post on the topic. If you did, you found that problems STILL existed!!

So I have created a patch to the securepages module (are you watching Gordon?) to allow this to actually work. And yes! It does work! There are some caveats though

  • The user login block, which I use to use on my site, won't work in SSL mode unless you limit it to SSL pages only. That means you can't put it on your homepage and have SSL logins. It appears that the user block in core needs to be changed or a replacement block created.
Submitted by davea on Sat, 2007-09-01 12:50. categories [ ]

Drupal and Secure Logins using mod_rewrite and manually setting the cookie

I never dug into mod_rewrite before Drupal. Now I do. I hope that I have explained this properly and that it helps others figure things out.

So here is the scenario:

  • logins should occur via SSL
  • everything else should occur via non-ssl
  • the main site is www.example.com
  • the ssl site is ssl.example.com
Submitted by davea on Thu, 2007-08-30 00:34. categories [ ]