Digital Signage in the Church Setting

The latest project has been trying to get a digital sign up and running in the church.  I thought I’d give a little breakdown of the project.

The Concept: Create a Digital Sign that can list church activities, announcements and other important information.  It must be cheap, easy to update and be upgradable for the future.  It also must have an anti-theft device to dissuade someone from trying to steal it since it is in an open area.

The Challenges: Coming up with a system that can be edited easily but doesn’t cost an arm and a leg.  There are great sign companies out there providing great solutions for a fee.  You could always get a TV with a USB reader and load slides everyday.  But I wanted something that was easier than that.  I wanted it to be web-based so a volunteer could log-in and update it.

The Solution: Obviously any TV with an HDMI input will work.  The question is how to get info onto the TV.  Initially I thought about a recycled computer running Debian or Ubuntu but when I contemplated running a long enough HDMI cable to reach or the issue of powering it, I switched my focus.  What about a Roku, Boxee Box or Apple TV?  All legitimate options.  I landed however on the Raspberry Pi Model B.

This baby will run a modified version of Debian, uses 5v and so far will just run 24/7.

Building the Raspberry Pi to run the Digital Sign

This is my first project with the Pi and I must say I’m blown away.  Following the instructions I got Raspbian up and running on a 16GB SD card, it auto-loads into the pi user.  I found a Cell Phone Charger that would reach the 700mAh required on the mini-USB port and purchased a black case that allowed the standard ports to be visible (it also screwed together instead of snapped which is important for the security side of things).
With SSH access over the network I installed Chromium so I could run Kiosk mode.
I simply modified the autostart file at /etc/xdg/lxsession/LXDE and added “@chromium –kiosk http://YourUrlHere
You will find quickly the mouse stays in the center without any commands from the user so we also add an xwit command to force the mouse to the bottom corner:
“@xwit -root -warp $( cat /sys/module/*fb*/parameters/fbwidth ) $( cat /sys/module/*fb*/parameters/fbheight )”
I figured out pretty quickly two things.  The operating system will blank the screen without activity AND Chromium will only show the site loaded at startup.  I needed a way to refresh the screen on a regular basis.  I first found xdotool which mimics key and mouse commands from the terminal and installed it.  This plays well so I can also sent automatic refresh commands from ssh.
I then added a 15 minute cron command through crontab that calls the two parameters into play you need to refresh:
“export DISPLAY=:0”

“xdotool key F5”

When the device is turned on it will no autoload into pi, launch chromium in kiosk mode, put the mouse in the bottom right corner and then refresh the screen every 15 minutes.

Building The Sign Website

A couple people have discussed using Drupal for this type of idea but I didn’t find a clear walk through. Below I’ll try to explain what I did to set it up.
First, I decided to go with an internal server so I setup a Debian box I have running our Unifi Wireless system to host a Drupal 7.23 website.  I like having my own box so I can install things with Drush.  You can of course use a web hosting company and point the Pi to the internet but if your building loses internet then your sign shuts down 15 minutes later with an error.
  1. Install Drupal as you normally would
  2. Add the following Modules:
    1. Front Page
    2. Chaos Tools
    3. WYSIWYG Editor
    4. IMCE
    6. Views Slideshow
    7. Libraries
    8. IMCE wysiwyg
    9. Draggable Views
    10. Entity
    11. Add the jquery files for the slideshow module
    12. Add TinyMCE (or other favorite editor) for WYSIWYG
  3. Add your favorite Theme Template (I used Adaptive Theme)
  4. Disable Comment module
  5. Remove all the Blocks you don’t want displayed
    1. I have a header block to contain the Logo
    2. The main content block
  6. Go into the Image Style and setup any cropping you want for images you upload and thumbails
  7. Setup your Content type
    1. I created an Announcement that just has a Title, Image and Thumbnail
    2. I also created a Schedule content type that contains Title and Body
  8. Create a View that shows both types in a Slideshow Format
  9. Follow the instructions to create a draggable view
    1. I limited it to the title and thumbnails in a block
    2. Connect the draggable view to the main slideshow
  10. Create a View through blocks that shows unpublished content
  11. Setup Front Page to point to your slideshow link
Now you should be able to throw some content in and see how it looks.  I based mine on the 32″ TV specs (1366 x 768).  All my images are no larger than that and the schedule content all contains a DIV marker that sets a background and size for now.  I plan to theme it into the system but just cheat by putting the code directly into the content body.
The real challenge is making the back-end work properly.  I started by turning the authenticated user into the permission laden account for volunteers.  I gave them just enough access to change content and add stuff including the ability to drag the slideshow into order.
I then went back into blocks and added the draggable block to the sidebar and made it visible only to authenticated users and admins.  This now becomes the link to the content AND the order it shows on the site.  I also enabled the Navigation bar for only the Authenticated and Admin plus I threw the user menu into the top menu location and limited it a link to which I titled Home and the Logout button.


