Latest Entries »

For those of you not in “the know,” the /etc/motd or the MOTD stands for “Message of the Day.” The file contains text that is displayed whenever logging in via SSH to your machine. If you found this article via a search engine, you probably already know that.

 

To the best of my knowledge, back in Ubuntu 8.04 (Hardy Heron), the MOTD was static and involved updating the /etc/motd or /etc/motd.tail file. When switching to 9.04 (Jaunty Jackalope) I made no changes to the MOTD and therefore noticed no difference. When attempting to edit the MOTD in 10.04 (Lucid Lynx), it appears that the process has changed so that the MOTD is not read from one (or two) static text files that may or may not need periodic updating. Since 8.10 (Intrepid Ibex) it appears that the MOTD can be updated dynamically by using a number of scripts. I’m always the last to know!

 

Let’s jump right in and I’ll explain as we go. For some of the commands, you will probably have to precede the command with sudo. To start, you can display the contents of the /etc/motd file to see what is currently in there. It might help when we look at the scripts later that actually generate the text in this file. Using the less command will allow you to scroll through the text if the file is long, but it probably isn’t so we’ll use the cat command instead.

user@machine:~# cat /etc/motd
Linux machine 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 x86_64 GNU/Linux
Ubuntu 10.04 LTS

Welcome to Ubuntu!
 * Documentation:  https://help.ubuntu.com/

You will probably see information about the kernel, last login, Ubuntu version, etc. Now let’s look at the scripts that created the MOTD.

user@machine:~# ls -lah /etc/update-motd.d/
total 20K
drwxr-xr-x  2 root root 4.0K Apr 22  2010 .
drwxr-xr-x 65 root root 4.0K Jun 17 15:31 ..
-rwxr-xr-x  1 root root   57 Apr 23  2010 00-header
-rwxr-xr-x  1 root root  248 Apr 23  2010 10-help-text
-rwxr-xr-x  1 root root  261 Apr 23  2010 99-footer

All the scripts that create the MOTD are contained in the /etc/update-motd.d/ folder. Each script (text file) is preceded by a number that indicates in what order the scripts should be run. This is why the header is first (00) and the footer is last (99). Let’s take a look at the header file and see if we can match what part of the MOTD is generated by this header script.

user@machine:~# cat /etc/update-motd.d/00-header
#!/bin/sh

uname -a
printf "%s\n" "$(lsb_release -s -d)"
user@machine:~#

