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

Post Init Script Issues

Scheduled Pinned Locked Moved
FOG Problems
4
13
952
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.
  • C
    Chris Whiteley
    last edited by Nov 3, 2020, 11:54 PM

    I have FOG Server 1.5.9 and I was trying to customize my FOG reg menu.

    I followed this post: https://forums.fogproject.org/topic/9754/custom-full-host-registration-for-1-3-4 as I wanted to change a few things in my script, namely change the “other user tag #1” and “other user tag #2” to be different questions. I have updated that and created the “patch.fullreg” file in /images/dev/postinitscripts and the fog.man.reg.fix file that I downloaded from github and made my changes. It doesn’t ever look at the file when it goes through even though I have defined it in the “fog.postinit” file like this

    . ${postinitpath}patch.fullreg
    

    I am not quite sure what I am missing here…Is there a different version of the fog.man.reg file?

    1 Reply Last reply Reply Quote 0
    • G
      george1421 Moderator
      last edited by Nov 4, 2020, 12:41 AM

      Similar concept in this tutorial. https://forums.fogproject.org/topic/14278/creating-custom-hostname-default-for-fog-man-reg

      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
      • S
        Sebastian Roth Moderator
        last edited by Nov 4, 2020, 11:43 AM

        @Chris-Whiteley What exactly do you have in patch.fullreg? How do you know it’s not being used?

        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

        C 1 Reply Last reply Nov 4, 2020, 2:33 PM Reply Quote 0
        • C
          Chris Whiteley @Sebastian Roth
          last edited by Nov 4, 2020, 2:33 PM

          @Sebastian-Roth The reason I know it’s not being used is because the changes I made are not happening during a full registration and the script “echo’s” are not there. Here is the patch.fullreg

          currfile="/bin/fog.man.reg"
          newfile="${postinitpath}fog.man.reg.fix"
          
          . /usr/share/fog/lib/funcs.sh
          
          echo "Testing path for our fixed file at ${postinitpath}fog.man.reg.fix"
          debugPause
          
          # Test path and run copy if found and matched.
          if [[ -r $newfile ]]; then
              echo "Found file preparing to copy"
              debugPause
              cp -f $newfile $currfile >/dev/null 2>&1
              [[ ! $? -eq 0 ]] && echo "Copy Failed" || echo "Copy Succeeded"
              debugPause
          else
              echo "Failed to find file sorry"
              debugPause
          fi
          

          This was borrowed from Tom Elliot’s post. I tried the very simple one first and that didn’t work, so I tried this one next and the same issue.

          G 1 Reply Last reply Nov 4, 2020, 3:01 PM Reply Quote 0
          • G
            george1421 Moderator @Chris Whiteley
            last edited by george1421 Nov 4, 2020, 9:02 AM Nov 4, 2020, 3:01 PM

            @Chris-Whiteley so what does your fog.postinit script look like?

            Again I’ll refer you to my post: https://forums.fogproject.org/topic/14278/creating-custom-hostname-default-for-fog-man-reg

            Specifically look at the fog.patch.customhostname and fog.postinit sections.

            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!

            C 2 Replies Last reply Nov 4, 2020, 3:29 PM Reply Quote 0
            • C
              Chris Whiteley @george1421
              last edited by Nov 4, 2020, 3:29 PM

              @george1421 I ended up figuring it out. I had 3 different locations in /images that had the “postinitscripts” folder which I thought was odd. I had it at the root of /images, inside of /images/dev and inside of /images/dev/dev/. I ended up copying the same things into those 2 other folders and now it is working. I am not sure where it is pulling from though.

              T 1 Reply Last reply Nov 4, 2020, 3:36 PM Reply Quote 0
              • C
                Chris Whiteley @george1421
                last edited by Nov 4, 2020, 3:32 PM

                @george1421 I already showed you right in the question I asked, but since you want to see it again:

                #!/bin/bash
                ## This file serves as a starting point to call your custom pre-imaging/post init loading scripts.
                ## <SCRIPTNAME> should be changed to the script you're planning to use.
                ## Syntax of post init scripts are
                #. ${postinitpath}<SCRIPTNAME>
                . ${postinitpath}patch.fullreg
                
                1 Reply Last reply Reply Quote 0
                • T
                  Tom Elliott @Chris Whiteley
                  last edited by Nov 4, 2020, 3:36 PM

                  @Chris-Whiteley PostInit pulls from /images/dev/postinitscripts (the ${postinitpath} is defined as this.)

                  The /images/dev/dev should not exist but won’t hurt anything either.

                  I’ll paste the code below, but just for understanding of what it does:

                  It looks for postinit script in /imagesinit based on the type of task.
                  Capture task: /imagesinit/ mounted would be looking at /images/dev/
                  Deploy task: /imagesinit/ would be looking at /images/

                  The code that sets this up:

                  dots "Running post init scripts"
                  [[ ! -d /imagesinit ]] && mkdir /imagesinit >/dev/null 2>&1
                  umount /imagesinit >/dev/null 2>&1
                  mount -o nolock,proto=tcp,rsize=32768,wsize=32768,intr,noatime "$storage" /imagesinit >/tmp/mount-output 2>&1
                  if [[ $? -eq 0 ]]; then
                      if [[ -f /imagesinit/.mntcheck ]]; then
                          if [[ -f /imagesinit/postinitscripts/fog.postinit ]]; then
                              postinitpath="/imagesinit/postinitscripts/"
                          elif [[ -f /imagesinit/dev/postinitscripts/fog.postinit ]]; then
                              postinitpath="/imagesinit/dev/postinitscripts/"
                          fi
                          . ${postinitpath}fog.postinit
                      fi
                      umount /imagesinit >/dev/null 2>&1
                      echo "Done"
                      debugPause
                  else
                      echo "Skipped"
                      debugPause
                  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! 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

                  C G 2 Replies Last reply Nov 4, 2020, 3:47 PM Reply Quote 0
                  • C
                    Chris Whiteley @Tom Elliott
                    last edited by Nov 4, 2020, 3:47 PM

                    @Tom-Elliott Thanks Tom for showing that. It looks like mine is pulling from /images/postinitscripts and not the /images/dev/postinitscripts for doing a full host registration and inventory. Is there a way to change “other tag” and other verbiage both in the FOG web and in the database? Basically, I am looking to put certain info inside of FOG and then find a way to export that out to a different system.

                    For Instance, when my company buys computers, we have to track the Purchase Order (P.O.) they go with. I would like to have one of the prompts be asking for the P.O. and then find a way to export that or send that info to another system.

                    Is that even possible?

                    1 Reply Last reply Reply Quote 0
                    • S
                      Sebastian Roth Moderator
                      last edited by Nov 4, 2020, 4:08 PM

                      @Chris-Whiteley Run the following commands and post output here:

                      ls -al /images/dev/postinitscripts/
                      cat /images/dev/postinitscripts/fog.postinit
                      

                      I just tested and your script works as far as I can see.

                      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

                      C 1 Reply Last reply Nov 4, 2020, 4:11 PM Reply Quote 0
                      • C
                        Chris Whiteley @Sebastian Roth
                        last edited by Nov 4, 2020, 4:11 PM

                        @Sebastian-Roth

                        ls -al /images/dev/postinitscripts/

                        drwxrwsrwx. 2 fogproject root    70 Nov  3 15:26 .
                        drwsrwsrwx. 4 fogproject root    73 Nov  4 07:45 ..
                        -rwxrwxrwt. 1 fogproject root 10000 Nov  3 15:19 fog.man.reg.fix
                        -rwxrwxrwx. 1 fogproject root   279 Nov  3 15:45 fog.postinit
                        -rwxrwxrwt. 1 fogproject root   502 Nov  3 15:48 patch.fullreg
                        

                        cat /images/dev/postinitscripts/fog.postinit

                        #!/bin/bash
                        ## This file serves as a starting point to call your custom pre-imaging/post init loading scripts.
                        ## <SCRIPTNAME> should be changed to the script you're planning to use.
                        ## Syntax of post init scripts are
                        #. ${postinitpath}<SCRIPTNAME>
                        . ${postinitpath}patch.fullreg
                        
                        1 Reply Last reply Reply Quote 0
                        • G
                          george1421 Moderator @Tom Elliott
                          last edited by Nov 4, 2020, 5:00 PM

                          @Tom-Elliott said in Post Init Script Issues:

                          It looks for postinit script in /imagesinit based on the type of task.
                          Capture task: /imagesinit/ mounted would be looking at /images/dev/
                          Deploy task: /imagesinit/ would be looking at /images/

                          Possibly we need to take this discussion off line but shouldn’t we consider creating a symbolic links between /images/dev/postinitscripts and /images/postinitscripts if the point of view changes between image capture and deployment? This way there is only one location contains the file that are used with both capture and deployment.

                          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 4, 2020, 5:11 PM Reply Quote 0
                          • T
                            Tom Elliott @george1421
                            last edited by Nov 4, 2020, 5:11 PM

                            @george1421 Remember that during a capture, the $storage variable is defined, usually:

                            IPAddress:/images/dev

                            In the case of a deplooy the $storage variable is defined, usually:

                            IPAddress:/images

                            That’s why the checking.

                            If somebody wants to move the postinit into /images, then it should be symlinked, but that’s beyond our scope. That’s more of a preference .

                            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
                            • 1 / 1
                            1 / 1
                            • First post
                              9/13
                              Last post

                            216

                            Online

                            12.0k

                            Users

                            17.3k

                            Topics

                            155.2k

                            Posts
                            Copyright © 2012-2024 FOG Project