Finally I mounted the TV in it’s location in the Church.  I pulled off the back panel of the TV (note: you can easily damage the TV so do so with caution) and drilled holes for a U-Bolt and a hole for the Raspberry Pi case.  By bolting part of the case to the back of the TV I’m making it difficult to steal the Pi.  The Pi and the top part of the case then enclose the bolt.
I then purchased a regular Safety Hasp from Home Depot along with a Master Lock and 6 foot cable.  I looped the cable through the U-Bolt on the back of the TV, looped the cable around the mount a couple times and locked it all to the hasp.  I made sure the hasp had at least 2 long screws going into a stud so you can’t just rip it out of the drywall.
There are still some clean-up things to do to make it look better but so far it’s working properly.  We will see if the Church Volunteers will be able to maintain the information properly.

Slicing an MP3 Based on Marks in the Metadata

Notes: Installing ExifTool – You need sudo yum install perl-ExtUtils-MakeMaker before the Install instructions work for

I first decided to use exiftool to find the data I needed:

exiftool -UserDefinedText -a filename.mp3 [where -UserDefinedText is the specific metat field and -a shows all of the fields]

User Defined Text               : (DDJ/VER) 0100
User Defined Text               : (DDJ/MK01) 885324
User Defined Text               : (DDJ/MK02) 1956684

exiftool -UserDefinedText -a filename.mp3 | grep -oP ‘\d+\D+\K\d+’

Extracts the data, uses grep to pull both numbers.

Since I want them separate I add a second grep (might be a better way).

exiftool -UserDefinedText -a $file | grep MK01 | grep -oP ‘\d+\D+\K\d+

Here’s the script test file

#!/bin/bash -x


mk1=`/usr/local/bin/exiftool -UserDefinedText -a $file | grep MK01 | grep -oP ‘\d+\D+\K\d+’`

mk2=`/usr/local/bin/exiftool -UserDefinedText -a $file | grep MK02 | grep -oP ‘\d+\D+\K\d+’`

/* calculate start */

totsecs1=`echo $mk1 / 900.037 | bc`

min1=`echo $totsecs1 / 60 | bc`

sec1=`echo “$totsecs1 – ($min1 * 60)” | bc`

totsecs1=`echo “scale=2; $mk1 / 900.037” | bc`

hund1=`echo “$totsecs1 – ($min1 * 60) – $sec1” | bc`

hun1=`echo “scale=0; $hund1 * 100/1” | bc`

start=`echo $min1″.”$sec1″.”$hun1`

/* calculate end */

totsecs2=`echo $mk2 / 900.037 | bc`

min2=`echo $totsecs2 / 60 | bc`

sec2=`echo “$totsecs2 – ($min2 * 60)” | bc`

totsecs2=`echo “scale=2; $mk2 / 900.037” | bc`

hund2=`echo “$totsecs2 – ($min2 * 60) – $sec2” | bc`

hun2=`echo “scale=0; $hund2 * 100/1” | bc`

end=`echo $min2″.”$sec2″.”$hun2`

echo $start” “$end

/* Split the file */


mp3splt $file $start $endmp3

Update Drupal 7 using SSH

This is my own tutorial so I don’t forget for the future.  Stole directly from with modifications for my useage.  I currently use dreamhost and enjoy their SSH access to the servers my sites are hosted on.

UPDATE: I now added Drush to my SSH access so you only need to run one command to backup and update.

$drush pm-update

The following is for those with limited SSH or access to the host only via web/ftp.

Prepare your site

  1. Switch Drupal into Off-line mode so that visitors do not access the site while the upgrade is happening and encounter various errors.
  2. Ensure that you are logged into the site as the main administrator account (user ID 1). You cannot run the update.php file near the end of the process unless you are logged in as the administrator user. If you forget to log in first before running update.php, the page will inform you of the step to take to regain access.

Backup your site

Next back up the full site, both the files as well as the database. Never upgrade without backing up. Ever. Here are the basic commands needed for a quick manual backup:

  1. First make a directory with today’s date in your backups folder (create the backups folder first if you haven’t made one yet). Ensure that this folder is not accessible to the web:
    mkdir /home/yoursitename/backups/08-17-08
  2. Now backup the database (customize with your directory paths and info):
    mysqldump --user=username --password=password --host=drupal_database > /home/yoursitename/backups/08-17-08/yoursite_db.sql
  3. Next backup your site’s files (again, customize as needed):
    tar -czvpf /home/yoursitename/backups/08-17-08/yoursite.tar.gz /home/yoursitename/public_html

