Custom Fog Registration menu



  • I’m having troubles getting the “quick image” to work after I’ve edited the PXE menu a bit.

    I followed this to remove some of the questions, [url]http://www.fogproject.org/wiki/index.php/Create_Custom_Fog_Registration_menu[/url]

    also removed authentication on the quick image, so you just have to type in the password i set for that menu item.

    Now when i choose “quick image” i get the error: unable to determine operating system type

    If i go and check the OS type in FOG Management its set to Windows 7, as all machines are. Have tryed a few different machines but all get the same error.

    Can upload the config files for the menu if needed.

    Using Fog 0.32 and Ubuntu 12.04.4



  • and the fog.custom.reg

    [HTML]#!/bin/sh
    . /usr/share/fog/lib/funcs.sh
    clearScreen;
    displayBanner;
    hd="";
    getHardDisk;

    setupDNS ${dns}

    sysman="";
    sysman64="";
    sysproduct="";
    sysproduct64="";
    sysversion="";
    sysversion64="";
    sysserial="";
    systype="";
    biosversion="";
    biosvendor="";
    biosdate="";
    mbman="";
    mbproductname="";
    mbversion="";
    mbserial="";
    mbasset="";
    cpuman="";
    cpuversion="";
    cpucurrent="";
    cpumax="";
    mem="";
    hdinfo="";
    caseman="";
    casever="";
    caseserial="";
    casesasset="";
    sysserial64="";
    systype64="";
    biosversion64="";
    biosvendor64="";
    biosdate64="";
    mbman64="";
    mbproductname64="";
    mbversion64="";
    mbserial64="";
    mbasset64="";
    cpuman64="";
    cpuversion64="";
    cpucurrent64="";
    cpumax64="";
    mem64="";
    hdinfo64="";
    caseman64="";
    casever64="";
    caseserial64="";
    casesasset64="";

    echo “”;
    echo “”;
    if [ -n “$hd” ]; then
    part=$hd’1’;
    echo " * Using disk device…$hd";

    echo " * Starting host registration...";
    
    mac=`ifconfig | grep HWaddr | head -n1 | base64`;
    
    exists=`wget -O - --post-data="mac=${mac}" "http://${web}service/man.hostexists.php" 2>/dev/null`
    
    if [ "$exists" = "#!ok" ]; then
    
        host="";
        imageid="";
        osid="NQ==";
        blImage="";
        blDoAD="";
       
        echo
        echo -n "    Enter the hostname of this computer: ";
        read host;
        host=`echo $host | base64`;
       
        while [ "$imageid" = "" ]
        do
            res=`wget -O - "http://${web}service/imagelisting.php" 2>/dev/null`
                                i=0
                                OLDIFS=$IFS;
                                IFS='
    

    ';
    for line in $res
    do
    i=$((i+1));
    echo $line;
    if [ “$i” = “20” ]
    then
    echo -n "Press Enter to Proceed…"
    read dummy;
    clearScreen
    i=0;
    fi
    done

                echo
                echo -n "    Enter the image ID for this computer: ";
                        read imageid; 
    
                imageid=`echo $imageid | base64`;
        done
    
        if [ "$blDoAD" = "" ]
        then
            echo
            echo -n "    Would you like to add this host to AD (using default settings)? (y/N) ";
            read tmpAd;
            blDoAD="0";
            case "$tmpAd" in
                Y | yes | y | Yes | YES )
                    blDoAD="1";
                    ;;
                [nN]*)
                    ;;
                *)
                    ;;
            esac           
        fi
    
        echo
        echo "    If you entered all the required information, ";
        echo -n "    would you like to image this computer now? (y/N) ";
        read blImage;       
       
        realdoimage="0";
       
        case "$blImage" in
            Y | yes | y | Yes | YES )
                tmp="";
                echo
                echo
                echo "    You have selected to image this host.  This";
                echo "    will destroy all current data on this computer.";
                echo "    Are you sure you wish to continue?";
                sleep 1;
                echo -n "    If so type \"fog\": ";
                read tmp;
                tmp=`echo $tmp | tr '[A-Z]' '[a-z]'`
                if [ "$tmp" = "fog" ]; then
                    echo
                    echo "    This host will reboot and imaging will start!";
                    echo
                    realdoimage="1";
                else
                    echo
                    echo "    You have NOT confirmed imaging, so we will not send an image!";
                    echo
                fi
                sleep 3;
                ;;
            [nN]*)
                ;;
            *)
                ;;
        esac
       
       
        echo
       
        echo -n " * Attempting to register host.................";
       
        res="";
        while [ "${res}" = "" ]
        do
            res=`wget -O - --post-data="mac=${mac}&advanced=1&host=${host}&imageid=${imageid}&osid=${osid}&doimage=${realdoimage}&doad=${blDoAD}" "http://${web}service/auto.register.php" 2>/dev/null`
            echo "${res}";           
            sleep 2;
        done;
       
    else
        echo " * Unable to register host for the following reasons:";
        echo "        ${exists}";
        sleep 10;
    fi
           
    doInventory;
    
    echo
    echo
    echo   
    echo " System Information";
    echo " ------------------";
    echo
    
    echo " * System Manufacturer: $sysman";
    echo " * System Product Name: $sysproduct";
    echo " * System Version: $sysversion";
    echo " * System Serial Number: $sysserial";
    echo " * Computer Form Factor: $systype";   
    
    sleep 1;
    
    echo
    echo " BIOS Information";
    echo " ----------------";
    echo
    
    echo " * BIOS Version: $biosversion";
    echo " * BIOS Vendor: $biosvendor";
    echo " * BIOS Date: $biosdate";
    
    sleep 1
    
    echo   
    echo " Motherboard Information";
    echo " -----------------------";
    echo   
    
    echo " * Motherboard Manufacturer: $mbman";
    echo " * Motherboard Product Name: $mbproductname";   
    echo " * Motherboard Product Version: $mbversion";
    echo " * Motherboard Serial Number: $mbserial";   
    echo " * Motherboard Asset Tag: $mbasset";       
    
    sleep 1   
    
    echo
    echo " CPU Information";
    echo " ---------------";
    echo   
    
    echo " * CPU Manufacturer: $cpuman";   
    echo " * CPU Version: $cpuversion";       
    echo " * CPU Current Speed: $cpucurrent";
    echo " * CPU Max Speed: $cpumax";   
    
    sleep 1       
    
    echo
    echo " Memory Information";
    echo " ------------------";
    echo   
    
    echo " * Memory: $mem";
    
    sleep 1   
    
    echo
    echo " Hard Disk Information";
    echo " ---------------------";
    echo       
    
    echo " * Hard Disk: $hdinfo";
    
    sleep 1   
    
    echo
    echo " Case Information";
    echo " ----------------";
    echo   
    
    echo " * Case Manufacturer: $caseman";   
    echo " * Case Version: $casever";
    echo " * Case Serial Number: $caseserial";
    echo " * Case Asset Number: $casesasset";
    echo
    echo
    echo
    echo
    echo       
    
    poststring="mac=${mac}&sysman=${sysman64}&sysproduct=${sysproduct64}&sysversion=${sysversion64}&sysserial=${sysserial64}&systype=${systype64}&biosversion=${biosversion64}&biosvendor=${biosvendor64}&biosdate=${biosdate64}&mbman=${mbman64}&mbproductname=${mbproductname64}&mbversion=${mbversion64}&mbserial=${mbserial64}&mbasset=${mbasset64}&cpuman=${cpuman64}&cpuversion=${cpuversion64}&cpucurrent=${cpucurrent64}&cpumax=${cpumax64}&mem=${mem64}&hdinfo=${hdinfo64}&caseman=${caseman64}&casever=${casever64}&caseserial=${caseserial64}&casesasset=${casesasset64}";
    
    
    
    echo -n " * Attempting to send inventory................";
    
    res="";
    while [ "$res" = "" ]; do
        res=`wget -O - --post-data="${poststring}" "http://${web}service/inventory.php" 2>/dev/null`
        echo "$res";
        sleep 3;
    done
    

    else
    echo “hard disk not found!”;
    fi
    sleep 10
    [/HTML]



  • Put this aside for a while, but am back to troubleshooting. Have tried using a default fog.custom.reg and fog.quickimage files with out any difference.

    Same problem on any machine, tryed to delete a host and re-add it manually or via Host Registration menu item from PXE with out any change.
    Also removing the password from the PXE menu doesn’t help.

    not sure it helps but the fog.quickimage file I’m using is:

    [HTML]#!/bin/sh
    . /usr/share/fog/lib/funcs.sh
    clearScreen;
    displayBanner;

    setupDNS ${dns}

    echo “”;
    echo “”;

    mac=ifconfig | grep HWaddr | head -n1 | cut -d' ' -f 11;

    echo -n " * Starting Quick Image…";
    hostinfo=wget -O - --post-data="mac=${mac}" "http://${web}service/hostlookupbymac.php" 2>/dev/null
    echo “Done”;

    if [ “$hostinfo” == “#!db” ]; then
    handleError “Database Error :: Unable to proceed!”;
    elif [ “$hostinfo” == “#!ih” ]; then
    handleError “Invalid Host Information.”;
    elif [ “$hostinfo” == “#!nf” ]; then
    handleError “Host not found.”;
    elif [ “$hostinfo” == “#!im” ]; then
    handleError “Invalid MAC Address.”;
    fi
    echo “”;
    echo " Host Information";
    echo " ================";
    echo -e “$hostinfo”;

    ret="";
    retry=“3”;
    while [ “$ret” == “” ] && [ “$retry” != “0” ]; do
    #echo “”;
    #echo " Enter a valid FOG username and password.";
    #echo “”;
    #echo -n " Username: ";
    #read username;
    #echo “”;
    #echo -n " Password: ";
    #stty -echo
    #read password;
    #stty echo;
    #echo “”;
    #echo “”;

    username="fog"
    password="password";
    
    user64=`echo -e $username | tr -d '\012' | base64`;
    pass64=`echo -e $password | tr -d '\012' | base64`;
    tmp=`wget -O - --post-data="mac=${mac}&username=$user64&password=$pass64" "http://${web}service/hostlookupbymac.php" 2>/dev/null`
    if [ "$tmp" == "#!ok" ]; then
        ret="1";
        echo "  * Imaging will start after a reboot.";
    elif [ "$tmp" == "#!ip" ]; then
        ret="";
        echo "  * Error: problem with image package!";
    elif [ "$tmp" == "#!ih" ]; then
        ret="";
        echo "  * Error: Invalid host id!";       
    elif [ "$tmp" == "#!il" ]; then
        ret="";
        echo "  * Error: Invalid Login! ($retry remaining)";
    else
        echo $tmp;               
    fi
    
    retry=$(( $retry - 1 ));
    

    done

    echo “”;
    echo "“
    echo " * Task Complete, restarting”;

    sleep 10
    [/HTML]


Log in to reply
 

531
Online

39008
Users

10721
Topics

101841
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.