Postscript Not Running, How to Test?



  • Server
    • FOG Version: 1.4.4
    • OS: Ubuntu 16.04
    Client
    • Service Version:
    • OS:
    Description

    Setting up Postdownload scripts to put drivers on universal image. Worked with @george1421 but got stuck when the script would not run. I was not able to update FOG as we were in a huge deployment that is over with and I want to take a wack at this again.

    How do I test to see the Postscript run? Here are the scripts

    0_1500560078388_d5e6f383-0b3d-4a86-b862-b9f3b78c8b41-image.png

    fog.postdownload

    #!/bin/sh
    ## This file serves as a starting point to call your custom postimaging scripts.
    ## <SCRIPTNAME> should be changed to the script you're planning to use.
    ## Syntax of post download scripts are
    #. ${postdownpath}<SCRIPTNAME>
    
    echo "starting postdownload"; 
    
    . /usr/share/fog/lib/funcs.sh
    [[ -z $postdownpath ]] && postdownpath="/images/postdownloadscripts/"
    case $osid in
        5|6|7|9)
            clear
            [[ ! -d /ntfs ]] && mkdir -p /ntfs
            getHardDisk
            if [[ -z $hd ]]; then
                handleError "Could not find hdd to use"
            fi
            getPartitions $hd
            for part in $parts; do
                umount /ntfs >/dev/null 2>&1
                fsTypeSetting "$part"
                echo  "$part"
                case $fstype in
                    ntfs)
                        dots "Testing partition $part"
                        ntfs-3g -o force,rw $part /ntfs
                        ntfsstatus="$?"
                        if [[ ! $ntfsstatus -eq 0 ]]; then
                            echo "Skipped"
                            continue
                        fi
                        if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then
                            echo "Not found"
                            umount /ntfs >/dev/null 2>&1
                            continue
                        fi
                        echo "Success"
                        break
                        ;;
                    *)
                        echo " * Partition $part not NTFS filesystem"
                        ;;
                esac
            done
            if [[ ! $ntfsstatus -eq 0 ]]; then
                echo "Failed"
                debugPause
                handleError "Failed to mount $part ($0)\n    Args: $*"
            fi
            echo "Done"
            debugPause
            # . ${postdownpath}fog.log
            . ${postdownpath}fog.drivers
            # . ${postdownpath}fog.ad
            umount /ntfs
            ;;
        *)
            echo "Non-Windows Deployment"
            debugPause
            return
            ;;
    esac
    

    fog.drivers

    #!/bin/bash
    ceol=`tput el`;
    manu=`dmidecode -s system-manufacturer`;
    case $manu in
        [Ll][Ee][Nn][Oo][Vv][Oo])
            machine=$(dmidecode -s system-version)
            ;;
        *[Dd][Ee][Ll][Ll]*)
            machine=$(dmidecode -s system-product-name) #pruduct is typo, just realized sorry :(
            ;;
        *)
            machine=$(dmidecode -s system-product-name) # Technically, we can remove the dell one as it's the "default"
            ;;
    esac
    [[ -z $machine ]] && return #assuming you want it to break if it is not lenovo or dell?
    machine="${machine%"${machine##*[![:space:]]}"}" #Removes Trailing Spaces
    
    #############################################
    # Quick hack to find out if the installed OS image is a x86 or x64
    system64="/ntfs/Windows/SysWOW64/regedit.exe" # sloppy detect if 64bit or not
    [[ ! -f $system64 ]] && arch="x86" || arch="x64"
    
    #############################################
    #this section has been updated to bring the osn names in line
    # with how the Dell CABs are defined
    case $osid in
        5) osn="win7" ;;
        6) osn="win8" ;;
        7) osn="win8.1" ;;
        9) osn="win10" ;;
    esac
    
    #############################################
    dots "Preparing Drivers"
    # below creates local folder on imaged pc
    # this can be anywhere you want just remember
    # to make sure it matches throughout! (case IS important here)
    clientdriverpath="/ntfs/Windows/DRV"
    remotedriverpath="/images/drivers/$machine/$osn/$arch"
    
    [[ ! -d $clientdriverpath ]] && mkdir -p "$clientdriverpath" >/dev/null 2>&1
    echo -n "In Progress"
    
    #there's 3 ways you could handle this,
    #driver cab file, extracted driver files or both
    #so on the server put extracted driver files to match below folder tree
    #i.e. Model Latitude E5410, Windows 7 x86 image would be:
    #/fog/Drivers/Latitude E5410/win7/x86
    
    echo "System breakpoint";
    debugPause;
    
    rsync -aqz "$remotedriverpath" "$clientdriverpath" >/dev/null 2>&1
    [[ ! $? -eq 0 ]] && handleError "Failed to download driver information for [$machine/$osn/$arch]"
    
    echo "End driver copy";
    debugPause;
    
    #this next bit adds driver location on pc to devicepath in registry (so sysprep uses it to reference)
    # remember to make devicepath= match the path you've used locally
    #also do not remove %SystemRoot%\inf
    #and to add more locations just use ; in between each location
    
    regfile="/ntfs/Windows/System32/config/SOFTWARE"
    key="\Microsoft\Windows\CurrentVersion\DevicePath"
    devpath="%SystemRoot%\DRV;%SystemRoot%\inf;";
    reged -e "$regfile" &>/dev/null <<EOFREG
    ed $key
    $devpath
    q
    y
    EOFREG
    echo -e "\b\b\b\b\b\b\b\b\b\b\b${ceol}Done"; # this just removes "In Progress and replaces it with done :-)"
    
    
    


  • @george1421 I copied what your pasted and changed the permissions. Maybe it was the permissions to fog:root that did it?


  • Moderator

    @UWPVIOLATOR So now it magically works and it didn’t before? What changed?? If nothing then I don’t believe it. The only thing I added was comments to know where it was in the script.



  • @george1421 This now works. I will now work on putting drivers in the folders and testing it out. SO EXCITED to start working on a Golden image.


  • Moderator

    #!/bin/bash
    ceol=`tput el`;
    manu=`dmidecode -s system-manufacturer`;
    case $manu in
        [Ll][Ee][Nn][Oo][Vv][Oo])
            machine=$(dmidecode -s system-version)
            ;;
        *[Dd][Ee][Ll][Ll]*)
            machine=$(dmidecode -s system-product-name) #pruduct is typo, just realized sorry :(
            ;;
        *)
            machine=$(dmidecode -s system-product-name) # Technically, we can remove the dell one as it's the "default"
            ;;
    esac
    [[ -z $machine ]] && return #assuming you want it to break if it is not lenovo or dell?
    machine="${machine%"${machine##*[![:space:]]}"}" #Removes Trailing Spaces
    
    echo "Debug found ${machine}";
    
    #############################################
    # Quick hack to find out if the installed OS image is a x86 or x64
    system64="/ntfs/Windows/SysWOW64/regedit.exe" # sloppy detect if 64bit or not
    [[ ! -f $system64 ]] && arch="x86" || arch="x64"
    
    echo "${arch} was detected";
    #############################################
    #this section has been updated to bring the osn names in line
    # with how the Dell CABs are defined
    case $osid in
        5) osn="win7" ;;
        6) osn="win8" ;;
        7) osn="win8.1" ;;
        9) osn="win10" ;;
    esac
    
    #############################################
    dots "Preparing Drivers"
    # below creates local folder on imaged pc
    # this can be anywhere you want just remember
    # to make sure it matches throughout! (case IS important here)
    clientdriverpath="/ntfs/Windows/DRV"
    remotedriverpath="/images/drivers/$machine/$osn/$arch"
    
    echo "setting client path";
    [[ ! -d $clientdriverpath ]] && mkdir -p "$clientdriverpath" >/dev/null 2>&1
    echo -n "In Progress"
    
    #there's 3 ways you could handle this,
    #driver cab file, extracted driver files or both
    #so on the server put extracted driver files to match below folder tree
    #i.e. Model Latitude E5410, Windows 7 x86 image would be:
    #/fog/Drivers/Latitude E5410/win7/x86
    
    echo "System breakpoint";
    debugPause;
    
    rsync -aqz "$remotedriverpath" "$clientdriverpath" >/dev/null 2>&1
    [[ ! $? -eq 0 ]] && handleError "Failed to download driver information for [$machine/$osn/$arch]"
    
    echo "End driver copy";
    debugPause;
    
    #this next bit adds driver location on pc to devicepath in registry (so sysprep uses it to reference)
    # remember to make devicepath= match the path you've used locally
    #also do not remove %SystemRoot%\inf
    #and to add more locations just use ; in between each location
    
    regfile="/ntfs/Windows/System32/config/SOFTWARE"
    key="\Microsoft\Windows\CurrentVersion\DevicePath"
    devpath="%SystemRoot%\DRV;%SystemRoot%\inf;";
    reged -e "$regfile" &>/dev/null <<EOFREG
    ed $key
    $devpath
    q
    y
    EOFREG
    echo -e "\b\b\b\b\b\b\b\b\b\b\b${ceol}Done"; # this just removes "In Progress and replaces it with done :-)"
    

  • Moderator

    you could add breakpoints into the scripts so you can step through them. The script will only pause when you are in debug mode. Something like this:

    #!/bin/sh
    ## This file serves as a starting point to call your custom postimaging scripts.
    ## <SCRIPTNAME> should be changed to the script you're planning to use.
    ## Syntax of post download scripts are
    #. ${postdownpath}<SCRIPTNAME>
    
    echo "starting postdownload"; 
    
    . /usr/share/fog/lib/funcs.sh
    [[ -z $postdownpath ]] && postdownpath="/images/postdownloadscripts/"
    case $osid in
        5|6|7|9)
            clear
            [[ ! -d /ntfs ]] && mkdir -p /ntfs
            getHardDisk
            if [[ -z $hd ]]; then
                handleError "Could not find hdd to use"
            fi
            getPartitions $hd
            for part in $parts; do
                umount /ntfs >/dev/null 2>&1
                fsTypeSetting "$part"
                echo  "$part"
                case $fstype in
                    ntfs)
                        dots "Testing partition $part"
                        ntfs-3g -o force,rw $part /ntfs
                        ntfsstatus="$?"
                        if [[ ! $ntfsstatus -eq 0 ]]; then
                            echo "Skipped"
                            continue
                        fi
                        if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then
                            echo "Not found"
                            umount /ntfs >/dev/null 2>&1
                            continue
                        fi
                        echo "Success"
                        break
                        ;;
                    *)
                        echo " * Partition $part not NTFS filesystem"
                        ;;
                esac
            done
            if [[ ! $ntfsstatus -eq 0 ]]; then
                echo "Failed"
                debugPause
                handleError "Failed to mount $part ($0)\n    Args: $*"
            fi
            echo "Done, fixing to load the drivers"
            debugPause
            # . ${postdownpath}fog.log
            . ${postdownpath}fog.drivers
            # . ${postdownpath}fog.ad
            umount /ntfs
            ;;
        *)
            echo "Non-Windows Deployment"
            debugPause
            return
            ;;
    esac
    

Log in to reply
 

468
Online

39.3k
Users

11.0k
Topics

104.5k
Posts

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