I need to create a package for installing content in a specific folder

33 views Asked by At

I need to create a PKG to install my products in specific locations. I am distributing video templates for Final Cut Pro and need to place the folders with the contents in different locations. I have no experience with coding, and I've been trying to solve this for a few days without success!

If I can create a simple PKG that installs just one folder of the product in the correct location, it would already serve my purpose. I wouldn't mind creating more than one PKG for each template. However, even under these conditions, the furthest I've been able to get is making it work only on my Mac. I believe this is because when executed on another machine, it doesn't account for the change in the username!

Example paths:

Folder 01 - /Users/itallo/Movies/Motion\ Templates.localized/Titles.localized

Folder 02 - /Users/itallo/Movies/Motion\ Templates.localized/Transitions.localized

Folder 03 - /Library/Fonts

I've tried several different approaches, such as this "postinstall.sh" script, but I'm not sure if its construction is correct. As I mentioned earlier, I don't have experience with coding, but either the PKG completely ignores the script, or it simply freezes.

#!/bin/bash

Get the current username

USERNAME=$(stat -f %Su /dev/console)

Desired destination path

DESTINATION_PATH="/Users/$USERNAME/Movies/Motion Templates.localized/Titles.localized"

Check if the destination directory exists

if [ -d "$DESTINATION_PATH" ]; then echo "The destination directory already exists. No action needed." else

 # If it doesn't exist, create the destination directory
 mkdir -p "$DESTINATION_PATH"

 # Move the installed content to the desired directory
 echo "Moving content to the directory: $DESTINATION_PATH"
 mv "$1"/* "$DESTINATION_PATH/"

 # Check if the operation was successful
 if [ $? -eq 0 ]; then
     echo "Move completed successfully."
 else
     echo "Error during the move."
     exit 1
  fi

fi

exit 0

I tried creating it directly through the MacOS Terminal, which is where I got closest to my goal, but still unable to correctly direct the path on other iMacs.

0

There are 0 answers