fog.drivers script will not run correctly in postdownloadscripts



  • Server
    • FOG Version: 1.3.0-RC-16
    • OS: Debian 8 ‘jessie’
    Client
    • Service Version: v0.11.5
    • OS: Windows 7
    Description

    We’re trying to get a master image made and using lots of sources on the forum, we found a script here:

    #!/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
    system64="/ntfs/Windows/SysWOW64/regedit.exe" # sloppy detect if 64bit or not
    [[! -f $system64]] && setarch="x86" || setarch="x64"
    #############################################
    #this is not section necessary needed, it's just to make the path "human readable"
    #rather than using osid for filepath
    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!
    clientdriverpath="/ntfs/Windows/DRV"
    remotedriverpath="/images/drivers/$osn/$machine"
    [[! -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/Win7/Latitude E5410/x86
    rsync -aqz "$remotedriverpath" "$clientdriverpath" >/dev/null 2>&1
    [[! $? -eq 0]] && handleError "Failed to download driver information"
    
    #if you wanted to use driver.cab use this line below.
    #i.e. /fog/Drivers/Win7/Latitude E5410/E5410-Win7-A07-KTT4G.CAB
    #cabextract -d "$clientdriverpath" "$remotedriverpath/*.CAB" >/dev/null 2>&1
    
    #if you wanted to mix both cab and extracted use these:
    #rsync -aqz --exclude='*.CAB' "$remotedriverpath" "$clientdriverpath" >/dev/null 2>&1
    #[[! $? -eq 0]] && handleError "Failed to sync cab and non-cab drivers"
    #cabextract -d "$clientdriverpath" "$remotedriverpath/*.CAB" >/dev/null 2>&1
    #[[! $? -eq 0]] && handleError "Failed to extract cab files"
    
    #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%\inf;%SystemRoot%\DRV";
    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 :-)"
    

    Looking it over and it seems good to go, I tried it and received the following error:

    mount: mounting <ip address>:/fog/ on /fog failed: Permission denied
    /images/postdownloadscripts/fog.drivers: line 2: $'\r': command not found
    /images/postdownloadscripts/fog.drivers: line 3: $'\r': command not found
    /images/postdownloadscripts/fog.drivers: line 4: $'\r':syntax error near unexpected token  '$'in\r''
    'images/postdownloadscripts/fog.drivers: line 4: 'case $manu in umount: can't unmount /ntfs: Invalid Argument
    

    Then it finishes out and boots into Windows without its drivers it needs.

    the drivers are in /images/drivers/Win7/Optiplex 790/x64 for this lone machine at the moment.

    I’ve been working on this for a while and the drivers are my downfall. I can’t seem to parse these scripts myself.

    Anything and anything would be amazing and helpful.

    Thank you



  • I agree with you that it works wonderfully well with postdownloadscripts,
    Thanks to the scripts provided by the forum community. Thanks to them.

    But we must look for a bit before we find the existence of this functionality.

    Many people will turn to OPSI because it is better indicated in the documentation and it is native in the application.

    http://www.opsi.org/en

    I always love Fog because it’s very light.

    Thanks to the Fog team


  • Developer

    postscripts once setup, its literally the case of dropping drivers onto server, you could even setup permissions and map drive onto windows machine so you can “inject” there without even needing to go on the server (or give engineers permission to whole server)… pretty much what ur asking for but rather than through web interface, its network share


  • Senior Developer

    @Jacky94 A feature request that, this late in the game, will not be processed.



  • @Tom-Elliott

    Do not worry I know how to fetch my Dell drivers.

    But I would like to be able to inject the drivers from the Fog web interface.


  • Senior Developer

    @Jacky94 As @george1421 stated, this is not something that can be done considering the sheer number of companies and products available. And, each person’s layout is 100% unique to their configuration.



  • Hello,
    Is it possible to have the script complete and that works?

    It would be nice to have this feature directly integrated into fog in a future version.

    The management of the drivers customized by machine model is paramount now in the windows images.

    Thanks Jacky


  • Moderator

    @Jacky94 Its a start: https://forums.fogproject.org/topic/8889/fog-post-install-script-for-win-driver-injection/5

    But coming up with a universal driver install would be difficult since each company is unique.



  • Hello,
    Is it possible to have the script complete and that works?

    It would be nice to have this feature directly integrated into fog in a future version.

    The management of the drivers customized by machine model is paramount now in the windows images.

    Thanks Jacky



  • This post is deleted!

  • Developer

    apologies both - i could of jumped in sooner to point out about the /fog directory confusion and assisted with the partition code but been swamped as of late but luckily @Tom-Elliott had already sorted partition bit of magic for you guys! ;-)

    @THEMCV if you do only have dell machines and want to use cab files - you can use cabextract which is built into the FOS.

    something like:

    cabextract -d /ntfs/Windows/DRV "/fog/Drivers/$osn/${machine}"/*.CAB &>/dev/null;
    

    /ntfs/Windows/Drv - Change to wherever you want your drivers to be extracted to

    /fog/Drivers/etc… - Change to match the directory you store the .cab file on the server. i.e. /images/Drivers/E7270-WIN7-A02-8924F.CAB

    if you go down the .cab route - use the enterprise cabs as they are tested and put together specifically for image deployment.
    http://en.community.dell.com/techcenter/enterprise-client/w/wiki/2065.dell-command-deploy-driver-packs-for-enterprise-client-os-deployment

    if for whatever reason the cab isn’t sufficient and you need to add drivers, you could incorporate both .cab and folders using both sets of code. if you know what i mean?

    as @george1421 pointed out scripts are a lil’ flawed but where written and posted sometime ago and for my own environment at the time and my own postscripts have come a long way since then.

    the wiki post would be a very good idea as easier to keep up to date, once that’s done it may be worth changing any old posts with code in, redirecting users to the wiki so they don’t put conflicting or outdated code together. but like @george1421 said, a lot of it is personal preference and there is so many ways of achieving the same thing…

    Glad you got there in the end though :-)



  • @george1421 Ah yes, I did read over that one a bit! I finally got it figured out, but I didn’t end up using MDT. :) Very thorough. :)


  • Moderator

    @THEMCV I did create a write up for creating a single golden image for multiple platforms here: https://forums.fogproject.org/topic/7391/deploying-a-single-golden-image-to-different-hardware-with-fog But because of my NDA with my company I can’t include any of my own scripts. Now with what Tom, Lee an other produced I can compile that into a single document.

    But this next one will be short and to the point copy and paste this and it “should” work as designed. I’ll leave the big words on the other documents.



  • @Tom-Elliott Yep, it’s working extremely well. Thank you for helping me (and writing a piece of code for me!).

    @george1421 Sounds great, that’d be amazing! All of the past places that I’ve worked at (I’m in contact with them after I left) will appreciate the write up. They’ve been wanting to get master images rolling at their school districts (one being ~1,000 PCs), but never have gotten to get them up and running.


  • Moderator

    @THEMCV That’s great. I’m going to compile the results of this thread into a tutorial page tonight to get everything in one spot again.


  • Senior Developer

    @THEMCV safe to solve the?



  • @george1421 @Tom-Elliott @Quazz Okay, it looks like it worked! Amazing!

    You guys are simply the best devs/mods/team ever.

    Although I forgot to disable FOG Client in my sysprepped image, I fixed and and will be double testing again. It went through the section without a hitch though. :)


  • Senior Developer

    @george1421 The -eq 0 directly after the done part of the loop will be enacting on the last command ran.

    In this case it would either be echo or break which both will always equal 0.

    The if I’m referring to is not needed because you’re looping directories and immediately after the main mount you’re testing already.

    To correct this, and leave this there, you can add a variable in the first check of the mount success by doing something like:

    ntfsstatus="$?"
    if [[_! $ntfsstatus -eq 0_]]; then
        echo "Skipped"
        continue
    fi
    

    Then change the if check after the loop to check for $ntfsstatus instead of $?.

    A lot of refinement can be added admittedly.


  • Moderator

    @THEMCV First understand this this script won’t copy and paste correctly. For some reason the FOG Forum pages eat the spaces around the conditional tests, but I wanted to get it out here for viewing. I’ll upload the file in a minute.

    Tom: the only question I have is if NO partitions match will the test if [[ ! $? -eq 0 ]]; then still trap it?

    #!/bin/bash
    . /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"
                case $fstype in
                    ntfs)
                        dots "Testing partition $part"
                        ntfs-3g -o force,rw $part /ntfs
                        if [[ ! $? -eq 0 ]]; then
                            echo "Skipped"
                            continue
                        fi
                        if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then
                            echo "Not found"
                            umount /ntf >/dev/null 2>&1
                            continue
                        fi
                        echo "Success"
                        break
                        ;;
                    *)
                        echo " * Partition $part not NTFS filesystem"
                        ;;
                esac
            done
            if [[ ! $? -eq 0 ]]; then
                echo "Failed"
                debugPause
                handleError "Failed to mount $part ($0)\n    Args: $*"
            fi
            echo "Done"
            debugPause
            . ${postdownpath}fog.drivers
            . ${postdownpath}fog.ad
            umount /ntfs
            ;;
        *)
            echo "Non-Windows Deployment"
            debugPause
            return
            ;;
    esac
    
    

    0_1478194755557_fog.postdownload



  • @george1421 No problem. :)

    That would be nice though. I had to jump through a few threads (which is a given sometimes!) and the wiki page for Auto Installing drivers didn’t seem as robust as the scripts that I had found.

    But that’s how progress and the process work. One problem at a time and always improving. :)


Log in to reply
 

407
Online

39181
Users

10829
Topics

103052
Posts

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