Skip to content

Instantly share code, notes, and snippets.

@bryanzak
Last active May 9, 2017 21:44
Show Gist options
  • Save bryanzak/9180379 to your computer and use it in GitHub Desktop.
Save bryanzak/9180379 to your computer and use it in GitHub Desktop.
Script Runner. This is a Launch Agent and script launcher so we can have a folder of scripts that are run anytime a user logs in. This is very barebones and not even remotely fancy, please feel free to share any feedback or suggestions you might have. Updated 2014-03-04 to support logging
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.yourorg.scriptrunner</string>
<key>ProgramArguments</key>
<array>
<string>/Library/yourorg/ScriptRunner.sh</string>
</array>
<key>QueueDirectories</key>
<array/>
<key>StandardOutPath</key>
<string>/var/log/yourorg-scriptrunner.log</string>
<key>StandardErrorPath</key>
<string>/var/log/yourorg-scriptrunner.log</string>
<key>RunAtLoad</key>
<true/>
<key>WatchPaths</key>
<array/>
</dict>
</plist>
#!/bin/bash
# save this file at /Library/yourorg/ScriptRunner.sh
script_path="${0}"
source_path=$(dirname "${script_path}")
chmod 777 "/var/log/yourorg-scriptrunner.log"
if [ -d "${source_path}/User Login Scripts" ]; then
cd "${source_path}/User Login Scripts"
for item in *; do
echo "### $(date) BEGIN ${item}"
"./${item}"
echo "### $(date) END ${item}"
done
fi
chmod 777 "/var/log/yourorg-scriptrunner.log"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment