Provision with Script
-
@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
-
So you might ask how would you even begin to debug and/or write one of these scripts?
Simple you would go in a create your own bash script in /images/postinstall directory call it something like fog.aws or what ever in there create a simple bash script like
#!/bin/bash echo "debug my custom script here. Press Ctrl-C to exit now"; debugPause;
Link that script into the master fog.postdownload script. And then schedule a deployment. Before you hit the schedule task button, tick the debug check box. Then pxe boot the target computer. After a few screens of text where you need to clear with the enter key you will be dropped to the FOS Linux command prompt in debug mode. Key in
fog
to start the master fog script. The master fog script will stop at each break point waiting for you to press the enter key to move to the next debugPause statement. When you see the message you created in your fog.aws script, hit ctrl-C and exit out of the FOG installer script. At this point you will be where your post install script should run. Now you can start developing your post install actions. The fog post install script should be in /images/postinstall on the FOS Linux target computer you can edit with vi or what ever else is on FOS Linux. You can mount the disk partitions all of the contents of the disk image should be on the target computer by now. -
@george1421 Thanks for that. I will try that out
-
@Junkhacker thanks for that. I will try that out
-
@george1421 @Junkhacker @Tom-Elliott I see what it does now. I actually tried that out. Basically, it copied the script from fog server and placed that into the target computer. Once the target computer powers up, it will run the script automatically. That actually helps. Thanks for your guys effort. I will close this issue then.