Saturday, 23 January 2016

How To Build A RaspberryPi based (BananaPro) TV Kiosk

We have multiple pairs of TV's in the office with each pair connected to a mac mini running xStand. They simply display a web page on each TV in full screen mode but you could use them any way you like.

We also wanted a solution that could turn itself on and off which would help reduce our energy bill. The mac mini's have the ability to set power on and power off schedules which is quite nice.

We also needed the TV's to turn on before the mac mini and turn off after the mac mini to ensure the web pages are displayed on the correct TV.

Most of the name brand TV's support auto power on/off schedules straight out of the box but it's quite a large price increase, like the kind that could be spent on a couple of USB missile launchers, or maybe parts to build a 3D printer one day.

So we picked up one of the largest (49 inch), cheapest TVs and grabbed a spare mac mini and off we went.

It worked! for a while. Some of the TV's have this stupid home screen when you power it on which can't be disabled. Every time the TV turns on, you have to press the home button to exit and that's super annoying. We'll get to fixing that later.

Obviously, there's a better way to deploy one of these setups and we believe we've found it. Bring on the BananaPro or as we've come to know them as, the DashPi.

Parts Required


Cost (Time Of Writing) Description Typical Use Case Purchasing Link
$84.95 BananaPro circuit board Pro version of the Banana Pi. https://www.gpio.com.au/shop/banana-pro-starter-kits/banana-pro-banana-pi-pro/
$14.95 Clear acrylic case A protective case for the BananaPi. https://www.gpio.com.au/shop/cases-and-sd-cards/clear-acrylic-case-for-the-banana-pro-banana-pi-pro/
$8.38 1m micro USB cable BananaPro power cable. Connects to the TV's USB port.http://www.4cabling.com.au/1m-usb-2-0-am-micro-bm-cable.html
$15.95 8GB MicroSD Card Operating system/data gets written to this. Faster = better. https://www.jbhifi.com.au/cameras/sony/sony-8gb-microsdhc-memory-card-uhs-i-class-10/837496/
$2.04 Network Cable(s) Might need more than 1 if your using a switch. http://www.4cabling.com.au/0-5m-cat-5e-rj45-rj45-network-cable.html
$10.47 2M HDMI Cable Connects the BananaPro to the TV. http://www.4cabling.com.au/2m-hdmi-v1-4-high-speed-with-ethernet-channel-red-braiding.html
$799 49 Inch LED-LCD Full HD TV Output for the BananaPro. https://www.jbhifi.com.au/tv-home-entertainment/hd-televisions/soniq/soniq-s49vt15a-49-full-hd-3d-smart-led-lcd-tv/734918/
$55.44 TV wall bracket To hang the TV on the wall. http://www.4cabling.com.au/ultra-slim-tv-bracket-up-to-55-75kg-black.html
$991.18Total

If you've decided to go it alone and select your own bits and pieces there's a couple of things you should keep in mind;

Multiple USB ports per TV


If the TV you've selected does not have multiple USB ports, you may need a USB hub if you plan to run more than one device from the TV's USB port.

Cost (Time Of Writing) Description Typical Use Case Purchasing Link
$22 USB hub If your TV doesn't have more than one USB port. http://www.auspcmarket.com.au/hi-speed-usb-2-0-4-port-hub-black/

Ethernet Network Ports


If you're like us and only have one network port on the wall to use with your BananaPro but require two, you'll need a network switch to connect your BananaPro's to the network.

But why bother when the BananaPro supports WiFi?

Because WiFi isn't reliable enough and in production, we found that sometimes the time it took to connect to the WiFi network meant the web pages failed to load.

Cost (Time Of Writing) Description Typical Use Case Purchasing Link
$29.95 USB powered network switch If there isn't enough network ports for your BananaPro to connect to. http://www.dual-comm.com/5_Port_LAN_Switch.htm

Assembly


Build The BananaPro Acrylic Case


Why bother writing stuff up, when you can can link to a video.


Connect Everything Up


The video below is a great resource to use if you want a professional looking installation. The first 12 minutes covers everything you need to know but unlike the above, i've also written something up as well. The truth is that i remembered the video AFTER i wrote this section.