If you don’t know much about scripting, the very first line starts with a shebang. The shebang is the pound sign followed by the exclamation point (#!). The shebang signifies that the file is a script and should be run by a program. What follows the shebang is the path to program that should run the script. In this case, /bin/sh will interpret and run the script. Since we now know the following lines are shell commands, we can run the next command from the 00-header file via SSH and see it’s output to figure out what it does (if you don’t already know).

user@machine:~# uname -a
Linux machine 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 x86_64 GNU/Linux

The output from this command matches with the first line of the MOTD when we checked it earlier. If you’ve already guessed that output of the second command in the 00-header file will match the second line of the MOTD, then so what?! You think you’re some kind of big shot all of a sudden?!

user@machine:~# printf "%s\n" "$(lsb_release -s -d)"
Ubuntu 10.04 LTS

Good lookin out though. It does match with the second line of the MOTD. Since there are no other lines in this 00-header file, the rest of the MOTD must be generated in one of the other files in /etc/update-motd.d/. You can go through the other files and follow the same process to determine which scripts generate what text in the MOTD. If you want to edit any of the files, use nano if you’re a beginner or any other linux text editor if you’re already familiar with one.

user@machine:~# nano /etc/update-motd.d/00-header

Common commands are listed at the bottom of nano. The carrot symbol(^) stands for the Ctrl key so to exit you would hold the Ctrl and press the x key. Then you will be prompted on whether or not you want to save the changes to the file. You can also create a new script by using a text editor, just make sure to precede the name with a two digit number and a dash. Maybe you want to include a disclaimer message to users that log in via SSH.

user@machine:~# nano /etc/update-motd.d/09-disclaimer

Then add whatever text you’d like. Make sure the first line contains the shebang followed by the path to the program to interpret the script. I’ll give you an simple example that will output the text “I added a disclaimer message here which was generated from the 09-disclaimer file.” You can copy and paste (right-click the SSH window to paste or hold the Shift key and press the Insert key) the text below into your text editor and save the file.

#!/bin/sh

echo "\nI added a disclaimer message here which was generated from the 09-disclaimer file."

The echo command means to display whatever is in quotes to the screen. The \n at the beginning of the sentence means to add a new line. This new line spaces our sentence one line down from the previous header message.

Now before this newly created script will work, we need to make sure that we enable permission to execute or run the script. Without permission for the script to run, it will just be ignored and you’ll wonder why it’s not showing up.

user@machine:~# chmod 755 /etc/update-motd.d/09-disclaimer

The chmod command is used to change permissions for files and stands for change mode.  We’re not going to get into an explanation of permissions as there is just too much to cover. You can check out this link for some basic info if you’re curious.

Now the MOTD is updated each time a user logs in via SSH. If you’ve made some changes to any of the files in /etc/update-motd.d/ and want to check to make sure the scripts operate correctly and the message is displayed how you wanted, you can run the following command.

user@machine:~# run-parts /etc/update-motd.d/
Linux machine 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 x86_64 GNU/Linux
Ubuntu 10.04 LTS

I added a disclaimer message here which was generated from the 09-disclaimer file.

Welcome to Ubuntu!
 * Documentation:  https://help.ubuntu.com/

If you want to see which scripts are generating which text, you can use run the above command in verbose mode by adding the -v switch to the command.

user@machine:~# run-parts -v /etc/update-motd.d/
run-parts: executing /etc/update-motd.d//00-header
Linux machine 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 x86_64 GNU/Linux
Ubuntu 10.04 LTS
run-parts: executing /etc/update-motd.d//09-disclaimer

I added a disclaimer message here which was generated from the 09-disclaimer file.
run-parts: executing /etc/update-motd.d//10-help-text

Welcome to Ubuntu!
 * Documentation:  https://help.ubuntu.com/
run-parts: executing /etc/update-motd.d//99-footer

If you just wanted to add simple text to your MOTD, hopefully the above will help you. If you want to add more dynamic information to the MOTD using Linux commands, you might have to do some research. Any Linux command or utility that can be run from the command line and outputs text can be added to the MOTD scripts. Good luck!

DBH

Remember LightScribe technology? Never heard of it? I almost forgot too.

 

I purchased a new LightScribe Dual Layer DVD/CD burner combo and LightScribe CD-Rs  this past weekend. It was the result of a search for the cheapest spindle of CD-Rs I could find online which ended in me spending more money than I wanted. Dooped again!

 

LightScribe discs are blank on both sides of the disc. One side is silver in color like a regular CD-R and the opposite side is a Sepia color (although there are other various colors available). The silver side is used to burn data to the CD while the sepia side of the disc is able to change color when etched with a laser so that you can produce a grey-scale CD cover using your LightScribe burner. The idea is pretty cool, especially since you don’t have to buy adhesive, printable labels for your CDs and then waste expensive ink creating them. After getting sidetracked on the LightScribe topic when looking for blank CDs online, I spent a while trying to read reviews regarding the entire process. Apparently I didn’t spend long enough…

 

I liked the idea and wanted to play with the technology so I bought a drive (Samsung SH-S223L ~$30) and a spindle of CD-Rs (HP LightScribe  10036 ~$15). Today I burned three CDs which each had different CD cover art which was etched to the disc using LightScribe. Now many reviews complained about the contrast of the image etched to the disc. I saw various suggestions on how to increase the contrast or thicken lines to bolden the image and “simulate” more contrast. The drive I purchased was OEM so it did not include any software. I opted to use the Nero Cover Designer which was bundled with my Nero software. After “lightscribbling” these three CD cover images using LightScribe, I’m surprised.

 

LightScribe Example

LightScribe Example

 

Without altering any settings, the result turned out very well. The image above was the most complex of all the CD covers made and the detail is quite good. The contrast is not lacking in my opinion and the detail of facial hair and the heather sweater is surprising. The end result is well worth the investment, but getting to the result leaves something to desired…

 

The time taken to burn each one of the CD cover art weighed in around 27 minutes. Even the images with scant color and complexity still took around 25 minutes. I haven’t researched enough to determine why it only takes 2 minutes to burn the CD and 27 minutes to burn the image but I have to assume that the image is burned linearly with multiple passes to get a darker colors (although there’s a good chance I’m wrong). 27 minutes feels like lightyears when it takes less than five to actually burn the CD. Maybe it’s just the specific drive that I purchased but I suppose there’s really not much to complain about. LightScribe is novel if you have the time, but you can always rip out the sharpie and practice your penmanship if you’re in a hurry.

 

So all in all I would say there is really no downside to LightScribe if you’re in the market for a new CD/DVD burner, but it wouldn’t hurt to investigate if there are drives which can etch the CD cover art in less time.

DBH

Let me start off by showing you some screen shots of HellaHella that may help your decision over whether or not to install it.

HellaHella Login

HellaHella Login

HellaHella Main page

HellaHella Status (main)

HellaHella queue page

HellaHella Queue

HellaHella Bandwidth

HellaHella Bandwidth

HellaHella Bookmark

HellaHella Bookmark

You can find the official page for HellaHella here. You will find that the requirements are Python 2.4 or higher and Subversion. You can use aptitude to check if you currently have these installed.

user@machine:~$ aptitude search subversion
p   python-subversion                                                      - Python bindings for Subversion
p   python-subversion-dbg                                                  - Python bindings for Subversion (debug extension)
v   python2.4-subversion                                                   -
v   python2.5-subversion                                                   -
p   subversion                                                             - Advanced version control system
p   subversion-tools                                                       - Assorted tools related to Subversion

If you are unaware, the alphabetical characters preceding the package names are as follows:

  • p  -  meaning that no trace of the package exists on the system
  • c  -  meaning that the package was deleted but its configuration files remain on the system
  • i  -  meaning that the package is installed
  • v  – meaning that the package is virtual

Now, to install packages we need to be a superuser so we will need to use “sudo” before the install command:

user@machine:~$ sudo aptitude install python-subversion
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Building tag database... Done
The following NEW packages will be automatically installed:
libneon27 libsvn1 subversion
The following packages have been kept back:
bind9-host dnsutils libbind9-30 libisccc30 libisccfg30 linux-image-server linux-server
The following NEW packages will be installed:
libneon27 libsvn1 python-subversion subversion
0 packages upgraded, 4 newly installed, 0 to remove and 7 not upgraded.
Need to get 0B/1912kB of archives. After unpacking 8888kB will be used.
Do you want to continue? [Y/n/?]

This tells you that there are other packages this one depends on that need to be installed. If I’m not mistaken, this should install python’s core package if it is not installed already. We will check after this package installs. Type “y” without the quotes and press enter to install this package as well as its dependencies.

When you get the command line back type:

user@machine:~$ whereis python
python: /usr/bin/python2.5 /usr/bin/python /etc/python2.5 /etc/python /usr/lib/python2.4 /usr/lib/python2.5 /usr/lib/python2.3 /usr/local/lib/python2.5 /usr/include/python2.5 /usr/share/python /usr/share/man/man1/python.1.gz

And you should see output somewhat like what is listed above. Since HellaHella requires python2.4 or higher, we are obviously looking for the output to say python2.4, python2.5, etc. in it. If you see a blank line, you can always install it by using the same command as earlier:

user@machine:~$ sudo aptitude install python2.5

Now, when I attempted to install HellaHella, I got some grief over not having python-routes v1.7.3 installed but rather v1.7.1. So before we even give the system a chance to complain, let’s download and install Routes v1.7.3 from python’s site directly (It wasn’t in the aptitude cache).  Typing “aptitude show python-routes” without the quotes showed that the only version in cache was for v1.7.1-1). We will use wget to download this to our home directory. First, to make sure we are in the root directory on the machine, type:

