Postdownload Scripts



  • I’m curious if there’s a way to have the postdownload scripts only run for certain images and not all of them.



  • Like @Tom-Elliott said, the initial postdownload script always runs. However, you can use CASE or IF statements to either call a function or open another script. Here is my current postdownload script that I got from one of @george1421 and his wonderful driver injection scripts found here

    #!/bin/bash
    . /usr/share/fog/lib/funcs.sh
    [[ -z $postdownpath ]] && postdownpath="/images/postdownloadscripts/"
    if [ $img == "Win7BaseVM" ] || [ $img == "Win10BaseVM" ] ; then
    	case $osid in
    	    5|6|7|9)
    	        clear
    	        [[ ! -d /ntfs ]] && mkdir -p /ntfs
    	        getHardDisk
    	        if [[ -z $hd ]]; then
    	            handleError "Could not find hdd to use"
    	        fi
    	        getPartitions $hd
    	        for part in $parts; do
    	            umount /ntfs >/dev/null 2>&1
    	            fsTypeSetting "$part"
    	            case $fstype in
    	                ntfs)
    	                    dots "Testing partition $part"
    	                    ntfs-3g -o force,rw $part /ntfs
    	                    ntfsstatus="$?"
    	                    if [[ ! $ntfsstatus -eq 0 ]]; then
    	                        echo "Skipped"
    	                        continue
    	                    fi
    	                    if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then
    	                        echo "Not found"
    	                        umount /ntf >/dev/null 2>&1
    	                        continue
    	                    fi
    	                    echo "Success"
    	                    break
    	                    ;;
    	                *)
    	                    echo " * Partition $part not NTFS filesystem"
    	                    ;;
    	            esac
    	        done
    	        if [[ ! $ntfsstatus -eq 0 ]]; then
    	            echo "Failed"
    	            debugPause
    	            handleError "Failed to mount $part ($0)\n    Args: $*"
    	        fi
    	        echo "Done"
    	        debugPause
    	        . ${postdownpath}fog.deletelog
    	        . ${postdownpath}fog.drivers
    	        #. ${postdownpath}fog.ad
    	        umount /ntfs
    	        ;;
    	    *)
    	        echo "Non-Windows Deployment"
    	        debugPause
    	        return
    	        ;;
    	esac
    fi
    

    You can see that I have an if statement at the beginning to only run his driver injection script if the image name is one of my golden image VM’s.


  • Senior Developer

    No, it’s a run on everything, or not. Though you can add checks in your post download script to only run commands if the image is a certain name.

    For example, something like:

    case $img in
        ImageNameForDoingStuff)
            # do stuff for this image.
            ;;
        *)
            # do stuff for everything else, or return.
            ;;
    esac
    

 

570
Online

5.4k
Users

12.6k
Topics

118.8k
Posts