Mount the TV bracket base plate to the wall making sure it is nice and level. Luckily, the bracket we selected has a built in bubble level which makes this task quite easy.

You'll want to make sure you screw into the your wall studs. Otherwise, you might come in one morning to see your TV hanging by its cables or worse, smashed on the floor. You have been warned!

Lay down a blanket, rug or use the carpet before you remove the stand from the TV and place the TV face down against your nice, soft. You'll need to attach the wall brackets to the back of the TV.

Before you hang the TV, it's a good idea to connect your cables while you have easy access to the ports. Connect your HDMI cable to HDMI input 1 on the TV and your Micro USB to any available USB port though i prefer to connect USB cables to the most difficult to access ports first.

Take the opportunity to tidy everything up now because once this is all installed, you probably won't touch it again. Use velcro cable wrap to secure the cables where you need them to be so they don't hang down below the TV height and don't get in the way when you try to mount the TV. You could use cable ties, but you'll kick yourself when you have to make changes to your setup.

Lastly, mount the TV on the wall. You might need an extra pair of hands in order to get it done. Just remember to keep the other end of the cables you attached where you can reach them. You'll soon need to connect the BananaPro.

BananaPro Configuration


Install The Bananian OS


Next, you'll need to download the Bananian OS. I suppose you could use Ubuntu or Debian (all of which can be downloaded from the lemaker.org website) but we chose Bananian. Not sure why though.. and i don't care. I've provided a link to the download page. http://www.lemaker.org/product-bananapro-resource.html

I have managed to track down a video on installing Lubuntu. The process is essentially the same when installing Bananian.


Connect the BananaPro to the TV


Now that your MicroSD card has its operating system, go ahead and insert it into the MicroSD card slot on the BananaPro.



Connect the network cable, HDMI cable and the Micro USB cable to the BananaPro. It's probably worth connecting a keyboard and mouse as well. We'll need them to perform the final configuration on the BananaPro.

You're now ready to turn your TV on (which will also switch on your BananaPro).

Moar Applications!!


Once your operating system has loaded, open Terminal via the shortcut on your desktop. If you need to enter a username and password, try bananapi / bananapi as your username and password.

Chromium is like your normal Chrome browser. I think Google Chrome shares some kind of link to Chromium but i'm not sure... and i don't care. Moving on, we can use this to load a website or maybe a web based slide show, a youtube playlist - whatever you want.

For us, we have a web server in the office that the BananaPro's all talk to. All BananaPro's load the same page making configuration simple and the webserver uses a spreadsheet (A CSV file if you must know) to figure out what content to display based on the BananaPro's hostname. The reason we use a CSV file is to allow other's to change the contents being displayed. I seriously don't want to know every time this needs to happen.

By loading the content in an Iframe and setting a content refresh meta tag on the loader page, we can change the content being displayed in the Iframe whenever we want without having to physically interact with the BananaPro. In our case, we just wait up to 15 minutes before the loader page refreshes and the content in the iframe reloads. Cool huh?

The BananaPro, just like many other HDMI devices has the ability to send audio over the HDMI cable. We decided to take advantage of this by installing text to speech functionality and combining it with aplay (which is pre-installed) to play mp3s.

Since it's really easy to install, we'll install it right along side chromium as well as configure some Stephen Hawking like text to speech alerts using espeak.

Finally, one of the problems with the Soniq TV's is the fact they come with this stupid home screen which can't be disabled. Every time you turn on the TV, there it is and it requires a button press on the remote to get rid of. Let's take care of this as well using lirc.

Install chromium, espeak, mpg123 and lirc


When you run the following in a terminal window, you'll be asked for a password. If you haven't changed your password, this will still be bananapi. Once you've successfully entered your password, apt-get will install the necessary applications.


sudo apt-get update && sudo apt-get install chromium espeak lirc mpg123

When you dump the following into an open terminal, you'll configure Chromium to load at startup and go straight into Kiosk mode displaying whatever page you tell it to display.

It will also disable any power saving functions like the screensaver.


Remote Controlled Crontab (Scheduled Tasks)

Early on we realised that we'd be asked to create recurring notifications. Obviously, we would use cron to automate this task but when you have 50 million of these buggers floating around, you really don't want to log into every single one of them to make them say "Home time!" at 6pm, Monday to Friday.

Enter remote controlled crontab...

Remote controlled crontab uses one crontab entry, generally deployed during initial configuration of the BananaPro. This cron entry calls a PHP file on a webserver somewhere. In return, the webserver responds with crontab which is then saved to /etc/cron.d/remote_cron. The contents of the BananaPro's crontab is dependant on the its hostname.

Why not just add the entries to /etc/crontab? Because if you break this process (which you probably will), you could destroy /etc/crontab which includes the only crontab entry which is capable of fixing your mistake. Using this system, if you mess up your crontab, the only file you'll destroy is /etc/cron.d/remote_cron but as you'll see soon enough you'll be able to fix it.

This guide won't go through how to set up a linux webserver with PHP installed but once you have done so, you'll need to create the following PHP file in the webservers' document root.


This file simply figures out the hostname of the BananaPro that's trying to talk to it, then opens a file on the webserver using the hostname as its key before returning the contents of that file. Sure, we could have written this code a little better but it's here, so you can do that if you want.

With that done, it's time to give our host a task to execute on a regular basis. How bout some audio notifications and an automated shutdown?

Audio Notifications


We also copied an mp3 which plays a couple of bells before the text to speech kicks in. We'll use mpg123 to play the bells followed by a text to speech notification using espeak.


sdfsdfjsdf

Automated Shutdown


Finally, we need to tell the BananaPro to shutdown overnight. To be honest, it's probably not that necessary given how little current the BananaPro's draw but we're paying for it and there's no need for it so let's tell it to shutdown once the majority of people have gone home for the night.

We could also turn the TV off, which would cut the power to the USB port shutting off the BananaPro. However, because we're cool we'll shut it down via crontab.

USB IR Blaster


Finally, we'll connect a USB IR Blaster between the BananaPro and the TV. This will be used to send certain TV remote signals to the TV to exit the stupid Soniq home screen and ensure the HDMI1 input is selected.

To be honest, this part is a PITA. Surely, there's a better way to do this...

Sunday, 4 October 2015

Rack 2 Rebuild

If you haven't already read it, i suggest reading about the BW Rack 1 Rebuild because all of the nitty gritty is covered in that blog post.

The only difference with this rebuild is the fact that we pre-cabled every single port and put cable labels on both ends of each network cable.

Before The Rack 2 Rebuild




And the moment you've all been waiting for...

After The Rack 2 Rebuild


The middle of the server rack.

The lower half of the server rack.


The top of the server rack before we re-routed the pesky electrical conduit.


And the front of the rack 2 server rack. Doesn't that look nice?


Took two people a day to get that done but i'm sure you can agree it looks great.

IITG 

Rack 1 Rebuild


So how do we do it? and why do we do it?

That's easy. How we do it is listed below. Why we do it, is pretty simple. It makes maintenance easier, troubleshooting easier, and it just looks like it's something that you can really be proud to show off.

Planning

This all starts as most things start, with an Excel spreadsheet. I find that a spreadsheet allows me to visualise exactly which RU the equipment will be loaded into. After all, it's better to shuffle machines around in a spreadsheet than it is once the servers are in place.

When finding a home for a piece of equipment, there's a couple of things i try to keep in mind. I try to load all of the equipment as close to the middle of the rack as i can with the most frequently accessed pieces (such as an LCD KVM) mounted closer to the middle so your not having to bend down or look up to use them. I will leave a space or two here and there for additional pieces of equipment but those with a lot of potential for expansion (such as a SAN) i will load at the edge. This of course means that I'll generally fill a rack with a maximum of two pieces of equipment which have a large potential for expansion. It's at this stage that a capacity plan could really come in handy. Unfortunately, i never seem to have one so i do my best with the information i have at the time and add an extra RU or two where i can.

Rack UPSs

When it comes to a rack UPS, i mount them at the bottom of the rack. Pretty simple really, they're usually quite heavy and by mounting them lower down they're easier to slide in and out. At least, that's what i think. Usually i mount these UPS systems by myself and i find it easy. With two people, it should be no problem.