user@machine:~$ cd ~

Now we can download the Routes gunzipped file by typing:

user@machine:~$ wget http://pypi.python.org/packages/source/R/Routes/Routes-1.7.3.tar.gz

Once this has finished downloading, we now have to untar the archive[d] (file). We do this with the following command:

user@machine:~$ tar xvfz Routes-1.7.3.tar.gz

If you don’t know what the options “xvfz” stand for, I will explain in a minute. You can however list the options for a program by following it with “–help.” In this instance, we would type “tar –help” without the quotes to display all of the available options for this application. In doing this, the output spans many screens. To be able to read through this properly we will type “tar –help | less” without the quotes. This will allow us to use the arrow keys to traverse through the output until we are finished, at which point you may press the “q” key to quit out of this mode.

  • x  -  extract files from an archive
  • v  -  verbosely list files processed
  • f  -  use archive file or device ARCHIVE
  • z  -  filter the archive through gzip

Now we should be able to see the directory that was made after untarring the file. We will then change directories to that folder to continue the install process.

user@machine:~$ ls
Routes-1.7.3        Routes-1.7.3.tar.gz
user@machine:~$ cd Routes-1.7.3
user@machine:~/Routes-1.7.3$ ls
dist  PKG-INFO  README  routes  Routes.egg-info  setup.cfg  setup.py

