Hacking Your Portable Linux Server
If you followed my advice to set the device name and workgroup earlier, your hostname is taken care of already. The device boots in DHCP mode by default, which can be altered easily for those who want a tiny, power-conscious but rather homebound server at their disposal. I find the greatest promise of the WDMBII in its easy mobility, however, and that poses the question of how to recognize its location quickly in a new setting—nothing that a good bit of scripting cannot fix.
The first approach to this is to have the device notify you of its IP address as it boots. I personally leverage instant messaging for these sorts of system notifications and have an “automation” group in my contact list featuring several borg-looking avatars that are authorized to send me all manner of alerts when the situation warrants. The key to this script is the SendXMPP tool (see Resources), which provides the ability to send instant messages with ease from the console. SendXMPP carries a few Perl module dependencies that you need to download from the CPAN archive and build. Retrieve the tarfiles via wget, extract and follow the customary perl Makefile.PL; make; make install procedure as root—the CPAN shell does not seem to work in the strict RAM confines of the WDMBII. After building two or three modules, you will be able to include the following one-line wizardry in /etc/init.d/post_network_start.sh (line 20):
# $SCRIPTS_PATH/mionet.sh start touch $POST_NETWORK_STARTED_FILE # Announce IP address of operation to admin OUT=`ifconfig | grep -A2 "eth0"`; \ echo -e "(lander) now operational: \n$OUT" \ | /usr/local/bin/sendxmpp -r lander-notifier \ -f /root/.sendxmpprc firstname.lastname@example.org fi
The script parses the current network configuration and sends it with appropriate text wrapping and an XMPP resource (-r) describing the device to one of my notification accounts. The user ID and password are retrieved from /root/.sendxmpprc (-f). Once the script is installed, the device will notify me of its IP address at every bootup in any network where DHCP is enabled and access to the Jabber server in question has not been restricted. The result message is very effective in allowing me to locate the device and possibly even troubleshoot occasional connectivity glitches:
(lander) now operational: eth0 Link encap:Ethernet HWaddr 00:90:A9:15:DD:73 inet addr:184.108.40.206 Bcast:220.127.116.11 Mask:255.255.254.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
This approach will serve most road warriors willing to put up with connecting to IP addresses. But, power users controlling their own domains can do even better. By setting up a dynamic DNS subdomain, one can enable the device to update at boot a fully qualified domain name, valid to the Internet at large. The intricacies of DNS zone configuration are beyond the scope of this article, but the Perl script to leverage a properly configured domain remains relatively simple:
# Variables to configure the script's operation my $hostname = 'ooga'; # Device hostname my $domain = 'dynamic.booga.org.'; # Domain name my $nameserver = 'ns1.booga.org'; # Primary nameserver # for your zone my $keyname = 'md5key'; # Name of the key my $key = 'se64bAsE64BASE64BasE64=='; # HMAC-MD5 TSIG key my $interface = 'eth0'; # Interface whose IP # is to be published
Refer to the Resources section of this article for a reference to the Web page where the author maintains the script. This more extensive solution makes our briefcase-friendly, quick-booting mini-server a full-fledged participant in the Internet.
The most obvious workload for our portable server is file-centric: well equipped with SMB support from Samba and NFS support built in to the kernel, as well as the lighttpd Web server and the rsync client, the system is ready to shine in this space. Enterprising users have built HOWTOs describing how to expand further the array of services to FTP and even BitTorrent, but I should not forget to mention that the system has a healthy complement of essential dæmons: ntp, cron and even Apple's mDNS are at your disposal out of the box.
The built-in toolchain enables the compilation of packages natively, but cross-compilation also is a possibility for jobs requiring more RAM than the device has available. It is, however, possible to find prebuilt packages for a number of services, as the device shares the ARM core of many others, its closest cousin being the Gumstix micro-board (check the many Gumstix sites for suitable binaries before starting a large cross-compiled build).
Webinar: 8 Signs You’re Beyond Cron
On Demand NOW
Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.View Now!
|Dr Hjkl on the Command Line||May 21, 2015|
|Initializing and Managing Services in Linux: Past, Present and Future||May 20, 2015|
|Goodbye, Pi. Hello, C.H.I.P.||May 18, 2015|
|Enter to Win Archive DVD + Free Backup Solution||May 18, 2015|
|Using Hiera with Puppet||May 14, 2015|
|Urgent Kernel Patch for Ubuntu||May 12, 2015|
- Dr Hjkl on the Command Line
- Initializing and Managing Services in Linux: Past, Present and Future
- Goodbye, Pi. Hello, C.H.I.P.
- Enter to Win Archive DVD + Free Backup Solution
- Using Hiera with Puppet
- Gartner Dubs DivvyCloud Cool Cloud Management Vendor
- Infinite BusyBox with systemd
- Mumblehard--Let's End Its Five-Year Reign
- A More Stable Future for Ubuntu
- It's Easier to Ask Forgiveness...