Patch Panels / KVMs etc

I keep my patch panels, KVMs etc for smack bang right in the middle of the rack. Why? because it allows to me to purchase standard length cables which are readily available. Sometimes you forget to order enough, or new equipment is added after you've finished planning and it's more likely you'll have a few of these shorter cables just lying around.

Once all of the equipment locations are finalised, it's time to move onto the cabling. My spreadsheet tracks the numbers, lengths and colours of each cable that's connected to each piece of equipment. Once i'm done, i can tally up the totals ready for the purchasing. Don't think the spreadsheet just tracks network cables either. I also keep track of the quantity, length and colour of each power cable as well.

Purchasing

Server Rack

We replaced the existing server rack which was an old Dell PowerEdge rack with an APC AR3100 42U server rack. This also allows us to pre-cable and pre-load as much equipment as possible into the new server rack and simply unload the old rack, remove it from the area, 

The other benefit was the fact that the APC had Zero U mounting points allowing us to mount PDUs on one side and cable management on the other.

Cable Management

We use APC Vertical Cable Organizers for vertical cable management. There's not much to be said but i highly recommend them.

At the top of the rack, we have a 600mm APC Cable Trough. The electricians use the cable trough mainly. Also, the the outlet boxes are mounted to the cable trough.



APC cable troughs, when connected together allow the server rack to be removed independently of the electrical. When the server rack was replaced, we needed electricians onsite to disconnect and relocate the outlets. With the outlets mounted on the cable trough, the electricians are no longer required when replacing the server rack. Below is what the top of the server rack used to look like and as you can see, there's no way around getting the electricians onsite without that cable trough.



We used a ton of velcro cable wraps for data cables and cable ties for power cables, SAS cables etc. Buy this stuff in bulk because you'll rip through the stuff quite quickly if you want your installation to look neat.

Also, replacing cable ties is annoying. Use them only where necessary.

PDUs

We used a pair of APC AP8959 Switched IP PDUs. In a 240v single phase environment with 20amp circuits these are probably the best for the job. In this environment, they'll handle up to 16 amps each which is enough to meet the CTO's needs.

One of the PDUs (the inner most one) is connected to a UPS while the other is simply connected directly to mains power.

KVM

We purchased a 16 port Dell 2162DS IP KVM. It's cheap and nasty but does the job. I have to say, it was my first time dealing with it and i probably don't want to re-use them ever again. Check out the marketing video. It played no part in selecting the KVM but here you go:



You might be wondering, what happens when you have more than 16 servers in a rack? Well, either you upgrade the KVM or you designate one SIP to be a 'floating' SIP to quickly connect to the new servers.

Before you ask why not just buy a bigger KVM? It wasn't an option and the CTO is quite happy to upgrade when necessary.

Rack UPS

Again we turn to Dell for a UPS. From memory it was a 1920w line interactive UPS. We also added an Extended battery module (EBM) and an network management card so it could be remotely managed and monitored. We also purchased a Dell temperature probe to keep track of the temperature within the rack.

While you might seem to think that this would be quite small, you need to remember that this UPS is connected to just one PDU and therefore only needs to power HALF the total power demand of the rack.

During post installation testing, we were at 1 hour of battery backup time for the entire server rack. This far exceeded the 20 minute requirement set by the CTO. Without the EBM though, we were at 15 minutes of battery backup time. The system can't be expanded beyond this capacity. You get what you pay for, nuff said.

Pictures Before The Rebuild






After The Rebuild


Although the picture doesn't show it, we wrapped the IEC leads connected to the outlets in the same colour as their feed cable (Red or Blue). This ensures you always know your dealing with the right power outlet.

You can also clearly see the status of those two outlets without opening the doors. This was something that wasn't possible with the old setup.


And this is the front of the server rack. In the end, we ditched the Dell covers on the front of the servers. I'm sure there's plenty of good reasons to do it such as airflow, better visibility of status lights etc. The real reason though was that they look ugly.


And then before and after. You'll also notice we scrapped the Dell cable management arms. I'm sure there's plenty of good reasons to do it such as airflow, better visibility of status lights etc. The real reason though, well, you know why.