Upgrade your site

  1. Navigate to your site’s root directory (the following commands from this point are to be run while you are in the root directory of your site):
    cd /home/yoursitename/public_html
  2. First make a temporary folder to hold Drupal’s old files/folders until you’re certain that the upgrade has completed successfully (doing this extra step instead of deleting the old files right off can be helpful in an emergency, since it makes it quick and easy to undo things back to normal if the upgrade fails for some reason, rather than bothering with extracting the whole backup):
    mkdir d-backup
  3. Next paste in the following command which moves all of Drupal’s files and folders, besides your personal ones (such as the /sites and /files folders), into the temporary d-backupfolder. The .htaccess and robots.txt files are not included in the move since it’s possible that you’ve customized them (however if not, feel free to add them to the list):
    Drupal 7:

    mv authorize.php CHANGELOG.txt COPYRIGHT.txt cron.php includes index.php INSTALL.mysql.txt INSTALL.pgsql.txt install.php INSTALL.sqlite.txt INSTALL.txt LICENSE.txt MAINTAINERS.txt misc modules profiles scripts themes update.php UPGRADE.txt web.config xmlrpc.php d-backup

  4. Check’s home page to get the download link for the latest version of Drupal (or simply adjust the number in the command below). Generally you can safely upgrade from your current version of Drupal to any version within the same release (for example 6.1 to 6.4), though reading the UPGRADE.txt files for each version ahead of time is advised, just in case. However extra caution/preparation is required upgrading between major releases (for example 5.x to 6.x). Some web hosts do not support the wget command so the alternate curlcommand is also listed (if neither are supported, resort to FTP).
    Using wget:
  5. Extract the downloaded file (it will create its own sub-folder for the files, so don’t worry about it getting mixed up with your own files). This command assumes you only have one downloaded copy of Drupal in the directory – if you have others, enter the full name to exact it instead of using the wildcard character:
    tar -xzvpf drupal-*
  6. Go into the newly created sub-directory:
    cd drupal-*
  7. Run the following command to move the new Drupal files out of the folder they were extracted into and into place in the root directory of your site. This moves “only” the same files and folders which you moved into the d-backup folder, preserving all of your personal files and folders (e.g. the /sites and /files directories) The ../ at the end is what tells the command to move the data up one level in the folder structure, into your site’s root directory:

    Drupal 7:
    mv authorize.php CHANGELOG.txt COPYRIGHT.txt cron.php includes index.php INSTALL.mysql.txt INSTALL.pgsql.txt install.php INSTALL.sqlite.txt INSTALL.txt LICENSE.txt MAINTAINERS.txt misc modules profiles scripts themes update.php UPGRADE.txt web.config xmlrpc.php ../
  8. Return to your site’s root directory:
    cd ..
  9. If you had any extra files which you placed into Drupal core folders (for instance jquery.js into the /misc folder in the case of having the jQuery Update module installed), you can quickly restore them into place using commands as well. Very few modules ask you to put files outside of the modules directory, so this may never be a step you need to do. Here are several common examples:
    cp sites/all/modules/jquery_update/jquery.js misc/jquery.js
    cp sites/all/modules/image/ includes/
  10. Lastly, go to in your web browser and follow the instructions to update the database within a few clicks. Do not adjust any of the drop-down menus under the “Select versions” fieldset; simply run update.php. You can go to Administer > Logs > Status report (Drupal 5) or Administer > Reports > Status report (Drupal 6 and 7) to confirm your Drupal version.

Clean up temporary files/folders and restore access to your site

  1. Now that the upgrade has completed successfully, go ahead and delete the temporary d-backup folder (remember you still have your “real” backup file in case you need it). Also delete the tar.gz copy of Drupal which you downloaded and the drupal-* folder it was extracted into. To do this all in one step, run this command (only if you do not have any files or folders the name of which begins with drupal- that you want to keep, as this will immediately delete them all):
    rm -rf d-backup drupal-*
  2. Many Drupal site admins prefer to delete the various .txt files (such as UPGRADE.txt, README.txt, etc) in the root directory of their Drupal sites (often because these files easily reveal the currently-installed version of Drupal to the public). Feel free to delete every .txt file from your Drupal installation directory besides robots.txt. If you perform this deletion, adjust the “mv” (move) commands from steps 3 and 7 to no longer include these files during future upgrades.
  3. When done, you can re-enable Drupal for the public again at Administer > Site configuration > Site maintenance (admin/settings/site-maintenance). You should test the site to ensure that everything works as expected.