Thursday Jul 02, 2009

And now I have a Centos VM

The reson for upgrading my Virtual BOx config is to install a Red Hat Centos image. I chose 4.7 because this seems jolly popular within the hosting community and I need a new host for my web servers. Two pieces of advice

  1. Download the x86 DVD image, I couldn't see how to use the multiple disk images with Virtual Box.
  2. It installs an SMP and uniprocessor version and grub is configured to start the SMP version as default. This thread, entitled CentOS 4.7 guest won't start, suggests that one should configure PAE/NX=on for the SMP image. This is not the default. Anyway works for me.

Now I need a manual to help through all those little differences between it and Ubuntu. Is been a couple of years since I played with Red Hat's Linux.

tags:

Monday Feb 16, 2009

A bitty week

Last week was a pretty bitty week, dominated by the need to complete some mandatory, examined web training. I have recently completed similar training in Sun's Unified Storage Products which I found useful. This one is not so focused on technology and while useful in that I learned a couple of things, I really wonder if it was a good use of my time.

Prior to getting stuck in, I made some progress on my web estate including Laconica, planet and glassfish. I got a copy of mingle running on one of my Linux images but made no progress on installing Glassfish. I have taken advice and been recommended to use the Sun installer, but I am being stubborn and want to see if I can use the Ubuntu package installer.

Mind you I got fed up with bash & sh and installed the Korn Shell. I was able to use the package manager which is cool. I was expecting that some Linux religous view, or over zealous conformance with the various licenes would prohibit its inclusion, but it works fine. Since I shall only be using it for scripts, I don't need to write a global .kshrc and install it where ever it would need to be. What broke the Camel's back? I felt I needed $(). I had been lectured by Chris Gerhard about using this syntax a while ago because it supports nesting and finally came across a case where it was needed, or at least, coding speed and my skills meant that I decided to move over to it. (It does mean that anything I write may be harder for other Linux users to adopt.) So I'll write in ksh, and port to sh.

I ended the week on Sunday at the Chichester Smith and Western, where the atmosphere, decor and music are fun and the portions enormous.

tags:

Tuesday Feb 03, 2009

Do we need private community microblogging?

Is twitter or microblogging a service that would benefit from more active community management? It would seem that the people at friendfeed seem to thinks so but the people at Laconica have produced a package that allows for the hosting of a microblogging community, which was pointed out to me by Peter Reiser and Scott Matoon.

Despite Peter Reiser’s statement (on his twitter feed at 1.41 am GMT 3rd Feb) that it installs on Solaris like a dream, I chose to install on Ubuntu Linux and there is a specific install page for Ubuntu at the Laconica site. It’s also useful to look at the >>README as it documents the pre-requisities and discusses the location of the site within the webserver's root namespace in more adult fashion than the Ubuntu install page.

Microblogging

I have written up my install notes on my snipsnap, and must try and get them adopted at the Laconica site. I have also repeated them in the [Read More] section below, but once its properly installed I made a post, changed my avatar and checked the RSS, and I did it all in a Virtual Box image.

tags:

[Read More]

Tuesday Jun 03, 2008

Python bites

I wrote my first Python program over the weekend. I very foolishly ran out space in my root filesystem on my cobalt qube. This is v. stupid and had two causes.

  • I have installed an application in the root disk volume. While this is not unusual, it has a database and its log files in the same file system. An error caused the log files to grow and burst the file system. [ So RFE the app dude, the install should offer locations for the database and logs.].
  • The OS very sensibly mailed me quite a lot that I had a problem, but it mailed it to the administrator account on the qube and while I can access this mail account remotely, I didn't; I was busy.

So I decided to write a script that mailed me on my phone (via SMS) should this happen again. (I also need to move the data files and logs to sensible places).

