macOS launchd LaunchAgent daemon

  • Updated

1. Create user script directory in ~/

    mkdir ~/Scripts

2. Create lucidlaunch.sh bash

   nano ~/Scripts/lucidlaunch.sh
    #!/bin/bash
    lucid daemon --fs <filespace.domain> --user <username> --password <password> --mount-point ~/Lucid

3. Save lucidlaunch.sh and make executable

  chmod +x ~/Scripts/lucidlaunch.sh

4. Create property list file

  sudo nano /Library/LaunchAgents/com.startup.plist
    <?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>EnvironmentVariables</key>
        <dict>
        <key>PATH</key>
        <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:</string>
        </dict>
        <key>Label</key>
        <string>com.startup</string>
        <key>Program</key>
        <string>/Users/<username>/Scripts/lucidlaunch.sh</string>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <false/>
        <key>LaunchOnlyOnce</key>        
        <true/>
        <key>StandardOutPath</key>
        <string>/tmp/startup.stdout</string>
        <key>StandardErrorPath</key>
        <string>/tmp/startup.stderr</string>
        <key>UserName</key>
        <string>admin</string>
        <key>GroupName</key>
        <string>admin</string>
        <key>InitGroups</key>
        <true/>
    </dict>
    </plist>

5. Load plist

    sudo launchctl load -w /Library/LaunchAgents/com.startup.plist

6. Remove with Unload

    sudo launchctl unload -w /Library/LaunchAgents/com.startup.plist
 
 

Was this article helpful?

0 out of 0 found this helpful