User:Asc: Difference between revisions

From FAIWiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 3: Line 3:
== Hook mkboot ==
== Hook mkboot ==


<nowiki>
<pre>
#! /bin/bash  
#! /bin/bash  
# hook mkboot for fai.
# hook mkboot for fai.
Line 73: Line 73:


# End of hook chboot.DEFAULT
# End of hook chboot.DEFAULT
</nowiki>
</pre>

Revision as of 19:44, 19 May 2006

Installing with PXE and FAI MAC Address based.

Hook mkboot

#! /bin/bash 
# hook mkboot for fai.
# If you start this script on a fai client it copy, create or delete a pxe bootfile. It use the ethernet mac
# address of the fai client. 

cd /tmp 
TFTPCONFDIR="/boot/fai/pxelinux.cfg"
SSHUSER=fai
TFTPSERVER=faiserver
# TFTPSERVER=nsc
# TFTPCONFDIR="/var/lib/tftpboot/pxelinux.cfg"
# SSHUSER=cardtest

HOSTNAME="default"
if [ "$HOST" != "" ]; then HOSTNAME=$HOST; fi ;
BOOTMAC=`/sbin/ifconfig "$netdevices_up" |grep HWaddr|cut -d " " -f11|tr ':' '-'|tr '[:upper:]' '[:lower:]'`
BOOTMAC="01-"$BOOTMAC
echo Next Boot will boot or install: $HOSTNAME on $BOOTMAC.
echo "!!! OK - Press ctrl-c to interrupt FAI and to get a shell"

case $HOSTNAME in
    disable)
        ssh $SSHUSER@$TFTPSERVER "mv $TFTPCONFDIR/$BOOTMAC $TFTPCONFDIR/$BOOTMAC\.disable" ;;
    local)
        ssh $SSHUSER@$TFTPSERVER "mv $TFTPCONFDIR/$BOOTMAC $TFTPCONFDIR/$BOOTMAC\.disable ; cp $TFTPCONFDIR/local $TFTPCONFDIR/$BOOTMAC " ;;
    enable)
        ssh $SSHUSER@$TFTPSERVER "mv $TFTPCONFDIR/$BOOTMAC\.disable $TFTPCONFDIR/$BOOTMAC" ;;
    remove)
        ssh $SSHUSER@$TFTPSERVER "rm $TFTPCONFDIR/$BOOTMAC" ;;
    *)
        ssh $SSHUSER@$TFTPSERVER "cp $TFTPCONFDIR/$HOSTNAME $TFTPCONFDIR/$BOOTMAC" ;;
esac

task_faiend

# End of mkboot

Hook chboot.default

#! /bin/sh 
# hook for fai. Set boot to local 
set -xv

SCRIPTNAME=`basename $0`
skiptask=`echo $SCRIPTNAME | sed "s/\..*$//"`

cd /tmp 
TFTPCONFDIR="/boot/fai/pxelinux.cfg"
SSHUSER=fai
TFTPSERVER=faiserver
# TFTPCONFDIR="/var/lib/tftpboot/pxelinux.cfg"
# SSHUSER=cardtest
# TFTPSERVER=nsc
HOSTNAME="local"

BOOTMAC=`/sbin/ifconfig "$netdevices_up" |grep HWaddr|cut -d " " -f11|tr ':' '-'|tr '[:upper:]' '[:lower:]'`
BOOTMAC="01-"$BOOTMAC
echo Next Boot will boot or install: $HOSTNAME on $BOOTMAC.

case $HOSTNAME in
    local)
        ssh $SSHUSER@$TFTPSERVER "mv $TFTPCONFDIR/$BOOTMAC $TFTPCONFDIR/$BOOTMAC\.disable ; cp $TFTPCONFDIR/local $TFTPCONFDIR/$BOOTMAC " ;;
    *)
        ssh $SSHUSER@$TFTPSERVER "cp $TFTPCONFDIR/$HOSTNAME $TFTPCONFDIR/$BOOTMAC" ;;
esac

skiptask $skiptask 

# End of hook chboot.DEFAULT