I would normally do this in ksh, but the qube doesn't have this, so I started in bash. I quickly discovered that my version of bash doesn't have associative (or any) arrays. It does have the string handling facilities of the ksh, but I couldn't find them; I had forgotten the syntax.

    line="/root=OK"; state=${line##\*=}; echo $state
    $ OK

actually works. NB I tried the arrays on my virtual box ubuntu 7 build, which I now use as a terminal host for the qube; I get them inside a re-sizable x-window. The arrays seem to work, but not associative arrays, so its another nail in the Qube's coffin; the Qube's bash has no arrays at all.

When I say I've written it, its not yet finished, but what I have done shows me that its a very powerful and economic language. Given that this sort of script, 90% of the code is string handling and enviromental discovery, with one command at the end of the script doing the work. I actually only use the UNIX 'df' utility and 'mail' program. I invoked the mail program via

    os.system('./despatchmail')

where 'despatchmail' is an external shell script and it means that I can publish the program without stating the destination e-mail addresses. It could also invoke mail directly if I choose. I provide the df reply via a pipe to the program. (I did this because a coding example was more easily available it could be done in a number of ways.)

I am particularly impressed with python's dictionary feature and created one to hold the previous state, one to hold the current state and one to hold the utilisations. I can then use the file system mount point name as the retrieval key for all three arrays. e.g.

   >>>states={};      # states is an empty dictionary
   >>>s="/root=OK";
   >>>states[s[:s.index('=')]]=s[s.index('=') + 1:]
     # assigns the state clause to the dictionary, the filesystem name is the index.
   >>>print states
   >>>{'/root': 'OK'}

and the real one looks like

    {'var': 'OK', 'home': 'OK', 'root': 'OK'}

and the utilisations from the df are held as

    {'var': 9, 'home': 38, 'root': 77}

N.B. The utilisation values are held as integers and its now easy enough to write a test such that if a directories utilisation is above a threshold, then set the status code to something else

    for keys in states.keys():
        if utilisations[keys] > threshold:
            states[keys]='ERROR'

the first line ensures the tests are performed for each value pair in the states dictionary object.

So I was pleased to find a decent problem to test the language out on. When I have finished it, I might publish it in full. It might be useful to others, and you might be able to point out where my COBOL trained brain is still using tricks I learned 25 years ago. I know the parser is very powerful, and hence a line of code can perform a number of function, which means that what I would expect to take several lines can usually be done in one.

tags: technology programming language python linux utility

Thursday May 01, 2008

Laptop Diaries, Goodbye to dual boot

A month and a half ago, Sun & Innotek, the authors of Virtual Box, an open source desktop virtualisation solution announced that Sun was buying them Virtual Box is a free type II virtualisation solution permitting the configuration of a number of popular x86 operating systems to act as guests and hosts. I have just today configured a Linux VM running on my Windows XP Laptop, here's how it looks, when its not full screen.

 

Dave's Ubuntu Desktop screen shot

 

I used Ubuntu 7.04 and this is how I did it. Firstly a friend cut me an ISO image on CD and I loaded it into the cd reader.

  1. I then created a VM. This has hardware virtualisation enabled, I created a new .vdi file. This must be big enough, and defaults at 8Gb. This is a limit on the file size. It does not reserve this space at install time, however if you make it too small, the install fails. The boot device order is floppy, cdrom and then hard disk. The cdrom has to be enabled in the 'settings -> CD/DVD' panel. I also defined the VM as a host of a Linux 2.6 image.
  2. I then started the VM using the virtual box control panel. This then boots a live cd of the cdrom, and I selected the 'Install' option. This then installs Ubuntu and offers you the opportunity to restart the system, i.e. the VM.
  3. I then used the update manager to update the software. It downloads, works out dependencies and then installs the new software versions. At the end of this stage, I then rebooted the VM. This took some time, over an hour and half, but I was using a wireless connection to a not very quick BT broadband line.
  4. At this point in time, it only offers 800x600 screen resolution, which is a bit pants, so, I used the VM window menu option, 'Devices -> Install Guest Additions'. This opened a nautilus window on the CD which exposes a script called "VBoxLinuxAdditions.run". I ran this from a terminal session command line in bash using root privilidge (see below). At this point, I then rebooted the VM again.
  5. I then needed to check that the xorg.config was configured correctly. In order to amend it, one needs a root user shell. Its been a couple of years since I used a Linux, so I tried to 'su' to root, but it was having none of it. A quick google found me this article this article about default passwords for the ubuntu super user. So a quick 'sudo gnome-terminal' and we're away. This artilce at forums.virtualbox.org, about guest additions, and this article details the checks and changes required of xorg.conf to permit full screen mode on a larger screen. The Toshiba M5 I am using has 1400x1050. I only had to add the additional resolutions. The device name agreements worked and the virtual devices had been inserted.

I should also thank the Adrian Kingsley-Hughes, who posted an Ubuntu 7, install walkthrough, which while not difficult, helped me debug the initial install failure.

I have downloaded some backgrounds and installed them, but it seems as I shall not be trying to build dual or triple boot solutions again; I have also got opensolaris nevada and indiana VMs. I just wish it had all been installed on  a single partition. I can run whatever OS I want on the laptop now.

tags:

Tuesday Mar 13, 2007

Acrobat 7 on Solaris

Getting a modern version of Adobe Acrobat running on a Solaris Laptop has always been difficult. Running it in a Linux Zone is now possible as shown  to me during the lunch break by Richard Jenner.

 

Acrobat 7.0 on Solaris

 

 He and Kieth Glancey were demonstrating Solaris 10, and the Brandz demonstration was just part of what they demo'd. [Screenshot 1400x1050]. Richard used Centos as his Linux implementation.

tags:  

Sunday Jan 28, 2007

Uograding Postgres on a Qube

I've been busy installing Postgres on my Cobalt Qube, running Linux. The first thing I did was to decide to install a second and newer version of the product. Despite the fact that I can see the installed version of Postgres (V6.x) is not running, you can never tell what the OS designers decided to do for database services. Here's how I did it.

[Read More]

Monday Oct 23, 2006

Laptop Diaries, tripleboot & GRUB

The time has come the Walrus said to think of many things.............like upgrading my Laptop operating systems. Frankly I'm not using the Linux partition which I never got red-carpet to work on and is still languishing at a pretty incomplete Fedora 3. My Solaris partition is running at Nevada 35, and 50 is now availalbe, and as I wrote here..., Solaris is getting better and I need to move on. I am planning to replace the Linux partition with Nexenta and have a triple boot laptop, with Windows, Nexenta and Solaris. Sadly the Solaris upgrade path is destructive so I have to safeguard my SMF for Sybase (more coming soon) and a sekrit TCL project.

The prework required is based on the fact that the MBR points to the Linux grub menu, which needs to be changed; I propose to change the Linux partition for Nexenta. An additional problem is that the Solaris GRUB instance does not point at the Linux partition at all. With help from Big Admin, Derek Crudington & Mike Ramchand, I can now document the following facts.

The Linux grub menu /boot/grub/menu.lst is accurate. Take the Linux lines and copy them to the Solaris copy of menu.lst, which is in the same place. (The exact syntactal compatability between Solaris' GRUB and the Linux GRAB implementations took me several hours to discover). My missing Linux lines were

Title Fedora Core (2.6.13-1.1532_FC4)
    root (hd0,4)
    kernel /vmlinuz-2.6.13-1.1532_FC4 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
    initrd /initrd-2.6.13-1.1532_FC4.img

appending the word 'single' to the kernel line gives us a single user boot option, obviously, best change the title. The accuracy of the partition definition can be confirmed using the linux command fdisk -l. (The solaris programs prtvtoc & format perform this function, don't use fdisk on Solaris; the fdisk flags are different.)

So having a good Solaris GRUB menu, I need to change the MBR to point at the Solaris partition. Here's where BigAdmin although some material their is a bit long in the tooth, and Derek come in, his blog has a GRUB category and you can find an article called Solaris 11 GRUB, which documents the required syntax below.

    b# installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0d0s0

Before running the command I checked the disk (i.e. the final argument ) using df -k.

I now have a triple boot system, S11 Nevada 35, Red Hat Linux Fedora 3½, and Windows XP.

tags:

Thursday Sep 28, 2006

Hatsoff to UNIX

Chris Ratcliffe spoke today and stated that Red Hat are about to drop enterprise server R3, and this is an opportunity for their users. I didn't know Solaris 10 supports more hardware and more applications than Red Hat and that the transition from R3 to R4 is not necessarily easy, and that adopting Solaris may be as easy. Sun has more to say about this on it's web site.

tags:

Tuesday Jul 25, 2006

My personal planet

I now have an instance of the Planet RSS feed aggregator running on my Qube under Linux 2.2 which is aggregating my Snipsnap and del.icio.us feeds, or would be if I hadn't discovered a misconfiguration that makes it difficult to blog on my snipsnap. (This seems to be a windows firewall problem!)

How do I do this?

Planet requires Python(v2,2 or better). So I downloaded the most recent Python (2.4) from and tried to compile it into an install directory, this failed because my TCL library was too old, and I couldn't replace this with an up to date version; the ActiveState TCL distribution complained about my libc's age and version, and with Linux, that's that. For more on this unfortunate state of affairs, check my personal wiki here.... Fortunately I have a friend (Chris Gerhard) who installed Python 2.x a long time ago on a Qube and I borrowed his installation directory, copied it to my system and ran a make install. The install points at /usr/local/bin which means I can use a ${PATH} variable to control if my new Python V2.x or old Python V1.x is invoked. it claims to be V2.4 so I have no idea how it works, but I then downloaded the Planet code from its home site, http://www.planetplanet.org/, which I'd like to say is very simple but that wouldn't be true for me since I don't read Python, so with a bit of trial and error, this is what to do -

  1. I created a user called planet and ensured that $PATH & $MANPATH were set appropriately. i.e. to invoke my new version of python and then unpacked the archive into the user home directory. A sub-directory to hold the run time logs was created and also a sub-directory to hold files for a specific planet instance. (./Logs & ${HOME}/${PLANETNAME}.
  2. I then copied the fancy templates into ${HOME}/${PLANETNAME}, together with planet.css.
  3. I created a target directory which needs to be in the web server's file system. I chose ${WEBSERVER_ROOT}/planet/${PLANETNAME} and placed the image files into the target directory. The image files include the planet logo, the feed format badges and the face icon(s). (The face icon is exactly that, it allows the logoing of articles in the HTML version of the feed and the authors suggest a picture of the article author). Ensure the planet user has write permissions to this directory
  4. I then created the config file, I used explicit file and file directory names and placed the config file in the planet instance directory i.e. ${HOME}/${PLANETNAME}. The config file references a cache directory which planet uses. Planet uses a cache directory, this needs to be created and referenced in the config.ini. I placed this in the /var file system.
  5. The planet script, planet.py needs to be run occasionally. I chose to use cron to do this and wrote a script to ensure that all output was kept and written to a log file. (I also wrote a second script to keep these under control). I run planet every 15 minutes which given there's only one author is frequent enough. The log tidy up I run once/day. These jobs run as user planet, which is`why the planet user needs write privilidges to the target directory.
  6. I amended the index.html.tmpl and the planet.css files to get a colour conformity with the rest of my web space (except this blog) and discovered that the atom logo is missing, so I went and got myself one of those. Most of the amendments I made are to the sidebar. My planet is here..., PlanetCycling is here... which has a vanilla html page. I changed H1 to get my green banner and left justification.

Here's my H1 rule, which is used to implement the page banner -

h1 {
margin-top: 0px;
padding-top: 20px;

background-color: #690;
border: thin dotted #808080;

font-family: "Bitstream Vera Sans", sans-serif; font-weight: normal;
letter-spacing: -2px;
text-transform: lowercase;
text-align: right;
color: white;
}

Hope this helps!

tags:

Sunday Jan 29, 2006

Qube Diaries!

I've finally got an instance of Snipsnap running on my Qube and I've mucked around with the look and feel to give it my "Green Robot" look which my home site also has, if you like it, you can go there and download it.

 

screen shot of my snipsnap front page

 

I have used the .war version of snipsnap and have thus had to install Java, tomcat and snipsnap; the Qube's Linux does not come with any of these! Once I got the downloads to work correctly, this is fairly simple.

Java went on easily as you'd expect. I just followed the installation instructions at http://java.sun.com/. I took the full J2EE SDK pack for Linux. With tomcat, I took the binary distribution (V4.1) for Linux from the apache tomcat site. (I can't rember why we only took V4.1, there was a reason; it might be because of the oldness of the linux distro, or it might be Snipsnap thing.) Anyway the install is just a cp [copy] command. I then wrote a rc.d script for tomcat which needs to know where the ${JAVA_HOME} directory is but otherwise I have invoked the start and stop scripts distributed with tomcat. (They're in the ./bin directory). I also had to dick around with the tomcat-users.xml file. Installing Snipsnap was even simpler, with the .war version, you just need to upload this using the tomcat manager screen. When I uploaded the .war to tomcat, I had renamed the .war to snipsnap.war. (I think this is where it inherits its namespace root from, but anyway, you don't want all that version stuff leaking into the database structure.) All that's left then is amending the CSS to develop a new theme. Again Snipsnap's documentation is quite good and my only problem was my own CSS coding.

tags:

Sunday Jan 22, 2006

Uploading to the Qube

I have now used Google/linux to find unix2dos and dos2unix .rpm files and installed them using

rpm --install

i.e. they were missing from the Cobalt build and somehow the ftp client I was using wasn't handling the conversions, so this should make editing my shell scripts using notepad &/or context on windows easier.

As I implied last month I have got to get to grips with the bourne shell again; I'm holding off on the Korn Shell. These editing techniques may help

I have also got to grips with using ftp/wget on the Qube. Its a lot quicker than using http and quicker than using other system as web clients for the fetch.

tags:

Tuesday Jan 03, 2006

Dave's Adventures in Qubeland; shells and boot configuration

Isn't chkconfig a good idea. The first time I came across it, it seemed to be just a status and service requirment function. (See also what I said last time here...). I used it via GNOME and Red Hat's service manager,and Red Hat's documents are here.... While working on my Qube I have been pointed at it again by ddclient (see also my blog here... about DDNS), I've come to the conclusion that its really rather good. Here is Linux About's link and here is the SGI link.

This works with rc start|stop scripts. Actually they encourage a "status" branch, and also a restart branch aka "stop; start". All you need is a configuration line and a description line in the script. Immediately below is the code from ddclient, the first line states the run levels for which this program is required , the start level priority and the stop level priority. (This contrasts with Solaris SMF, which does not state priority as scalar but as relative).

# chkconfig: 2345 65 35
# description: ddclient provides support for updating dynamic DNS services.

Copy the rc file to the /etc/rc.d/init.d directory, make the directory current and then issue the chkconfig -add command and the rc.d links will be created for you. i.e. the first string on the chkconfig: line defines the run levels at which the program will run

I have added the following (final two) lines to the opensshd script to permit chkconfig to work with it.

#!/bin/sh
# Donated code that was put under PD license.
#
# Stripped PRNGd out of it for the time being.
# Inserted by Dave Levy
# chkconfig: 2345 92 95
# description: This is the secureshell daemon

Running chkconfig --add ${opensshd_script_name} ensure that the links in the rc.d directory structure are created. This is neat; I've forgotten where to put it, and I don't have to muck around with remembering. Frankly I added the last two lines from the above to my rc script using vi, but it would be nice to automate it.

An additional problem however, is that the openssh project distributes the rc script with an incorrect directory for the shell. For Cobalt (and maybe other) Linux(es), you'll need to substiture the first line with #!/bin/sh, the code string below fixes this,

cat ${opensshd_script_name} | sed -e "s?\\#\\!/sbin/sh?\\#\\!/bin/sh?g" \\
    >> ${opensshd_script_name}.${script_ver}

We might want some version control code. The code above assumes that ${opensshd_script_name} and ${script_ver} have been set appropriately. I have considered using ls -t, head -1 and cut to create a version control semantic but the original script file has no version control suffix, and I am expecting to create a Linux variant. So

if [ `unname` -eq 'Linux' ]
then
  script_ver=Linux
# Change the shell interpreter
  cat ${opensshd_script_name} | sed -e "s?\\#\\!/sbin/sh?\\#\\!/bin/sh?g" \\
    >> ${opensshd_script_name}.${script_ver}
fi

This will create a file called opensshd.init.in.Linux. However, once you get started, there are so many ways to do this.-

exec_shell=`which sh`

and use ${exec_shell} as the substitution string in the sed command or maybe best of all; this works for all UNIXes without a /sbin/sh, and tightly aligns the implemented execution shell with its existence

if [ ! -x /sbin/sh ]&& [ -x /bin/sh ]
then
# Change the shell interpreter
  cat ${opensshd_script_name} | sed -e "s?\\#\\!/sbin/sh?\\#\\!/bin/sh?g" \\
    >> ${opensshd_script_name}.${script_ver}
fi

Maybe this is all too complicated, why they've selected /sbin/sh as the execution shell I have no idea, surely all the UNIXes on the port list have a /bin/sh and its guaranteed to be available at run level 1. Perhaps, they should just change the shell interpreter in the rc script source (, and add the chkconfig comment controls at the same time).

I've copied this article to the opensshd developer list, although while I hope they take notice of the shell issue, chkconfig is a Linux thing and hence many other UNIXes will have problems with it. So writing an if Linux test is a bit more complex than I have suggested above and they may feel that this is not a porting issue.

tags:

About

DaveLevy

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today