This article is intended to fulfill the need to run a script upon login using Addigy's Custom Software. For information on creating Custom Software check out our Creating Custom Software KB article.
To set up a script to run at login, you will need to create either a Launch Daemon or a Launch Agent. A Launch Daemon will run the script as root, while a Launch Agent will run as the logged-in user. This is determined on which folder the settings defined by the property list, also known as a .plist, is copied to:
/Library/LaunchDaemon = run as root
/Library/LaunchAgents = run as logged-in user
Your Custom Software will need two files:
1. The script that you want to run at login
2. The previously mentioned .plist
To create the .plist copy this text and save it as a .plist.
Note: Make sure the Program key has the correct path to the script.
|<?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">|
For the Installation Script of the Custom Software, you will need to change the permission of the script, move the files to either /Library/LaunchDaemon or /Library/LaunchAgents, and then finally load the plist.
This is what the Installation Script will look like.
Note: Replace Name_of_Script, Name_of_Property_List.plist, and which folder to move the .plist to:
This is what the finished Custom Software will look like. In this example I set up a Launch Agent that will mount a network drive to the device:
Additional: The mapnetdrive.sh contains this code: