Provision with Script
-
@zfeng Of course that assumes you are installing linux on a target computer. If it was a windows OS on the target computer we still could do something similar you would just have to change how the script or PS was launched by updating the windows registry for run once with a FOS Linux post install script.
-
or run the script with the fog client as a snapin
-
@george1421 Thing is getting more clear. However, I still need some help. The reason why I need run script every time after I provision the computer is because with different computer I need to download different stuff for the different computer. Let’s say that I have computerA and computerB that I need to provision. How can I possibly specify argument with script, such as,
Computer=ComputerA ./script.sh
on the home directory? -
@Junkhacker can I run that on the home directory after the computer finishes provisioning? Thanks for jumping in
-
@zfeng variables such as the host name are available for use scripting within FOS. this info comes from the host’s profile that gets created when you register a host with FOG.
-
@zfeng if you give some more info on what the script is actually doing, we might be able to help you find the best solution faster
-
@Junkhacker hostname is part of the script. I also need to do something else such as downloading a particular file with specific variable passed from the argument
-
@zfeng this is very vague
-
@Junkhacker the script will install different projects from git repository. everyone of the them needs to have an argument to install specific package on the computer.
For now, after I complete the provision part, I basically power up the computer and run
Computer=ComputerA ./start.sh
on the home directory. -
@Junkhacker I am sorry for not specific enough
-
@zfeng I’m guessing the image is Linux based?
-
@Tom-Elliott Yes. You guys are very responsive. I appreciate that
-
@zfeng it sounds like George’s method of creating a file in /etc/init.d on the target disk would work well for you. you can find info on creating postdownload scripts by searching on the forums
-
@Junkhacker but how can I pass the argument to that script?
-
@zfeng so if you use post download script you could auto set your start script to have the host name preset
-
@zfeng you could do something like wget -o /root/script.sh <address>/script.sh; echo “Computer=$hostname /root/script.sh” > <drive mount point>/etc/init.d/oneshot.sh
something like that.
-
@Tom-Elliott The best thing I can do now is to try out that, and see what comes. Let’s say I need provision a linux computer with script
Computer=ComputerA ./start.sh
on the home directory. Is there any instruction I can try that out? -
@Junkhacker where should I specify
wget -o /root/script.sh <address>/script.sh; echo “Computer=$hostname /root/script.sh” > <drive mount point>/etc/init.d/oneshot.sh
command? -
@zfeng in a postdownload script, so that it will run when the imaging process completes but before the imaging task completes
-
If you search the tutorials FOG forum I have several on creating postdown scipts to install model specific drivers (for windows). The concepts are the same for what you want to do. You will just mount the target computer’s linux root volume. https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed
https://forums.fogproject.org/topic/9463/fog-postinit-scripts-before-the-magic-begins
and from here: https://forums.fogproject.org/topic/7740/the-magical-mystical-fog-post-download-script/4
These are the list of FOG variables that are available to postdownload scripts.
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 # ?? 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-General