And that's how you rebuild a server rack, costs a little bit but so much easier to work on than what was there before.

IITG

Saturday, 26 September 2015

Soundproof Server Room In A Box




This was part of an office fit out. The fit out consisted of a total of 140 odd network ports. My job was to figure out what needed to be done and get all of it up and running. 

Obviously, running 140 odd cat 6 cables back to the other side of the office would take quite a few people or a considerably long time and become quite costly.

Also, the area around the centre of the building is a common area so we can't very well run 140 odd network cables as the crow flies.

Instead, we decided to run a multicore fibre cable encased in corrugated PVC conduit connected to two, 1RU patch panels at each end. Cisco 10GBASE SE-SR SFP Modules are used at each end connecting the two locations together. Along with the fibre cable, there's four cat 5E cables which are used to connect the console port on each switch and UPS to an Out Of Band (OOB) management device allowing network maintenance to be performed remotely.

The SFP modules are connected to a stack of three, Cisco Catalyst 2960S 48 port switches (non POE) providing a small measure of redundancy.


We tried to use different coloured power cabling to try to make it quick and easy to identify what device your dealing with. The image above was taken before the project was finished and as such doesn't show the labeling that was added to each power cable. When your in the field and you've got an issue to deal with, it's nice having the information as fast as possible centred around where the problem usually is.

The switches are connected to a Zero U basic PDU which came with the rack although i tried really hard to find a switched IP PDU but couldn't find a single one which would fit. If someone out there makes switched IP PDUs, please make me a half height zero U PDU please.

There are three Cisco SPA 514G IP Phones, a 2n Helios IP Uni Single Button intercom and two Cisco Aironet 2600i Access Points. Being POE devices, we installed POE injectors which are hidden inside the rack. The cabling for POE devices is standard cat 6 cabling but with yellow cabling it sticks out. Obviously, i would have preferred to use POE switches but the limited number of POE devices at the time of switch selection coupled with the additional cost put POE switches out of reach.

The PDU is powered by a an APC 750VA UPS giving the entire system a good few hours of battery backup. An APC UPS Network Management Card with Environmental Monitoring ensures UPS status as well as temperature and humidity can be monitored within the server rack.


All of the data across the floor is connected to a number of Krone 24 port 2RU patch panels. These patch panels are pretty standard fare but they don't work well with the Neatpatch NP2K648 2RU Cable Management Kit. What's that you say? To give you a brief overview, check out this video from Cable Supply.

The Neatpatch NP2K648 2RU Cable Management Kit came with 48, 2 foot cat 6 patch leads. Each of these patch leads were labelled at both ends using cable labels oriented so the label was easy to read. Have a look at the before and after pics to see what it can do.





All of this goodness is contained within an APC NetShelter CX 18U Secure Soundproofed Server Room in a Box Enclosure. It remains locked at all times and when closed, no one really knows there's IT equipment whirring around inside the thing. Check out the video from APC for more information.


Thanks for reading everyone!

IITG

Who Is The Ignorant IT Guy

An IT guy who's been in the industry for over 10 years. I left school after year 10 and started working packing computers into boxes for Acer before being moved to the production line building and imaging the computers. Earning a little over $200 AUD and being 17 years old at the time, obviously i felt like a millionaire being able to purchase random crap for myself, my girlfriend and my friends.

As my contract with Acer finished, i found work at a local sports centre. I was able to use the facilities for free, and learn about linux by implementing an LDAP domain, internal DNS/DHCP, VPN and a generic fileserver.

I managed to someone secure an interview with a medical company and began work as a helpdesk engineer. In under two years, i had received four promotions making it to a linux systems administrator by hard work and hands on self education.

I've had no formal training prior to entering the industry and still continue in this fashion. I've pretty much learnt everything i know from just getting stuck in and finding out what works and what doesn't.

Generally when something doesn't work, i need to get it fixed as fast as possible. Preferably before anyone notices.

That's who i am. That's why i do what i do. I don't claim to be an expert on anything so don't assume i am. I don't claim to be anything really.

I set this blog up to share my experiences and hopefully expand my knowledge by sharing my thoughts with you and hopefully being corrected at the same time.

IITG