concerto_rpi
concerto_rpi copied to clipboard
Concerto Digital Signage Client script for a Raspberry Pi
┌────────────────────────────┐
│ Concerto for Raspberry Pi │
│ By: Andrew Fryer │
│ March 13, 2013 │
╔════════════════════════╧════════════════════════════╧══════════════════════════╗
║ 1. Introduction ────────────────────────────────────────────────────── Line 28 ║
║ ║
║ 2. Setting up the Raspberry Pi ─────────────────────────────────────── Line 39 ║
║ a. Required materials and software ║
║ b. Installing the OS ║
║ ║
║ 3. Setting up Concerto ─────────────────────────────────────────────── Line 75 ║
║ a. Automatic Installation ║
║ I. Required Files ║
║ II. Installing Concerto and ShoutCast for Pi ║
║ b. Manual Installation ║
║ I. Required Software ║
║ II. Installing the Script ║
║ III. Setting up the Cron Job ║
║ IV. Setting up AutoLogin ║
║ ║
║ 4. Changing the Concerto Settings ─────────────────────────────────── Line 175 ║
║ a. Concerto Server Address ║
║ b. ShoutCast Server Address ║
║ c. Automatic Daily Reboot ║
╚════════════════════════════════════════════════════════════════════════════════╝
╔════════════════════════════════════════════════════════════════════════════════╗
║ 1. Introduction ║
║ ║
║ This document explains how to properly set up a Raspberry Pi mini computer ║
║ to act as a Concerto client machine. The basic goal of this is to have a ║
║ device that, upon starting, will automatically start a Midori browser in ║
║ fullscreen and send it to the Concerto web page containing the device's ║
║ specific contents. We also wish to hide the mouse cursor and prevent the ║
║ device from going to sleep due to inactivity. Also, if the Midori browser ║
║ were to crash or close, we want to automatically restart the browser as ║
║ soon as possible. ║
╠════════════════════════════════════════════════════════════════════════════════╣
║ 2. Setting up the Raspberry Pi ║
║ ║
║ a. Required materials and software ║
║ - Raspberry Pi Model B and a 5V-1A MicroUSB Power Supply ║
║ - Standard SD card 4GB or more (class 6 or better) ║
╨ - Raspbery Pi's Wheezy Linux Distro OS ╨
http://downloads.raspberrypi.org/download.php?file=/images/raspbian/2012-12-16-wheezy-raspbian/2012-12-16-wheezy-raspbian.zip
- Win32 Imager (use secure mirror link to download)
http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml
╥ ╥
║ b. Installing the OS ║
║ - Begin by first formatting the SD card.This can be either a full ║
║ format or a quick format. If the SD is already formatted then you ║
║ don't need to bother. ║
║ - Next run the Win32 Disk Imager program with Adminstrative Privileges. ║
║ Select the drive letter for the SD card and open the Wheezy .img ║
║ file. Once that's done click the [Write] button. ║
║ - Once the program finishes your SD card will now contain the Wheezy ║
║ OS. The next thing is to test it to make sure it works. ║
║ - Place the card in the Raspberry Pi and start it up. If it works ║
║ great! If not, try reinstalling the OS. ║
║ - Once the Pi starts up for the first time you will see a blue screen ║
║ menu. This is for the initial Pi system setup. You can adjust the ║
║ system timezone, keyboard layout etc. Make sure that the SSH is ║
║ enabled so you can remote connect to it later on. ║
║ - Once you're finished setting that up and have left the menu you will ║
║ eventually reach a prompt. If you are asked to log in the default ║
║ user and password are as follows: ║
║ user: pi ║
║ pass: raspberry ║
║ - Once your at the "pi@raspberrypi ~ $" prompt, enter the 'startx' ║
║ command. This will begin the Wheezy GUI program which eventually give ║
║ you a nice desktop and mouse. ║
║ - At this point you are done. When the desktop starts up you can ║
║ proceed to section 3. Setting up Concerto. ║
╠════════════════════════════════════════════════════════════════════════════════╣
║ 3. Setting up Concerto ║
║ a. Automatic Installation ║
║ I. Required Files ║
║ These files should be found in the ConcertoForPi.zip file. ║
║ - InstallConcertoForPi.sh ║
║ - .crontab ║
║ - .script ║
║ - .shoutcast ║
║ II. Installing Concerto for Pi ║
║ - Extract the files onto the Raspberry Pi. You can do this by ║
║ either downloading the ConcertoForPi.zip from a network location ║
║ or by transferring it with a USB flash drive. ║
║ - Once extracted, open a command prompt (linux terminal) ║
║ - Navigate to the extracted files using the cd and ls commands ║
║ - Type the following command: ║
╟────────────────┤bash InstallConcertoForPi.sh├──────────────────────────────────╢
║ - Follow the on-screen instructions and you're done! (your mouse ║
║ should disappear when ever it's not moving. The Raspberry Pi ║
║ should not turn off while inactive and the Midori browser ║
║ should begin to automatically start. Music should also play if you ║
║ chose to configure your Pi for a shout cast playback) ║
║ ║
║ b. Manual Installation ║
║ I. Required Software ║
║ This software must be installed onto the Raspberry Pi ║
║ - x11-xserver-utils ║
║ - unclutter ║
║ (For ShoutCast) ║
║ - alsa-utils ║
║ - mpd ║
║ - mpc ║
║ To install the software, open a command prompt and enter the ║
║ following command: ║
╟─────────────┤sudo apt-get install x11-xserver-utils unclutter├─────────────────╢
║ (For ShoutCast also enter) ║
║ │sudo apt-get install alsa-utils │ ║
║ │sudo echo "snd_bcm2835" >> /etc/modules│ ║
╟─────────────┤sudo apt-get install mpd mpc ├──────────────────────────╢
║ │sudo /etc/init.d/mpd stop │ ║
║ │sudo chmod -x /etc/init.d/mpd │ ║
║ II. Installing the Scripts ║
║ For this you will need the .script and .shoutcast files. This script ║
║ is what automates opening the Midori browser to the Concerto web page ║
║ and making sure the computer does not fall asleep. ║
║ (Concerto Script) ║
║ - First copy the .script file to the home folder. If you're not sure ║
║ where that is, enter the following into a terminal: echo $HOME ║
║ - Rename the file to "digitalsignage.sh" ║
║ - Next, open the file in a text editor and just after the line ║
║ 'LOG="./digitalsignage.log"' add the following on its own line: ║
╟───────────────┤ConcertoServerIP="<CONCERTO_URL>"├──────────────────────────────╢
║ - Replacing <CONCERTO_URL> with either the web URL or IP address of ║
║ the Concerto server. ║
║ - Save the document and move on to the next step. ║
║ (ShoutCast Script) ║
║ - First copy the .shoutcast file to the home folder. If you're not ║
║ sure where that is, enter the following into a terminal:echo $HOME ║
║ - Rename the file to "shoutcast-radio.sh" ║
║ - Next, open the file in a text editor and just after the first two ║
║ lines (which are just file comments) add the following on its own ║
║ line: shoutcast_radio_link="<SHOUTCAST_URL>" ║
║ - Replacing <SHOUTCAST_URL> with either the web URL or IP address ║
║ and port of the Concerto server. ║
║ - Save the document and move on to the next step. ║
║ III. Setting up the Cron Job ║
║ - Open a terminal and enter the following command: ║
╟────────────────┤crontab -eu $USER├─────────────────────────────────────────────╢
║ - You should now see a command line text editor. Scroll down to the ║
║ bottom of the file and add the following line (include every ║
║ character including the s): ║
╟───────┤ * * * * export DISPLAY=:0 && /bin/bash $HOME/digitalsignage.sh├───────╢
║ (For ShoutCast also add the following line beneath the previous) ║
╟───────┤@reboot /bin/bash $HOME/shoutcast-radio.sh &> $HOME/shoutcast-radio.log├╢
║ (For the automatic daily reboot, add the following as well) ║
╟───────┤M H * * * sudo reboot├──────────────────────────────────────────────────╢
║ (Replace 'M' with a minute value 0-59.) ║
║ (Replace 'H' with an hour value 0-23. 0=12am, 23=11pm) ║
║ - Once done, save the document and close. If the editor does not ║
║ show instructions on how to do so it is most likely the 'vim' ║
║ editor. To exit hit [Esc] and then enter ':x' and hit enter. That ║
║ should save and close the document. ║
║ IV. Setting up AutoLogin ║
║ - First, open the .bashrc file that is located in /home/pi. This is ║
║ a hidden file so you may need to right click and select the ║
║ "Show Hidden" option. ║
║ - Once it is open in a text editor, scroll to the very bottom and ║
║ add the following three lines of code and then save the file. ║
║ │if [ "/bin/ps -A | /bin/grep -o -E "startx"
" == "" ]; then│ ║
╟────────────────┤ startx ├──╢
║ │fi │ ║
║ - That code insures that when you auto login, the desktop will ║
║ automatically load as well. ║
║ - Next we need to make our pi login automatically. First navigate to ║
║ the /sbin folder and open the file "inittab" in a text editor. ║
║ - Once open, search through the file until you find the following: ║
╟────────────────┤1:2345:respawn:/sbin/getty --noclear 38400 tty1├───────────────╢
╨ - You must replace the previous line you just found with this one: ╨
1:2345:respawn:/sbin/getty --noclear 38400 tty1/1:2345:respawn:/bin/login -f pi tty1</dev/tty1 >/dev/tty1 2>&1
╥ ╥
╠════════════════════════════════════════════════════════════════════════════════╣
║ 4. Changing the Concerto Settings ║
║ a. Concerto Server Address ║
║ - First navigate to the digitalsignage.sh file is located. It should be ║
║ the user's home folder which can be found by entering the following in ║
║ a terminal: echo $HOME ║
║ - Open the digitalsignage.sh file in a text editor. ║
║ - Locate the line that starts with 'ConcertoServerIP=' ║
║ - Inside the double quotes("") on that line is where the Concerto Server ║
║ URL/IP Address is stored. ║
║ - Change it to the new address and save the file. ║
║ b. ShoutCast Server Address ║
║ - First navigate to the shoutcast-radio.sh file is located. It should be ║
║ the user's home folder which can be found by entering the following in ║
║ a terminal: echo $HOME ║
║ - Open the shoutcast-radio.sh file in a text editor. ║
║ - Locate the line that starts with 'shoutcast_radio_link=' ║
║ - Inside the double quotes("") on that line is where the ShoutCast ║
║ Server URL/IP Address is stored. ║
║ - Change it to the new address and save the file. ║
║ c. Automatic Daily Reboot ║
║ - Open a terminal and enter the following: ║
╟──────────┤crontab -eu $USER├───────────────────────────────────────────────────╢
║ - Find the following line: (The #'s will have actual numbers) ║
╟──────────┤# # * * * sudo reboot├───────────────────────────────────────────────╢
║ - To stop the automatic reboot, you can place a single '#' at the ║
║ beginning of the line. This comments out the line and therefore ║
║ disables it. ║
║ - To change the time, replace the first number with the minute value you ║
║ wish (0-59), and the second number with the hour value you wish ║
║ (0-23, 0=12am 23=11pm) ║
║ ie. "30 7 * * * sudo reboot" will reboot at 7:30am ║
║ "15 15 * * * sudo reboot" will reboot at 3:15pm ║
║ - When you are finished, save the file and close. If there are no ║
║ onscreen instructions on how to do this, try hitting [Esc] then typing ║
║ ":x" and hitting enter. ║
╚════════════════════════════════════════════════════════════════════════════════╝