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

langage de programmation

Scheduled Pinned Locked Moved
General
3
51
9.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.
  • J
    julio @Sebastian Roth
    last edited by Feb 2, 2021, 12:26 PM

    @sebastian-roth Bonjour roth. oui j’ai utliser nano. mais le nom de ma machine n’a pas changer. ci join mes fichiers.hostname.PNG fichier2.PNG fichie1.PNG

    1 Reply Last reply Reply Quote 0
    • S
      Sebastian Roth Moderator
      last edited by Feb 2, 2021, 12:31 PM

      @julio Looking at the script again I see an issue with the mount command. Should be mount /dev/sda1 /ext (space in between!)

      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

      G J 3 Replies Last reply Feb 2, 2021, 12:37 PM Reply Quote 1
      • G
        george1421 Moderator @julio
        last edited by Feb 2, 2021, 12:37 PM

        @julio OK explaining this may be a little hard because of the language differences but lets try.

        I have examples of postdownload scripts for Windows. The concept is very similar for linux. The logic and flow have already been thought out you just need to translate for linux. You are doing a few steps wrong. I will follow on in the next post after I explain my thought here

        https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed

        If you have windows computers and want to install hardware specific drivers then you need all of the scripts in that post. If you only have linux computers then the only base script you need is fog.custominstall

        The beginning script looks like this

        #!/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
                            ntfsstatus="$?"
                            if [[ ! $ntfsstatus -eq 0 ]]; then
                                echo "Skipped"
                                continue
                            fi
                            if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then
                                echo "Not found"
                                umount /ntfs >/dev/null 2>&1
                                continue
                            fi
                            echo "Success"
                            break
                            ;;
                        *)
                            echo " * Partition $part not NTFS filesystem"
                            ;;
                    esac
                done
                if [[ ! $ntfsstatus -eq 0 ]]; then
                    echo "Failed"
                    debugPause
                    handleError "Failed to mount $part ($0)\n    Args: $*"
                fi
                echo "Done"
                debugPause
                . ${postdownpath}fog.copydrivers
                # . ${postdownpath}fog.updateunattend
                umount /ntfs
                ;;
            *)
                echo "Non-Windows Deployment"
                debugPause
                return
                ;;
        esac
        

        If you can read program code you can see it checks to see if $osid is a ms windows type. The it uses some fog built in function to get the hard drive name, then get the partitions on the hard drive. It loops through the partitions checking to see if there is a directory called windows on that partition. We are using that to find the C drive on windows computer. Once we find the windows directory then we call the copy drivers script. At the end then we unmount the /ntfs directory and exit

        In your case you can use the same logic but for $osid of 50. Then loop through the partitions looking for the /etc directory on the mounted share of /ntfs. The programming flow for windows is very close to the programming flow I can see for linux.

        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!

        J 1 Reply Last reply Feb 2, 2021, 12:51 PM Reply Quote 0
        • G
          george1421 Moderator @Sebastian Roth
          last edited by Feb 2, 2021, 12:37 PM

          @sebastian-roth said in langage de programmation:

          Should be mount /dev/sda1 /ext (space in between!)

          Yes I saw that too.

          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
          • J
            julio @george1421
            last edited by Feb 2, 2021, 12:51 PM

            @george1421 salut george, oui j’utilise uniquement des ordinateurs linux et je voulais savoir j’utlise le script que tu viens de m’envoyer et comment je pourrais modifier cela à mon besion.

            par exemple je vois partition ntfs cà c’est windows pour linux je remplace avec ext4 ou ext. et le osid 50 mais là je vois osid in 5/6/9 etc.

            G 1 Reply Last reply Feb 2, 2021, 1:10 PM Reply Quote 0
            • G
              george1421 Moderator @julio
              last edited by george1421 Feb 2, 2021, 7:11 AM Feb 2, 2021, 1:10 PM

              @julio I was thinking something like this:

              #!/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
                                  ntfsstatus="$?"
                                  if [[ ! $ntfsstatus -eq 0 ]]; then
                                      echo "Skipped"
                                      continue
                                  fi
                                  if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then
                                      echo "Not found"
                                      umount /ntfs >/dev/null 2>&1
                                      continue
                                  fi
                                  echo "Success"
                                  break
                                  ;;
                              *)
                                  echo " * Partition $part not NTFS filesystem"
                                  ;;
                          esac
                      done
                      if [[ ! $ntfsstatus -eq 0 ]]; then
                          echo "Failed"
                          debugPause
                          handleError "Failed to mount $part ($0)\n    Args: $*"
                      fi
                      echo "Done"
                      debugPause
                      . ${postdownpath}fog.copydrivers
                      # . ${postdownpath}fog.updateunattend
                      umount /ntfs
                      ;;
                 50)
                      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
                                  ntfsstatus="$?"
                                  if [[ ! $ntfsstatus -eq 0 ]]; then
                                      echo "Skipped"
                                      continue
                                  fi
                                  if [[ ! -d /ntfs/etc ]]; then
                                      echo "Not found"
                                      umount /ntfs >/dev/null 2>&1
                                      continue
                                  fi
                                  echo "Success"
                                  break
                                  ;;
                              *)
                                  echo " * Partition $part not linux root filesystem"
                                  ;;
                          esac
                      done
                      if [[ ! $ntfsstatus -eq 0 ]]; then
                          echo "Failed"
                          debugPause
                          handleError "Failed to mount $part ($0)\n    Args: $*"
                      fi
                      echo "Done"
                      debugPause
                      # at this point the root file system will be mounted on /ntfs
                      . ${postdownpath}fog.renamehost.sh
                      umount /ntfs
                      ;;
                  *)
                      echo "Unknown OS Deployment"
                      debugPause
                      return
                      ;;
              esac
              

              Understand I did not test this code at all. This code may be more complex than you need if only you set the hostname. The script you have will work if you fix what Sebastian posted about your mount command. I just wanted to show you that you can make the core more responsive if your root partition is not always /dev/sda1. In some cases like UEFI disk format /dev/sda1 is the UEFI boot partition and not the OS root partition. Your code would fail if that was the case. Or if your hard drive is a NVMe type then /dev/sda (points to sata) would be wrong and the script would fail because nvme disk have a different partition structure.

              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!

              J 2 Replies Last reply Feb 2, 2021, 1:31 PM Reply Quote 0
              • J
                julio @Sebastian Roth
                last edited by Feb 2, 2021, 1:24 PM

                @sebastian-roth oui j’ai modifier mon fichier mais jusque là pas de changement au niveau du hotsname. mount /dev/sda1 /ext

                1 Reply Last reply Reply Quote 0
                • J
                  julio @george1421
                  last edited by Feb 2, 2021, 1:31 PM

                  @george1421 en passant george je travail sur des VM sur virtualbox et lors de la création de mon pc ubuntu desktop, j’ai partitionner mon dique dur virtuel. es ce cela le problème.

                  G 1 Reply Last reply Feb 2, 2021, 1:40 PM Reply Quote 0
                  • J
                    julio @george1421
                    last edited by Feb 2, 2021, 1:39 PM

                    @george1421 oui george, voici à quoi ressemble ma partition sur la machine cliente ubuntu.partion3.PNG partion2.PNG partion1.PNG

                    G 1 Reply Last reply Feb 2, 2021, 1:46 PM Reply Quote 0
                    • G
                      george1421 Moderator @julio
                      last edited by Feb 2, 2021, 1:40 PM

                      @julio said in langage de programmation:

                      en passant george je travail sur des VM sur virtualbox et lors de la création de mon pc ubuntu desktop, j’ai partitionner mon dique dur virtuel. es ce cela le problème.

                      No works the same. I was just warning if you use real hardware that it could change the way your script runs because hardware changes.

                      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!

                      J 1 Reply Last reply Feb 2, 2021, 1:46 PM Reply Quote 0
                      • J
                        julio @george1421
                        last edited by Feb 2, 2021, 1:46 PM

                        @george1421 juste pour me rassurer, je ne vais pas par hasard modifier mon fichier host…

                        G 1 Reply Last reply Feb 2, 2021, 1:47 PM Reply Quote 0
                        • G
                          george1421 Moderator @julio
                          last edited by Feb 2, 2021, 1:46 PM

                          @julio I will give you a hint to maybe help you with your scripting.

                          FOG has a special mode you can use to debug your programs right on the target computer. So do the following.

                          1. Register your VM with fog (if you have not done so already)
                          2. Schedule a new deployment task, but before you press the Schedule Task button, enable the Debug checkbox, then schedule the task.
                          3. PXE boot the target computer.
                          4. After several screens of text, you can clear by pressing the ENTER key. You will land on the FOS LINUX command prompt.

                          Now run lsblk to find your hard drive. See if you can find from lsblk your root partition.

                          Now manually run

                          mkdir -p /ntfs
                          mount /dev/sdaX /ntfs
                          

                          Just as a test run the echo command the variable ${hostname} will not be set yet so you can’t use it here. But you can find out the right location and partition to use. You will not see all of the loop devices that ubuntu creates so it will be clear what partitions you want.

                          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!

                          J 3 Replies Last reply Feb 2, 2021, 1:51 PM Reply Quote 0
                          • G
                            george1421 Moderator @julio
                            last edited by Feb 2, 2021, 1:47 PM

                            @julio said in langage de programmation:

                            juste pour me rassurer, je ne vais pas par hasard modifier mon fichier host…

                            This is why I suggested to test your program using FOS Linux in debug mode. No chance to break your FOG server.

                            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
                            • J
                              julio @george1421
                              last edited by Feb 2, 2021, 1:51 PM

                              @george1421 j’essaye ça et je te tiens au courant merci beaucoup.

                              1 Reply Last reply Reply Quote 0
                              • S
                                Sebastian Roth Moderator
                                last edited by Feb 2, 2021, 4:49 PM

                                @julio When you added the echo "OK, osid is 50/Linux" into your script, did you see that message on the console??

                                You might want to add the mentioned read command as well so it waits for your input…

                                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

                                J 1 Reply Last reply Feb 2, 2021, 9:46 PM Reply Quote 0
                                • J
                                  julio @Sebastian Roth
                                  last edited by Feb 2, 2021, 9:46 PM

                                  @sebastian-roth salut roth. non je ne vois rien sur la console de mon serveur fog apparement le script ne fonctionne pas. je veux bien savoir.
                                  comment verifier que le script est bien fonctionnel???
                                  j’ai bien donner les droits d’execution à savoir chmod +x renamehost.sh

                                  1 Reply Last reply Reply Quote 0
                                  • J
                                    julio @george1421
                                    last edited by Feb 2, 2021, 10:34 PM

                                    @george1421 salut george. oui j’ai fais ce que tu m’as démander mais je n’arrive pas sur l’invite de commande de fos linux. y’a t’il pas une autre manière???

                                    G 2 Replies Last reply Feb 2, 2021, 10:40 PM Reply Quote 0
                                    • G
                                      george1421 Moderator @julio
                                      last edited by Feb 2, 2021, 10:40 PM

                                      @julio OK give me 5 minutes and I will give you more hints.

                                      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
                                      • G
                                        george1421 Moderator @julio
                                        last edited by george1421 Feb 2, 2021, 4:56 PM Feb 2, 2021, 10:52 PM

                                        @julio To get into debug mode on the pxe booting computer make sure you enabled debug mode.

                                        Screenshot from 2021-02-02 17-42-30.png

                                        See the Schedule as debug task option? When you do this and pxe boot the target computer you will end at the FOS Linux command prompt.

                                        In your script for debugging purposes you should add

                                        echo "Some step in the script"
                                        debugPause;
                                        

                                        This way you will know when and where your script is in the program. I add these quite often at specific points in my scripts.

                                        Also make sure you add your script like fog.custominstall or renamehost.sh to the master script of fog.postdownload or your script will not be called by fog.

                                        IF you are ready to debug your script AND you are at the FOS Linux command prompt key in fog to start the deployment. The FOG deployment will stop at all of the debugPause commands during deployment. Press enter to go to the next step. When / IF you get to see OK, osid is 50/Linux on the screen and you see a bug you can press CTRL-C to exit the script. The FOG Postinstall scripts are run right after the last partclone copy screen. You can fix what you need then restart the deployment process again by typing fog in again. You can do this testing as many times as you want without needing to reboot the pxe target computer.

                                        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!

                                        J 1 Reply Last reply Feb 3, 2021, 10:40 AM Reply Quote 0
                                        • J
                                          julio @george1421
                                          last edited by Feb 3, 2021, 9:59 AM

                                          @george1421
                                          j’ai reussi à entrer dans la partition de debogage. j’ai executer la commande lsblk. voici ce que j’obtient.partitionparclone.PNG

                                          G 1 Reply Last reply Feb 3, 2021, 10:58 AM Reply Quote 0
                                          • 1
                                          • 2
                                          • 3
                                          • 2 / 3
                                          2 / 3
                                          • First post
                                            21/51
                                            Last post

                                          151

                                          Online

                                          12.0k

                                          Users

                                          17.3k

                                          Topics

                                          155.2k

                                          Posts
                                          Copyright © 2012-2024 FOG Project