Sample Preinstall and Postinstall Script for Composer

New Contributor

Hi All,

I have 1.dat file which has license that needs to be placed in central network share and one more 2.dat file which needs to be placed in /users/shared/xyz/2.dat in all client machines.

Can I have sample script to place 1.dat file in central share?
and another post install script to place 2.dat file in /users/shared/xyz/2.dat.

Thanks in advance


Valued Contributor

@vmalapati Once you are in composer, you can just drag the .dat files from the locations you want to place them in and it should configure everything itself (placing the files wise). No install scripts should be needed just to place the files in locations on the machine. I see you are planning on placing one of the files into a central network share. If I were you, I would put a pre-install script to make sure that the volume you want to place the .dat file into is available and if not, abort the process and require the user to mount the share. You will need a post install script if you are planning on installing these on the system, but it seems you just need them placed in these locations so it should not be an issue.


New Contributor

@jared_f Thanks a lot Jared. I am looking for those pre-install and post install scripts. If you have any sample scripts can you please post me.

Thanks again

Valued Contributor

@vmalapati This is what we do.

We put the necessary user-specific files in a known location in Composer - we use /private/tmp (this way it's effectively hidden and when the machine is restarted it's removed unless we remove it manually). We then have a postinstall script copy or move it from the known location to the desired location for the user. Example given your situation:



# If license one exists, copy it to user location
if [ -f "$LICENSEONE" ]; then
    cp "$LICENSEONE" /path/to/desired/user/location

# If license two exists, copy it to user location
if [ -f "$LICENSETWO" ]; then
    cp "$LICENSETWO" /path/to/desired/user/location


You could also add some error checking to make sure each step of the postinstall script completes successfully.