Roger.postdonload et variable environnement
- 
 I would like to write a text file in “/ etc” after deploying the ubuntu client with fog. 
 I found on the internet a script to rename the pc that works very well
 but I would also like to write the name of the group that serves as a reference for an application per room
- 
 You need to use a post install script to do “stuff” after imaging is complete and before the first boot of the target OS. As for changing the system name, you can do it in the post install script or if you use the fog client on the *nix box then the fog client will do that for you too. 
- 
 I want to write text files with 
 Écho $groupename > /ext/etc/Groupon
 On the client fog
 But what the environ variable ?
- 
 @olivier-c 
 Change this file on your server:/images/postdownloadscripts/fog.postdownloadto read as:#!/bin/bash ## 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}/write_etc_file.shThen you could create this script: /images/postdownloadscripts/write_etc_file.shand mark it as executable.
 Then fill it with whatever echo statements and logic you want:#!/bin/bash file='/etc/some/blah.conf' echo "some config" > $file echo "some more config" >> $fileFor that above script to work, you will need to mount the disk that you just imaged to some directory at the start of that script, and then execute those commands using the new mounted directory. So this implies you know some things about the hosts, such as if they are using /dev/sda or /dev/sda1 or /dev/sdb2 or whatever. As far as the names and functions and such, thanks to @george1421 we have a great description of them here (that I’ve added a little to also): #The below are from sourcing the funcs.sh script. # ftp # IP Address from Storage Management-General # hostname # Host Name from Host Managment-General # img # Image Name from Image Management-General # mac # Primary MAC from Image Management-General # osid # Host Image Index number from Image Management-General # storage # IP Address + Image Path from Storage Management-General # storageip # IP Address from Storage Management-General # web #IP Address + Web root from Storage Management-General #The below are from querying the fog server. # shutdown # Shut down at the end of imaging # hostdesc #Host Description from Host Managment-General # hostip # IP address of the FOS client # hostimageid # ID of image being deployed # hostbuilding # Left over from very old versions of fog, not used anymore. # hostusead # Join Domain after image task from Host Management-Active Directory # hostaddomain # Domain name from Host Management-Active Directory # hostaduser # Domain Username from Host Management-Active Directory # hostadou # Organizational Unit from Host Management-Active Directory # hostproductkey= # Host Product Key from Host Management-Active Directory # imagename # Image Name from Image Management-General # imagedesc # Image Description from Image Management-General # imageosid # Operating System from Image Management-General # imagepath # Image Path from Image Management-General (/images/ assumed) # primaryuser # Primary User from Host Management-Inventory # othertag # Other Tag #1 User from Host Management-Inventory # othertag1 # Other Tag #2 from Host Management-Inventory # sysman # System Manufacturer from Host Management-Inventory (from SMBIOS) # sysproduct # System Product from Host Management-Inventory (from SMBIOS) # sysserial # System Serial Number from Host Management-Inventory (from SMBIOS) # mbman # Motherboard Manufacturer from Host Management-Inventory (from SMBIOS) # mbserial # Motherboard Serial Number from Host Management-Inventory (from SMBIOS) # mbasset # Motherboard Asset Tag from Host Management-Inventory (from SMBIOS) # mbproductname # Motherboard Product Name from Host Management-Inventory (from SMBIOS) # caseman # Chassis Manufacturer from Host Management-Inventory (from SMBIOS) # caseserial # Chassis Serial from Host Management-Inventory (from SMBIOS) # caseasset # Chassis Asset from Host Management-Inventory (from SMBIOS) # location # Host Location (name) from Host Management-GeneralYou can find a full tutorial written on FOG postdownload scripts here: 
 https://forums.fogproject.org/topic/7740/the-magical-mystical-fog-post-download-scriptThis stuff is also completely valid for fog postinitscripts too, which are scripts that run just before FOS begins the imaging process (typically only used for data destruction or backup). 
