Monday, October 25, 2010

Customizing Ubuntu's SSH MOTD

Ubuntu_10
I recently updated my Ubuntu server from 10.04 LTS to 10.10 and towards the end of the update process a prompt is displayed requesting for removal of obsolete packages with the options yes/no/details. I decided to check the details screen and accidentally exited, killing the installer and not completing the removal of these packages.  (you can resume this with apt-get...)

Since this abrupt exit of my update process, my SSH MOTD (message of the day) which, by default displays the landscape sysinfo and available updates was static. Now every time I would SSH into the server, the login sysinfo was always the same and it showed that I had 311 updates that running and apt-get update then upgrade would yield no such update.  It also kept telling me that an update was required even though a reboot file was not present in:

/var/run/reboot-required

There are a couple of files that need to be changed in order to correct this static message. The first, which you should not edit but can clear since it is overwritten is located at:

/etc/motd

This file is updated with the MOTD info but removal of anything here will simply get rewritten with  updated infomation and anything located in the "tail" file.   Editing the MOTD tail will append the info pushed to /etc/motd.  Upon editing:

/etc/motd.tail

In my case the /etc/motd.tail contained the same static message that I was seeing in my SSH session. Clearing this or adding your own custom message will now display your correct landscape sysinfo and you new custom "tail" content. 

Note - If you clear the tail and reboot and immediately log in via SSH, you might receive a message saying "System information disabled due to load higher than 1" so wait about 10 minutes before logging in to see if you new MOTD will display correctly.  

You can also display the same welcome landscape sysinfo by running he following command:

/usr/bin/landscape-sysinfo

 

UPDATE:

Another thing I noticed is that my update-notifier module has somehow been removed so if you are noticing that your update notification from MOTD is not showing up, ensure that update-notifier in installed.

Saturday, October 2, 2010

Web App Navigation with Apache Aliases

Apache_software_foundation_logo_3074
This past week I installed ThinkUp, the open source creation by Gina Trapani, sponsored by Expert Labs and used by the White House to get statistics from various social networks like Twitter and Facebook.  The web application is very easy to install due to the nice web installer interface.  If you are interested in installing it yourself, you can follow the instructions here.

All the ThinkUp web app needed was to be dropped in a folder accessable from your website, given write access and have an empty mysql database and user to specify for the setup.  The easy way would be to create a folder in your root directory so you could access it by going to:

http://yourdomainname.com/webapp

In my case my Apache root is set to my StatusNet instance in my www root (ie. /var/www/statusnet) and I didn't want to place the ThinkUp app folder in my "statusnet" folder due to it messing with my upgrade workflow for StatusNet.

I opted to create a folder in my www root for Thinkup (/var/www/thinkupfolder) but since Apache's root was set to /var/www/statusnet, I needed to create a shortcut to this location. To do this I used an alias.  With your favorite editor edit:

/etc/apache2/sites-available/default

Add the following:

Alias /webapp /var/www/webapp/
<Directory /var/www/webapp>
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

You can visit Apache's site to learn how to restrict access and add other controls as well. Now you can keep your web apps separate but still access them from your domain root as a sub directory! ~Lou