NSLU2-Linux
view · edit · print · history

HowTo.IdentifyUnslungVersion History

Hide minor edits - Show changes to markup

June 26, 2007, at 10:20 AM by tlhackque -- How to identify unslung version in scripts
Added lines 1-55:

In startup scripts, it's sometimes useful/necessary to know which version of unslung is running. There are annoying differences between versions, such as the (linksys-induced) change in device naming that can be painful when phasing over to a new version, and using one set of configuration files.

I've used the following shell script snippet to accomplish this.; hopefully somone else will find it useful

Also, although I run multiple devices, the startup scripts and software load is identical for them all. To give each device its personality, I have a S00configure script that turns services on/off and softlinks the right configuration files. S00configure decides what to do based on the IP address configured in the linksys GUI. I've included the code snipped that does that as well.

(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 
if [ -e /etc/motd ]; then
SLUGV="`grep 'Unslung V.' /etc/motd | sed -e 's|.*-uNSLUng-\([0-9][0-9]*\.[0-9][0-9]*.*\)-.*$|\1|'`"
SLUGVMAJ="`/bin/echo $SLUGV | sed -e 's/\(.*\)\..*/\1/'`"
SLUGVMIN="`/bin/echo $SLUGV | sed -e 's/.*\.\(.*\)/\1/'`"
else
SLUGVMAJ="5"
SLUGVMIN="5"
fi
#
if [ "`mount | grep '/dev/sda1 on / '`" = "" ]; then
    if [ "`mount | grep '/dev/sdb1 on / '`" = "" ]; then
#       Not running from disk, don't touch flash
#	BTDEV=
#       BTDEV='ramdisk'
        exit 1
    else
	BTFDEV="/dev/sdb1"
        if [ $SLUGVMAJ -ge 6 ]; then
            BTDEV='hdd'
        else
            BTDEV='flash'
        fi
    fi
else
    BTFDEV="/dev/sda1"
    if [ $SLUGVMAJ -ge 6 ]; then
        BTDEV='flash'
    else
        BTDEV='hdd'
    fi
fi

#
# Identify this host & determine configuration
#
IPADDR="`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-ixp0 | sed -e's/IPADDR=//'`"
# - 192.168.SUBNET.HOST
BASE="`/bin/echo $IPADDR | sed -e's/\.[0-9]*$//'`"
# - SUBNET
SUBNET="`/bin/echo $BASE | sed -e's/^[0-9]*\.[0-9]*\.//'`"
# - HOST
HOST="`/bin/echo $IPADDR | sed -e's/^.*\.\([0-9]*\)$/\1/'`"


(:tableend:)

view · edit · print · history · Last edited by tlhackque.
Originally by tlhackque.
Page last modified on June 26, 2007, at 10:20 AM