- 
 thank you 
 i put all in my script
 but some of the environment variable is not there
 I would like to retrieve the value of the fog group to write in the firefox settingsecho $groupname > /ext/etc/GM_ESU gm_esu=$(cat /etc/GM_ESU) echo ‘// 
 lockPref(“autoadmin.global_config_url”, "file:///tmp/netlogon/icones/’$gm_esu’/linux/firefox.js"); '> /usr/lib/firefox/firefox.cfgthe purpose of the script is to deploy linux clients in a school by fog without having to go back to the posts to change the client settings 
 the name change works the group setting associated with the class room.my script #!/bin/bash ##détection de l’OS, 50 pour les Linux 
 if [[ “$osid” == “50” ]];then
 ##création d’un répertoire temporaire
 mkdir /ext
 ##montage temporaire de la partition système du Linux
 mount /dev/sda1 /ext
 ##changement du nom host de la machine définie dans l’interface web
 echo $hostname > /ext/etc/hostname
 echo "127.0.0.1 localhost
 127.0.1.1 $hostnameThe following lines are desirable for IPv6 capable hosts 
 ::1 ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters" > /ext/etc/hosts#ecriture du groupe 
 echo $ftp > /ext/etc/groupefog
 echo $hostname >> /ext/etc/groupefog
 echo $img >> /ext/etc/groupefog
 echo $mac >> /ext/etc/groupefog
 echo $osid >> /ext/etc/groupefog
 echo $storage >> /ext/etc/groupefog
 echo $storageip >> /ext/etc/groupefog
 echo $web >> /ext/etc/groupefogecho autre >> /ext/etc/groupefog 
 echo $shutdown >> /ext/etc/groupefog
 echo $hostdesc >> /ext/etc/groupefog
 echo $hostip >> /ext/etc/groupefog
 echo $hostimageid >> /ext/etc/groupefog
 echo $hostbuilding >> /ext/etc/groupefog
 echo $hostusead >> /ext/etc/groupefog
 echo $hostaddomain >> /ext/etc/groupefog
 echo $hostaduser >> /ext/etc/groupefog
 echo $hostadou >> /ext/etc/groupefog
 echo $hostproductkey >> /ext/etc/groupefog
 echo $imagename >> /ext/etc/groupefog
 echo $imagedesc >> /ext/etc/groupefog
 echo $imageosid >> /ext/etc/groupefog
 echo $imagepath >> /ext/etc/groupefog
 echo $primaryuser >> /ext/etc/groupefog
 echo $othertag >> /ext/etc/groupefog
 echo $othertag1 >> /ext/etc/groupefog
 echo $sysman >> /ext/etc/groupefog
 echo $sysproduct >> /ext/etc/groupefog
 echo $sysserial >> /ext/etc/groupefog
 echo $mbman >> /ext/etc/groupefog
 echo $mbserial >> /ext/etc/groupefog
 echo $mbasset >> /ext/etc/groupefog
 echo $mbproductname >> /ext/etc/groupefog
 echo $caseman >> /ext/etc/groupefog
 echo $caseserial >> /ext/etc/groupefog
 echo $caseasset >> /ext/etc/groupefog
 echo $location >> /ext/etc/groupefog##Démontage de la partition système 
 umount /ext
 ##Suppression du répertoire temporaire
 rmdir /ext
 fiand the résult : grourpefog: echo $ftp > /ext/etc/groupefog 172.18.40.3 
 echo $hostname >> /ext/etc/groupefog L05-ORD00242
 echo $img >> /ext/etc/groupefog ubuntu1604_ssd128
 echo $mac >> /ext/etc/groupefog 70:4d:7b:2e:0e:e9
 echo $osid >> /ext/etc/groupefog 50
 echo $storage >> /ext/etc/groupefog 172.18.40.3:/images/
 echo $storageip >> /ext/etc/groupefog 172.18.40.3
 echo $web >> /ext/etc/groupefog http://172.18.40.3/fog/echo autre autre 
 echo $shutdown >> /ext/etc/groupefog
 echo $hostdesc >> /ext/etc/groupefog
 echo $hostip >> /ext/etc/groupefog
 echo $hostimageid >> /ext/etc/groupefog
 echo $hostbuilding >> /ext/etc/groupefog
 echo $hostusead >> /ext/etc/groupefog
 echo $hostaddomain >> /ext/etc/groupefog
 echo $hostaduser >> /ext/etc/groupefog
 echo $hostadou >> /ext/etc/groupefog
 echo $hostproductkey >> /ext/etc/groupefog
 echo $imagename >> /ext/etc/groupefog
 echo $imagedesc >> /ext/etc/groupefog
 echo $imageosid >> /ext/etc/groupefog
 echo $imagepath >> /ext/etc/groupefog
 echo $primaryuser >> /ext/etc/groupefog
 echo $othertag >> /ext/etc/groupefog
 echo $othertag1 >> /ext/etc/groupefog
 echo $sysman >> /ext/etc/groupefog System manufacturer
 echo $sysproduct >> /ext/etc/groupefog System Product Name
 echo $sysserial >> /ext/etc/groupefog System Serial Number
 echo $mbman >> /ext/etc/groupefog ASUSTeK COMPUTER INC.
 echo $mbserial >> /ext/etc/groupefog 161085607908324
 echo $mbasset >> /ext/etc/groupefog Default string
 echo $mbproductname >> /ext/etc/groupefog H110M-A/M.2
 echo $caseman >> /ext/etc/groupefog Default string
 echo $caseserial >> /ext/etc/groupefog Default string
 echo $caseasset >> /ext/etc/groupefog
 echo $location >> /ext/etc/groupefog
- 
 @olivier-c said in Roger.postdonload et variable environnement: I would like to retrieve the value of the fog group to write in the firefox settings You mean the group a host is assigned to I guess!? First, one host can be assigned to several groups so this could be an issue. Second, as far as I know this information is not handed to the client yet and I don’t see why we should do so. Third, you should be able to retrieve the information (group name) via an external API call from the FOG backend. Search the forum on how to use the API. 

