My script only runs after logging into the user FooUser
. I would like to bash file to run before login. I am not sure why it only runs after user login.
The plist and path for boot-script.plist
:
/Library/LaunchAgents/boot-script.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>boot-script</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/boot.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
The bash script and path for boot.sh
:
/usr/local/bin/boot.sh
#!/bin/bash
function startup(){
cd /Users/FooUser/Desktop
touch FooFile
}
startup;
I believe this is the proper setup for startup processes, having the plist stored in the LaunchAgents
launchctl load -w boot-script.plist
boot-script.plist owner is root and group is wheel
boot.sh permission set to executable