You should really read the README file. If you trust me though you can just type:

user@machine:~/Routes-1.7.3$ sudo python setup.py build

And then:

user@machine:~/Routes-1.7.3$ sudo python setup.py install

Now that Routes is installed, we can get to actually downloading and installing HellaHella. First we will download HellaHella from their site (after changing to the home directory):

user@machine:~/Routes-1.7.3$ cd ~
user@machine:~$ wget http://peak.telecommunity.com/dist/ez_setup.py

Once the setup script has been downloaded from HellaHella’s site, we will install it:

user@machine:~$ sudo python ez_setup.py -U hellahella==dev

We will then create the hella.ini which holds the config options for the program:

user@machine:~$ paster make-config hellahella hella.ini

Now we can open hella.ini to configure the options we need:

user@machine:~$ nano hella.ini

You will need to specify a username and password for access to the HellaHella web-app from the browser (this should be different from the HellaNZB username and pass). For nzb_server, you can specify 127.0.0.1 for localhost if hellanzb is running on this same machine. You will need to specify the password and port you used in the HellaNZB configuration for nzb_password and nzb_port. Lastly you can specify what IP address and port to bind the HellaHella app to under [server:main]. You can leave this as 0.0.0.0 and 5000 unless you want some special configuration but be sure to open up port 5000 on your router if you wish to access HellaHella from outside your LAN.

Hit Ctrl + o to write the file and Ctrl + x to exit the text editor. We have one more command to write before we can run HellaHella:

user@machine:~$ paster setup-app hella.ini

And now we can finally run HellaHella:

user@machine:~$ paster serve hella.ini

You should now see something like the following on the last lines of the output:

Starting server in PID 7243.
serving on 0.0.0.0:5000 view at http://127.0.0.1:5000

You should now be able to go to a web browser and type http://127.0.0.1:5000/ (or http://localhost:5000/) in the address bar and see HellaHella! If you have another machine in your lan you can open a web browser and type the IP followed by a “:5000″ without the quotes and get to it as well!

Lastly, to quit HellaHella you may press Ctrl + c on the terminal where is is running. You can also run HellaHella as a Daemon (in the background as a service) by typing “paster serve hella.ini –daemon” without the quotes instead of “paster serve hella.ini”

DBH