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

    Utilizing Postscripts (Rename, JoinDomain, Drivers, Snapins)

    Scheduled Pinned Locked Moved
    Tutorials
    14
    46
    33.1k
    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.
    • Tom ElliottT
      Tom Elliott
      last edited by

      [quote=“Corneliu Mahu, post: 40382, member: 27456”]Hi Lee,
      Can I add in this way the unattend.xml file to the postscripts? If yes, how?
      Thanks

      Corneliu[/quote]

      You can use these postscripts to alter your unattend file directly.

      What you need to do is know what line needs to be changed to what and make the post scripts mount the partition containing the unattend file and make the adjustments as needed.

      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 0
      • JunkhackerJ
        Junkhacker Developer
        last edited by

        I thought i would share my own Postdownloadscript. i have a tendency to forget to remove the fog.log file from an image before i upload it, so i made a script to delete it.
        [CODE]#!/bin/bash
        #deletes fog.log for Windows 7, 8, or 8.1
        #Greg Grammon (Junkhacker)

        #funcs.sh allows us to use the functions that are used in the rest of
        #fog i.e. “dots” and use the vars already in place i.e. “$part” and “$osid”
        . /usr/share/fog/lib/funcs.sh;
        if [ “$osid” == “5” ] || [ “$osid” == “6” ] || [ “$osid” == “7” ]; then
        mkdir /ntfs 2>/dev/null
        dots “Mounting Windows File System”;
        mount.ntfs-3g $part /ntfs 2>/tmp/mntfail
        mntRet=“$?”;
        if [ ! “$mntRet” = “0” ]; then
        echo “Failed”;
        echo “”;
        echo -n " * ";
        cat /tmp/mntfail
        echo “”;
        sleep 2;
        else
        echo “Done.”;
        rm /ntfs/fog.log 2>/dev/null
        echo “”;
        echo “fog.log deleted”;
        umount /ntfs
        sleep 5;
        fi
        fi[/CODE]

        signature:
        Junkhacker
        We are here to help you. If you are unresponsive to our questions, don't expect us to be responsive to yours.

        1 Reply Last reply Reply Quote 0
        • M
          Mikael
          last edited by

          This is extremely interesting! Can you explain where in the download process the fog.postdownload script is triggered?
          I have created those three scripts but I cannot notice anything happening when i run a normal download to a pc but the download process keep looping! it only stops when I remove the script files from the folder…

          [url=“/_imported_xf_attachments/1/1791_fog.ad.txt?:”]fog.ad.txt[/url][url=“/_imported_xf_attachments/1/1792_fog.drivers.txt?:”]fog.drivers.txt[/url][url=“/_imported_xf_attachments/1/1793_fog.postdownload.txt?:”]fog.postdownload.txt[/url]

          1 Reply Last reply Reply Quote 0
          • Lee RowlettL
            Lee Rowlett Developer
            last edited by

            fog.postdownload is triggered/executed by fog.download after the pc has pulled down the image

            1 Reply Last reply Reply Quote 0
            • Lee RowlettL
              Lee Rowlett Developer
              last edited by

              your fog.postdownload is missing: #!/bin/sh

              also you’ve changed path in fog.drivers to /images (sensible option using existing fileshare!)

              but your fog.postdownload is still trying to mount /fog so you can hash out/remove that, i can’t remember without checking but /images is still mounted so don’t even need “remount” it.

              1 Reply Last reply Reply Quote 0
              • M
                Mikael
                last edited by

                Thanks, I just saw that! Sorry. I will run some more tests now

                1 Reply Last reply Reply Quote 0
                • Lee RowlettL
                  Lee Rowlett Developer
                  last edited by

                  remove/hash these lines:

                  mkdir /fog &>/dev/null
                  mount -o nolock,proto=tcp $storageip:/fog/ /fog
                  dots “Mounting Device”;

                  1 Reply Last reply Reply Quote 0
                  • M
                    Mikael
                    last edited by

                    yeah, I was using the already mounted images folder for my drivers. I see now that those other lines are not in use either, thanks

                    1 Reply Last reply Reply Quote 0
                    • G
                      gwhitfield
                      last edited by gwhitfield

                      I’m attempting to use this in our image deployment to push drivers and am having some trouble that is hopefully not difficult to overcome, I’m just not real script savvy. 😞 I have placed my drivers in the /images/Drivers folder and my fog.postdownload is as follows:

                      
                      #!/bin/sh
                      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
                          # mkdir /fog &>/dev/null
                          # mount -o nolock,proto=tcp $storageip:/fog/ /fog 
                          # dots "Mounting Device";
                          if [ "$?" = "0" ]; then
                              echo "Done";
                              . ${postdownpath}fog.drivers 
                            # . ${postdownpath}fog.ad 
                            # . ${postdownpath}fog.snapins
                              umount /ntfs; # unmount when all is done :-)
                          else
                              echo "Failed To Mount Device";
                              sleep 30;
                          fi
                      fi
                      

                      The computer responds with :

                      ntfs-3g: No mountpoint is specified

                      gives lots of usage instructions and options then

                      Failed to mount device

                      then restarts after about 30 seconds.

                      My fog.drivers file is as follows:

                      #!/bin/sh
                       
                      ceol=`tput el`;
                      machine=`dmidecode -s system-product-name`; # Gets machine model
                      machine="${machine%"${machine##*[![:space:]]}"}" #Removes Trailing Space
                      #system64="/ntfs/Windows/SysWOW64/regedit.exe"; # dirty way to determine if it's 64bit or not
                      #if [ -f "$system64" ]; then
                      #    setarch="x64"
                      #else
                      #    setarch="x86"
                      #fi
                      #############################################
                      #this is not section necessary needed, it's just to make the path "human readable"
                      #rather than using osid for filepath
                      if [ $osid == "5" ]; then
                          osn="Win7"
                      elif [ $osid == "7" ]; then
                          osn="Win8.1"
                      elif [ $osid == "9" ]; then
                          osn="Win10"
                      fi
                      #############################################
                      dots "Preparing Drivers";
                      # below creates local folder on imaged pc
                      #this can be anywhere you want just remember
                      #to make sure it matches throughout!
                      mkdir /ntfs/Windows/DRV &>/dev/null;
                      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:
                      #/images/Drivers/Win7/Latitude E5410/x86
                      rsync -aqz "/images/Drivers/$osn/${machine}/*.*" /ntfs/Windows/DRV &>/dev/null;
                       
                      #if you wanted to use driver.cab use this line below.
                      #i.e. /images/Drivers/Win7/Latitude E5410/E5410-Win7-A07-KTT4G.CAB
                      #cabextract -d /ntfs/Windows/DRV "/images/Drivers/$osn/${machine}"/*.CAB &>/dev/null;
                       
                      #if you wanted to mix both cab and extracted use these next two lines:
                      # rsync -aqz --exclude='*.CAB' "/images/Drivers/$osn/${machine}/$setarch" /ntfs/Windows/DRV &>/dev/null;
                      # cabextract -d /ntfs/Windows/DRV "/images/Drivers/$osn/${machine}"/*.CAB &>/dev/null;
                       
                      #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 :-)"
                      

                      Would you be able to assist?
                      Thanks,
                      Gregg W.

                      1 Reply Last reply Reply Quote 0
                      • Lee RowlettL
                        Lee Rowlett Developer
                        last edited by

                        Hi Gregg,

                        What version of fog are you using?

                        G 1 Reply Last reply Reply Quote 1
                        • G
                          gwhitfield @Lee Rowlett
                          last edited by

                          @Lee-Rowlett Sorry,trunk version 7709 i believe

                          1 Reply Last reply Reply Quote 1
                          • Lee RowlettL
                            Lee Rowlett Developer
                            last edited by Lee Rowlett

                            @gwhitfield as you’re using /images as your driver location you do not need to mount a share as it’s already mounted, so /fog mount is irrelevant to you. as you’re only doing one arch or having both drivers on the image, i’m assuming as you commented it out, make sure your folder layout for drivers matches this for example a Windows 7 build OptiPlex 7010 would be:
                            “/images/Drivers/Win7/OptiPlex 7010” and all your drivers for the 7010 would be within that folder

                            Try these and let me know how you get on 🙂

                            fog.postdownload:

                            #!/bin/bash
                            case $osid in
                                [5-7]|9)
                            	clearScreen
                            	getHardDisk
                            	getPartitions $hd
                            	if [[ ! -d /ntfs ]]; then
                            	    mkdir -p /ntfs >/dev/null 2>&1
                            	    [[ ! $? -eq 0 ]] && echo " * Failed to Mount Device"
                            	fi
                            	for part in $parts; do
                            	    umount /ntfs >/dev/null 2>&1
                            	    ntfs-3g -o remove_hiberfile,rw $part /ntfs >/dev/null 2>&1
                            	    [[ ! $? -eq 0 ]] && continue
                            	done
                            	. ${postdownpath}fog.drivers
                            	umount /fog /ntfs /images >/dev/null 2>&1
                            	;;
                            esac
                            

                            fog.drivers:

                            #!/bin/bash
                            ceol=`tput el`;
                            machine=`dmidecode -s system-product-name`;
                            machine="${machine%"${machine##*[![:space:]]}"}"
                            if [ $osid == "5" ]; then
                                osn="Win7"
                            elif [ $osid == "7" ]; then
                                osn="Win8.1"
                            elif [ $osid == "9" ]; then
                                osn="Win10"
                            fi
                            dots "Preparing Drivers";
                            mkdir /ntfs/Windows/DRV &>/dev/null;
                            echo -n "In Progress";
                            rsync -aqz "/images/Drivers/$osn/${machine}" /ntfs/Windows/DRV &>/dev/null;
                            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";
                            
                            G 1 Reply Last reply Reply Quote 0
                            • G
                              gwhitfield @Lee Rowlett
                              last edited by gwhitfield

                              @Lee-Rowlett Seems like I’m very close. The image task completes and I get the following just before the machine restarts. Unfortunately no drivers are copied so the image fails to bootup since there’s no drivers in it:

                              /images/postdownloadscripts/fog.postdownload: line 2: syntax error near unexpected token '$' in\r''
                              
                              'images/postdownloadscripts/fog.postdownload: line 2: 'case $osid in
                              * Mounting directory ............................Done
                              * Mounting directory ............................Done
                              * Changing hostname .............................Done
                              * Task complete
                              * Updating Database..............................Done
                              * Rebooting system as task is complete
                              Reboot: Restarting system
                              
                              
                              Lee RowlettL 1 Reply Last reply Reply Quote 0
                              • Lee RowlettL
                                Lee Rowlett Developer @gwhitfield
                                last edited by Lee Rowlett

                                can you send me both your fog.postdownload and fog.drivers file and i’ll take a look - (i mean physically send, not paste the code on here :-))

                                G 2 Replies Last reply Reply Quote 0
                                • G
                                  gwhitfield @Lee Rowlett
                                  last edited by gwhitfield

                                  @Lee-Rowlett Sure, here’s the goods:

                                  Screenshot of folders in /images
                                  0_1464287477451_upload-d7bd4017-8d6d-4290-9f0e-8f3f288559ed

                                  1 Reply Last reply Reply Quote 0
                                  • G
                                    gwhitfield @Lee Rowlett
                                    last edited by

                                    @Lee-Rowlett 1_1464287927234_fog.postdownload 0_1464287927232_fog.drivers

                                    1 Reply Last reply Reply Quote 0
                                    • G
                                      gwhitfield @Lee Rowlett
                                      last edited by gwhitfield

                                      @Lee-Rowlett Success!! Evidently my fog.postdownload and fog.drivers files got corrupted by editing in Notepad. Thank you for sending me a clean version! Working like a champ. Also for purpose of posterity or future users, the name of the folder for each individual hardware type needs to exactly match the spelling and case of the “System Product” field in the “Inventory” for that machine (or type of machine):
                                      0_1464350550359_upload-6cb5345e-fa39-41cf-b8da-32753a7d9c810_1464350652931_upload-02508467-b071-4c00-82b5-4abe5b337023

                                      1 Reply Last reply Reply Quote 1
                                      • Greg PlamondonG
                                        Greg Plamondon Testers @Lee Rowlett
                                        last edited by

                                        @Lee-Rowlett

                                        I gotten this to make the edits to the unattend.xml but it still doesnt join the domain. Do you have a Windows10 Unattend.xml that i can compare where I went wrong?

                                        Lee RowlettL 1 Reply Last reply Reply Quote 0
                                        • Lee RowlettL
                                          Lee Rowlett Developer @Greg Plamondon
                                          last edited by

                                          @Greg-Plamondon where are you calling the unattend.xml from and how are u verifying the unattend.xml is beinf edited correctly? Also are is it x86 or x64?

                                          Tom ElliottT Greg PlamondonG 2 Replies Last reply Reply Quote 0
                                          • Tom ElliottT
                                            Tom Elliott @Lee Rowlett
                                            last edited by

                                            @Lee-Rowlett I remoted in and took a look. Cleaned up the scripts a lot, with Gregs help (-- @Greg-Plamondon I grabbed some credit but it still mostly goes to you --). I asked Greg to post the finished scripts after generalizing them so his environment is safe. Hopefully you will like them, and others as well.

                                            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 1
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • First post
                                              Last post

                                            192

                                            Online

                                            12.0k

                                            Users

                                            17.3k

                                            Topics

                                            155.2k

                                            Posts
                                            Copyright © 2012-2024 FOG Project