Provision with Script
-
@zfeng Yes FOG Linux has the curl command because it uses that and a few other commands to “talk” to the fog server during imaging.
One could (in a post install script) mount the target hard drive and then use a properly crafted wget or curl call to download a file onto the target hard drive. Unmount the target hard drive then complete the FOG imaging process.
-
@george1421 I think I need to be more precise. Let’s say that the image is deployed properly. Is that a way I can run script just like you can run that on the terminal? For now, after I complete the imaging provision, I have to power up the computer and run customized script to download something and install certain package which is must be done after the imaging process.I am sorry if I did not make the point clear
-
@george1421 I basically want to eliminate the part that I need to run the script after the provision is done.
-
@zfeng You can download the “something” and write it to the target hard drive, but you can not “install it” because it would install within the context of FOS Linux which runs from RAM. When the computer is rebooted fos linux is gone.
BUT what you can do is download something to the target computer and then create a file in /etc/init.d on the target disk (you will probably need to create the sym link in proper init folder so that it will run in the proper startup mode). Lets say you created a file call S99local and in that batch file you placed the commands to run the thing that FOS Linux downloaded and stored on the target computer. Once the script ran it would delete the /etc/init.d/S99local script so it wouldn’t run each time the system booted. That way FOS LInux could download (or copy the something from the FOG server) and when the target computer booted the first time it would run the script to install it.
-
@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.