Provision with Script

  • Hi guys. I have used Fog for a while and definitely this is a great project and saves a lot of my time on provisioning new machine.

    Does Fog have a feature that allows us to run script after it finishes provisioning, just like building AWS EC2 instance? Could that be a feature request if it does not exist?


  • @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.

  • @Junkhacker thanks for that. I will try that out

  • @george1421 Thanks for that. I will try that out

  • Moderator

    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 or what ever in there create a simple bash script like

    echo "debug my custom script here. Press Ctrl-C to exit now";

    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 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.

  • Moderator

    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.

    and from here:

    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

  • Developer

    @zfeng in a postdownload script, so that it will run when the imaging process completes but before the imaging task completes

  • @Junkhacker where should I specify wget -o /root/ <address>/; echo “Computer=$hostname /root/” > <drive mount point>/etc/init.d/ command?

  • @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 ./ on the home directory. Is there any instruction I can try that out?

  • Developer

    @zfeng you could do something like wget -o /root/ <address>/; echo “Computer=$hostname /root/” > <drive mount point>/etc/init.d/

    something like that.

  • Senior Developer

    @zfeng so if you use post download script you could auto set your start script to have the host name preset

  • @Junkhacker but how can I pass the argument to that script?

  • Developer

    @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

  • @Tom-Elliott Yes. You guys are very responsive. I appreciate that

  • Senior Developer

    @zfeng I’m guessing the image is Linux based?

  • @Junkhacker I am sorry for not specific enough

  • @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 ./ on the home directory.

  • Developer

    @zfeng this is very vague

  • @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

  • Developer

    @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

Log in to reply