• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

fog.drivers script will not run correctly in postdownloadscripts

Scheduled Pinned Locked Moved Solved
FOG Problems
7
69
31.4k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q
    Quazz Moderator @THEMCV
    last edited by Nov 3, 2016, 3:48 PM

    @THEMCV Yes, that’s fine.

    T 1 Reply Last reply Nov 3, 2016, 3:52 PM Reply Quote 0
    • T
      THEMCV @Quazz
      last edited by Nov 3, 2016, 3:52 PM

      @Quazz Okay, it’s in there. No change. Still acting like there’s no space left on the device which isn’t true at all. The image is only ~15GB.

      Q G 2 Replies Last reply Nov 3, 2016, 3:57 PM Reply Quote 0
      • Q
        Quazz Moderator @THEMCV
        last edited by Nov 3, 2016, 3:57 PM

        @THEMCV I’d have to guess your ntfs isn’t being mounted correctly on the client. Most likely it’s trying to rsync to the fog client (which is residing in RAM) which will of course not have space to write to.

        How do your scripts look like now?

        1 Reply Last reply Reply Quote 0
        • G
          george1421 Moderator @THEMCV
          last edited by george1421 Nov 3, 2016, 10:01 AM Nov 3, 2016, 3:59 PM

          @THEMCV OK what I think I would do at this point is insert a debug pause after the error generator.

          #/fog/Drivers/Win7/Latitude E5410/x86
          rsync -aqz "$remotedriverpath" "$clientdriverpath" >/dev/null 2>&1
          [[! $? -eq 0]] && handleError "Failed to download driver information"
          
          debugPause
          

          After the handleError line after the rsync.

          Then go back and schedule a deployment to this computer but pick the debug deployment checkbox.

          Then pxe boot the target computer. It will print out a bunch of text but drop you to a command prompt. From there key in fog This will single step you through the deployment process. When you get to the point of the error press crtl-C to exit the installer script. This will leave you at a linux command prompt. From there we should be able to check the disk size and what not.

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

          T 1 Reply Last reply Nov 3, 2016, 5:13 PM Reply Quote 1
          • G
            george1421 Moderator
            last edited by george1421 Nov 3, 2016, 10:08 AM Nov 3, 2016, 4:05 PM

            Wait, I just found a flaw in the script from Lee’s page (note: not a script Lee created though) for Windows 10, for Win7 its correct since the last partition on disk 0 is the windows partition.

                    getPartitions $hd
                    for part in $parts; do
                        true
                    done
                    dots "Mounting partition $part"
            

            This loosely gives me the last partition for Win10. But that is NOT the windows partition. In the case of the system I’m testing there are 3 partitions, but partition 2 is the windows partition. I’m not using rsync but just regular copy that threw the error.

            I think more intelligence needs to be built into this loop, where it should check to see if the /windows directory exists before exiting.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

            Q 1 Reply Last reply Nov 3, 2016, 4:09 PM Reply Quote 0
            • Q
              Quazz Moderator @george1421
              last edited by Nov 3, 2016, 4:09 PM

              @george1421 I personally use

              echo -n " * Mounting Windows File System...................";
              if [ -b /dev/sda4 ]
               then
                  mount.ntfs-3g /dev/sda4 /ntfs 2>/tmp/mntfail
               else
                  mount.ntfs-3g /dev/sda2 /ntfs 2>/tmp/mntfail
              fi
              

              Logic: If the system has 4 partitions (or more), then (assuming singleboot windows) it is a GTP installation and Windows is on partition 4. Otherwise it’s a MBR installation and it will generally be on partition 2.

              This is incredibly over simplistic, however and only reliably works on clean microsoft images, not OEM or the like.

              A loop function would need to be created to check for the windows folder or something.

              G 1 Reply Last reply Nov 3, 2016, 4:11 PM Reply Quote 0
              • G
                george1421 Moderator @Quazz
                last edited by george1421 Nov 3, 2016, 10:11 AM Nov 3, 2016, 4:11 PM

                @Quazz I had a similar simple conditional test, until I ran into a NVMe drive with its crazy disk naming of /dev/nvme0n1[partition]

                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                Q 1 Reply Last reply Nov 3, 2016, 4:12 PM Reply Quote 0
                • Q
                  Quazz Moderator @george1421
                  last edited by Nov 3, 2016, 4:12 PM

                  @george1421 Good point, we mostly deal in refurbished hardware and my script is non critical, so it hasn’t been a big deal for me so far.

                  G 1 Reply Last reply Nov 3, 2016, 4:15 PM Reply Quote 0
                  • G
                    george1421 Moderator @Quazz
                    last edited by george1421 Nov 3, 2016, 10:15 AM Nov 3, 2016, 4:15 PM

                    @Quazz Unless the @Senior-Developers can come up with a brilliant way to find the windows partition, I think we are going to have to mount each partition, in order, until we find one that has the /Windows directory on it. That is kind of an expensive way to do that (in CPU time).

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                    Q T 2 Replies Last reply Nov 3, 2016, 4:29 PM Reply Quote 0
                    • Q
                      Quazz Moderator @george1421
                      last edited by Quazz Nov 3, 2016, 10:34 AM Nov 3, 2016, 4:29 PM

                      @george1421 We can already reduce that by selecting only the NTFS partitions to try though.

                      PARTITIONS=$(df -T | grep ntfs | awk '{print $1}')
                      

                      edit: I just realized this may not work on unmounted partitions, I’ll correct in a bit.

                      1 Reply Last reply Reply Quote 0
                      • T
                        Tom Elliott @george1421
                        last edited by Tom Elliott Nov 3, 2016, 11:13 AM Nov 3, 2016, 4:37 PM

                        @george1421 There’s already a way.

                        It sounds like the partitions aren’t being processed based on:

                        @THEMCV said in fog.drivers script will not run correctly in postdownloadscripts:

                        @Quazz I did not, no. I think I found the /fog reference though and might be our problem.

                        I think it might be my postdownload script itself.

                        #!/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>
                        
                        if [ $osid == "5" -o $osid == "6" -o $osid == "7" ]; then #only handling Win7/8/8.1
                            clearScreen;
                            mkdir /ntfs &>/dev/null
                            ntfs-3g -o force,rw $part /ntfs #mount image (remember this is mounting partition [U][B]after[/B][/U] new image is deployed)
                            mkdir /fog &>/dev/null
                            mount -o nolock,proto=tcp $storageip:/fog/ /fog #this is a share created on server under /fog which contains drivers, software etc.. (just add /fog to exports but you could use existing location i.e. /images and if you do, do not ne$
                            dots "Mounting Device";
                            if [ "$?" = "0" ]; then
                                echo "Done";
                                . ${postdownpath}fog.drivers # run fog.drivers script
                                umount /ntfs; # unmount when all is done :-)
                            else
                                echo "Failed To Mount Device";
                                sleep 30;
                            fi
                        fi
                        

                        @Wayne-Workman I removed it and am testing it now.

                        The ntfs-3g -o force,rw $part /ntfs is using the last partition FOG processed instead of looping the partitions separately.

                        If it were me (psuedo code here) I’d end up doing something like:

                                getPartitions $hd
                                for part in $parts; do
                                    umount /ntfs >/dev/null
                                    fsTypeSetting "$part"
                                    case $fstype in
                                        ntfs)
                                            dots "Mounting partition $part"
                                            ntfs-3g -o force,rw $part /ntfs
                                            if [[_! $? -eq 0_]]; then
                                                echo "Failed...Trying next partition"
                                                continue
                                            fi
                                            if [[_! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS_]]; then
                                                echo "Done...no valid Windows directory found"
                                                umount /ntfs
                                                continue
                                            fi
                                            echo "Done"
                                            break
                                            ;;
                                        *)
                                            echo " * Partition $part not NTFS filesystem"
                                            ;;
                                    esac
                                done
                        

                        Of course this isn’t tested, and just thoughts through my head. Replace the _ with spaces.

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                        T 1 Reply Last reply Nov 3, 2016, 5:19 PM Reply Quote 2
                        • G
                          george1421 Moderator
                          last edited by Nov 3, 2016, 5:12 PM

                          Tom was able to do a bit of magic below. I tested it in my dev environment and it works to correctly find the windows partition. It needs a bit of cleanup work (hiding some unnecessary messages) but all in all it w is a brilliant bit of code.

                          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                          1 Reply Last reply Reply Quote 0
                          • T
                            THEMCV @george1421
                            last edited by Nov 3, 2016, 5:13 PM

                            @george1421 said in fog.drivers script will not run correctly in postdownloadscripts:

                            @THEMCV OK what I think I would do at this point is insert a debug pause after the error generator.

                            #/fog/Drivers/Win7/Latitude E5410/x86
                            rsync -aqz "$remotedriverpath" "$clientdriverpath" >/dev/null 2>&1
                            [[! $? -eq 0]] && handleError "Failed to download driver information"
                            
                            debugPause
                            

                            After the handleError line after the rsync.

                            Then go back and schedule a deployment to this computer but pick the debug deployment checkbox.

                            Then pxe boot the target computer. It will print out a bunch of text but drop you to a command prompt. From there key in fog This will single step you through the deployment process. When you get to the point of the error press crtl-C to exit the installer script. This will leave you at a linux command prompt. From there we should be able to check the disk size and what not.

                            Okay, done. running the command df I get:

                            Filesystem                   1K-blocks                Used        Available      Use%      Mounted on
                            /dev/root                        99459               99440              0         100          / 
                            10.4.200.150://images/        464307200             215944192        224754688    50          /images
                            

                            I will run @Tom-Elliot’s code and report back. 🙂

                            1 Reply Last reply Reply Quote 0
                            • T
                              THEMCV @Tom Elliott
                              last edited by THEMCV Nov 3, 2016, 11:21 AM Nov 3, 2016, 5:19 PM

                              @Tom-Elliott So this goes into fog.postdownload alone or conjoined with the previous script from ntfs-3g -o force,rw $part /ntfs down?

                              @Quazz My scripts currently:

                              #!/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>
                              
                              . ${postdownpath}fog.drivers
                              

                              and

                              #!/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
                              echo
                              echo "rsync -aqz \"$remotedriverpath\" \"$clientdriverpath\""
                              echo
                              rsync -aqz "$remotedriverpath" "$clientdriverpath"
                              [[ ! $? -eq 0 ]] && handleError "Failed to download driver information"
                              
                              debugPause
                              #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 :-)"
                              
                              
                              G 1 Reply Last reply Nov 3, 2016, 5:21 PM Reply Quote 0
                              • G
                                george1421 Moderator @THEMCV
                                last edited by george1421 Nov 3, 2016, 11:22 AM Nov 3, 2016, 5:21 PM

                                @THEMCV please stand by. I think I have a working solution based on tom’s script. I just want to make sure it doesn’t break anything else. I realize we are sending you in 10 different directions, because each has their own way to go about this.

                                We really need to get a wiki page built with a step by step.

                                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                                T 1 Reply Last reply Nov 3, 2016, 5:22 PM Reply Quote 1
                                • T
                                  THEMCV @george1421
                                  last edited by THEMCV Nov 3, 2016, 11:26 AM Nov 3, 2016, 5:22 PM

                                  @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. 🙂

                                  G 1 Reply Last reply Nov 3, 2016, 5:37 PM Reply Quote 1
                                  • G
                                    george1421 Moderator @THEMCV
                                    last edited by george1421 Nov 3, 2016, 11:39 AM Nov 3, 2016, 5:37 PM

                                    @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

                                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                                    Tom ElliottT 1 Reply Last reply Nov 3, 2016, 5:46 PM Reply Quote 2
                                    • Tom ElliottT
                                      Tom Elliott @george1421
                                      last edited by Tom Elliott Nov 3, 2016, 11:47 AM Nov 3, 2016, 5:46 PM

                                      @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.

                                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                      1 Reply Last reply Reply Quote 2
                                      • T
                                        THEMCV
                                        last edited by Nov 3, 2016, 6:17 PM

                                        @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. 🙂

                                        Tom ElliottT G 2 Replies Last reply Nov 3, 2016, 8:26 PM Reply Quote 1
                                        • Tom ElliottT
                                          Tom Elliott @THEMCV
                                          last edited by Nov 3, 2016, 8:26 PM

                                          @THEMCV safe to solve the?

                                          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                          T 1 Reply Last reply Nov 3, 2016, 8:54 PM Reply Quote 0
                                          • 1
                                          • 2
                                          • 3
                                          • 4
                                          • 4 / 4
                                          4 / 4
                                          • First post
                                            45/69
                                            Last post

                                          160

                                          Online

                                          12.0k

                                          Users

                                          17.3k

                                          Topics

                                          155.2k

                                          Posts
                                          Copyright © 2012-2024 FOG Project