Introduction
Using macOS LaunchAgents, it is possible to automatically link to a LucidLink Filespace upon logging in to a local user account on macOS.
Workflow Overview
- Create the script to launch the lucid daemon
- Create the LaunchAgent .plist file
- Test loading and unloading the LaunchAgent
Launch Script Setup
Create a script directory in
/usr/local/bin:
sudo mkdir -p /usr/local/bin
-
Create the
newlucidlaunch.shbash script in/usr/local/binusing your preferred text editor.
sudo nano /usr/local/bin/newlucidlaunch.sh
Using the text editor, add the following content. Be sure to change the Filespace, username, and password to your own details (omitting the <> brackets).
#!/bin/bash
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
lucid daemon --fs filespace.domain --user <yourEmail> --password <password> --mount-point ~/Lucid
Save
newlucidlaunch.shand make it executable:
sudo chmod +x /usr/local/bin/newLucidLaunch.sh
LaunchAgent Property List Setup
1. Create the property list file in /Library/LaunchAgents:
sudo nano /Library/LaunchAgents/com.newlucidlink.startup.plist
Inside the nano editor, add the following:
<?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>com.newlucidlink.startup</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/newlucidlaunch.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/com.newlucidlink.startup.out</string>
<key>StandardErrorPath</key>
<string>/tmp/com.newlucidlink.startup.err</string>
</dict>
</plist>
Test Loading and Unloading the LaunchAgent
1. Load the LaunchAgent plist:
launchctl bootstrap gui/$(id -u) /Library/LaunchAgents/com.newlucidlink.startup.plist
Verify the Filespace has mounted.
If it hasn’t, check the logs generated at: /tmp/com.lucidlink.startup.err
2. To unload the LaunchAgent.
launchctl bootout gui/$(id -u) /Library/LaunchAgents/com.newlucidlink.startup.plist
3. Perform a Final Test by logging out and back into the macOS user account and verifying that the LaunchAgent has successfully mounted the Filespace.