Hack and / - Working on My Temper

 in
Find out whether I can port my beer fridge controller from a laptop to a Pogoplug without losing my temper.
Note: a Quick Rant about Pacman

I have to admit that Plugbox was my first foray into the Arch Linux distribution. I know a number of people who really like Arch, and I don't really have an opinion one way or the other about the distribution itself, but I wanted to say a few words about pacman. First, I love the name. Second, who came up with the command arguments? In my experience, capital letters in arguments always are reserved for when you run out of lowercase arguments (or alternatively, to do the opposite of what the lowercase argument does), and although sometimes arguments have no relation to the action you are performing, at least for most programs, the most commonly used actions are the ones with the intuitive arguments. For instance, I fully expected pacman to use -i to install a package or possibly to use a longhand --install. The -S argument it does use simply makes no sense (I know it stands for “Sync” but that's a long way from “install”), and the -Ss argument to search for packages that match a keyword makes even less sense. I know it takes only a second to get used to it, but I'd still argue there are a number of more intuitive letters to choose.

CPAN Is a Harsh Mistress

Because it was so easy to build bottlerocket, I assumed it would be a relative cakewalk to install all the Perl modules I needed using CPAN. For those of you who aren't Perl hackers, Perl provides a vast repository of extra modules on-line at www.cpan.org. If there is a particular Perl module you need, you can use the cpan binary on your local system to pull down and build those modules for your system much like a modern package manager. I figured that even if Plugbox didn't include a lot of Perl modules, I would identify the modules I needed and install them one by one, like in my previous TEMPer column. The reality was that although Plugbox did include Perl and even included the cpan binary, it didn't include a lot of the necessary modules you need for CPAN actually to work.

Honestly, everything else about this project was simple once I got CPAN working, but this part of the process took the most time and effort, and it really reminded me of what Linux was like back in the day when you would find a cool project on Freshmeat, download the source and then spend the next two days tracking down all the dependencies. I finally found the magic list of packages and libraries I needed, and in this case, I had to install a few packages from Plugbox along with a manual module compilation:

# pacman -S perl-yaml perl-xml-libxml 
# pacman -S perl-text-query perl-text-diff perl-text-reform
# wget http://search.cpan.org/CPAN/authors/id/R/RC/RCLAMP/
 ↪Text-Glob-0.08.tar.gz
# tar xfvz Text-Glob-0.08.tar.gz
# cd Text-Glob-0.08
# perl Build.PL
# perl Build test
# perl Build install

From this point, I was able to get the cpan binary to function, and I could follow the installation steps I laid out in my previous column to finish the process (I was glad I had that nicely documented for myself). Afterward, all I had to do was edit my temper.pl script so that it referenced /dev/ttyUSB0 instead of a local serial port and created a file called /etc/cron.d/temper that contained the following data:

* *  * * *   /usr/local/sbin/temper.pl

After I restarted cron (/etc/rc.d/crond restart), I was able to check my logs and see that the script was, in fact, reading the temperature and controlling the fridge just like my laptop. In case you'd like to do something similar with your Pogoplug, Listing 1 is the current iteration of the script.

Now that I've had this running without issues for a few weeks, I do like how quiet and low-power the device is. Plus, it takes up less space on the top of my fridge. The only real drawback I've seen is that there is no screen on the device. On my laptop if I wanted to check the temperature, I just had to open the lid; now, I have to ssh in to the Pogoplug. Although I used a Pogoplug for this, I imagine you could translate these steps for a number of other small Linux devices that have USB ports, like the NSLU2—provided it included Perl and a gcc build environment. Now I can use my old laptop for nobler pursuits—like maybe some day powering my smoker.

______________________

Kyle Rankin is a director of engineering operations in the San Francisco Bay Area, the author of a number of books including DevOps Troubleshooting and The Official Ubuntu Server Book, and is a columnist for Linux Journal.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

fully

fully's picture

thanks edi.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix