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

    Post Download Scripts Included Variables

    Scheduled Pinned Locked Moved
    General
    3
    8
    1.2k
    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.
    • R
      rodluz Developer
      last edited by

      Hello, I am trying to create a post download script to add drivers to my image.
      I have read many forum posts about this and have created my script. Most of those posts reference the $osid variable that can be used in these scripts.

      I have different drivers for different versions of Windows 10 (1909, 2004, 20H2, …) but I don’t see a way of figuring out what version I am imaging on a computer.
      So, I am thinking I could add the version number in the image name and add the logic to the script.
      That being said, is there a variable for the image name?
      I know that the images table in the database has and imageName field, but is there a variable for it that can be used in the post download scripts?

      Also, is there a link/file where I can see what other variables are available to the FOS at that moment?

      Thanks for the help!

      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

      george1421G EduardoTSeoaneE 2 Replies Last reply Reply Quote 0
      • george1421G
        george1421 Moderator @rodluz
        last edited by

        @rodluz There is a couple of ways you can go about this. I’ll tell you the hacky way to get what variables you need.

        Schedule a debug deploy. Schedule a deployment task to a test computer, before you hit the schedule task button tick the debug checkbox. Now pxe boot the target computer. After several screens of text you need to clear with the enter key you will be dropped to the FOS Linux command prompt. At the fos linux command prompt key in fog and press enter. This will start the imaging process in debug mode. The imaging process will stop at each breakpoint in the code. Contine the imaging process until the fog banner is displayed. Press ctrl-c to exit the script. Now key in the word set these are all of the variables available in the post install script. You can also run this command to see the parameters passed from the FOG server. cat /proc/cmdline The image name you are looking for is defined there.

        Now to your task. You could use one of the tag fields in the host definition to pass a parameter to the post install script.

        In my build environment I use MDT to create the golden image. One of the task sequences I have writes a build version to a text file. In the post install script I read that build version to identify if I need to do any fixup (swapping files, changing stuff in the golden image, etc) during a post install script. You could do something similar for the windows version. i.e. leave some bread crumbs behind in the golden image so you can use them during the post install script.

        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!

        R 1 Reply Last reply Reply Quote 0
        • R
          rodluz Developer @george1421
          last edited by

          @george1421 I didn’t think of having a text file on the image itself, that is so simple to implement.
          I’ll try both things out next week when I am back at the office.

          Thank you so much!

          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

          george1421G 1 Reply Last reply Reply Quote 0
          • george1421G
            george1421 Moderator @rodluz
            last edited by

            @rodluz Here is my code that I used top patch the deployed image. It has the concepts you might need.

            #!/bin/bash
            
            # Only do patches of the PlatformVersion file exists
            if [ -f "/ntfs/Windows/PlatformVersion.rek" ]
            then
                platVersion=$(<"/ntfs/Windows/PlatformVersion.rek")
                echo " ";
                dots "Platform Version";
                echo "${platVersion}";
                # Identify what Image version we deployed
                case "${platVersion}" in
                    3.1.0.2*)
                        # Unattend.xml is missing the driver load section
                        rm -f /ntfs/Windows/Panther/*nattend.xml
                        cp "/images/patches/${platVersion}/Unattend.xml" "/ntfs/Windows/Panther/Unattend.xml";
                    ;;
                    3.2.0.0*)
                        # Unattend.xml is missing the driver load section
                        cp "/images/patches/${platVersion}/Unattend.xml" "/ntfs/Windows/Panther/Unattend.xml";
                    ;;
                    3.3.0.2A*)
                        # Unattend.xml is missing the driver load section
                        echo "Patching the unattend file in 3.3.0.2A";
                        cp "/images/patches/3.3.0.2A/Unattend.xml" "/ntfs/Windows/Panther/Unattend.xml";
                        echo "Patching done";
                    ;;
                    *)
                        # Nothing really to do if the version is not identified
                        echo "OS patching is not required";
                        echo " " ;
                    ;;
                esac
                # Clean up any *nix stuff in the SetupComplete file
                [[ -f "/ntfs/Windows/Setup/Scripts/SetupComplete.cmd" ]] && unix2dos /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
                debugPause;
                sleep 5;
            fi
            
            
            

            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!

            R 1 Reply Last reply Reply Quote 0
            • R
              rodluz Developer @george1421
              last edited by rodluz

              @george1421 Thank you so much that helps a lot! I’ll have to modify a few things and test it out.

              One question. What does the dots command do? I’ve tried to search what that command does in bash but I can’t find anything about it.

              EDIT: Also does the file have to be a .rek filetype or can it just be a txt?

              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

              george1421G 1 Reply Last reply Reply Quote 0
              • george1421G
                george1421 Moderator @rodluz
                last edited by george1421

                @rodluz said in Post Download Scripts Included Variables:

                What does the dots command do?

                That is a fog built in command. It makes pretty text like this.

                This is step 1................
                Cleaning up ..................
                Done Processing ..............
                

                You will see this text during imaging. It fills the remainder of the line with dots adjusting based on the length of the text string.

                Also does the file have to be a .rek filetype or can it just be a txt

                I just picked a file extension probably not in use. The .rek file is short for I was a total brain wreck by the time I finally figured out how to do what I wanted to with that process.

                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!

                R 1 Reply Last reply Reply Quote 0
                • R
                  rodluz Developer @george1421
                  last edited by

                  @george1421 Ahh okay thank you!

                  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
                  • EduardoTSeoaneE
                    EduardoTSeoane @rodluz
                    last edited by

                    @rodluz you can try this, https://forums.fogproject.org/topic/6463/expose-fog-host-and-image-properties-to-post-install-scripts?_=1620751811503 and make a review of host, image and hostinventory items…

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post

                    249

                    Online

                    12.0k

                    Users

                    17.3k

                    Topics

                    155.2k

                    Posts
                    Copyright © 2012-2024 FOG Project