Hi all,

with my last patch I've added also the 'rebooted' status to report when
a client starts successfully with the image deployed (I've already
talked about that with Bernard...).

This is not a "mandatory" state, I mean no error will be reported if a
client doesn't reach the rebooted state, but if a user wants to have
also this information, something must be put in the init scripts of the
image. IMHO the best approach is to use the rc.local (or all the
equivalent files in other distributions) adding the commands to report a
message to the monitor deamon on the image server.

To do that I've successfully used the attached post-install script. The
script adds a command in rc.local (and some equivalent files). It works
well with SuSE and should work also with Red-Hat (don't know if it's ok
also with Debian).

Maybe we could add these commands directly into the autoinstall script,
but only after some good tests.

Thoughts are welcome...

Cheers,
-Andrea
#!/bin/sh

# netcat timeout in seconds
TIMEOUT=30

send_monitor_msg() {
    if [ -z $MONITOR_SERVER ]; then
        return
    fi
    if [ -z $MONITOR_PORT ]; then
        MONITOR_PORT=8181
    fi

    # Remove special field separator from the message.
    msg=`echo "$@" | sed 's/:/\\\x3a/g'`

    # Get the client mac address.
    if [ -z "$mac" ]; then
        mac=`ifconfig $DEVICE 2>/dev/null | sed -ne "s/.*HWaddr //p" | sed "s/ 
//g" | sed s/:/./g`
    fi

    # Report the message to the monitor server.
    send_msg=`echo "mac=$mac:ip=$IPADDR:host=$HOSTNAME:$msg"`

    # Find netcat binary
    netcat=`which netcat || which nc`
    [ -z $netcat ] && return

    cmd="echo \"$send_msg\" | $netcat -w $TIMEOUT $MONITOR_SERVER $MONITOR_PORT"
    for f in /etc/rc.local /etc/rc.d/rc.local /etc/init.d/rc.local 
/etc/init.d/after.local; do
        echo $cmd >> $f
    done
}

# Load installation variables.
[ -e /tmp/post-install/variables.txt ] && . /tmp/post-install/variables.txt

# Write commands to send status and final message to the monitord.
send_monitor_msg "log=Client successfully rebooted."
send_monitor_msg "status=102"

_______________________________________________
Sisuite-devel mailing list
Sisuite-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sisuite-devel

Reply via email to