Permissions and Configuration question about creating a package of a script in Composer

psherotov
Contributor

Hello all, 

Here's the scenario, I want to install a script in /Library/Scripts on a computer and I want the script to work :-)

What permissions do I need to set to ensure it will work?

I'm aware of the chmod u+x terminal command to make it executable. After running that command the permissions were listed as -rwxr--r--

However a different script that was successfully packaged and installed using the composer method has different permissions: -rwxr-xr-x Also the owner is root...

Do I need to change/set the owner to root in Composer? And do I need to change the permissions?

Added info for the specific script I had a plist file in LaunchAgents to call the script.

7 REPLIES 7

sdagley
Esteemed Contributor II

@psherotov If the script is going to be called from a LaunchAgent then the calling context will be the logged in user and you'll want to set the following permissions (this is an excerpt from a post install script):

 

/usr/sbin/chown root:admin "/Library/Scripts/script.sh"
/bin/chmod 755 "/Library/Scripts/script.sh"

 

 

@sdagley Thank you for the information! Forgive my ignorance but what does the /usr/sbin/ and /bin/ mean in the context of your snippets? I see it a lot, for me I usually cd to the directory and then type in the commands or drag and drop the script into terminal and then run the commands. I'm sure I'm missing something, I just don't know what :-)

 

sdagley
Esteemed Contributor II

@psherotov I used the full path for the executable that will be run when the chown or chmod commands are used. The built-in shell command 'which' will return the path to a command (e.g. 'which chown' returns '/usr/sbin/chown')

scottb
Honored Contributor

As an aside, if you're using Composer, you can also set file ownership/permissions in there before you build the pkg/dmg.

I just dragged one in to show the checkboxes on the lower, right corner.

scottb_0-1660753627456.png

 

J_Morgan
New Contributor II

Am I missing something – is the only way in Composer to set ownership/permissions to set them individually for each file and folder or is there a way to set them recursively on a folder and have them inherited by subfolders and files within?

sdagley
Esteemed Contributor II

@J_Morgan To replicate permissions in Composer click the ... icon to the right of the permissions grid:  

Screenshot 2024-03-06 at 10.53.13 PM.png

J_Morgan
New Contributor II

Perfect, thanks!