Home Forums Software InstaDMG LaunchAgent

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #372988
    vogtstev
    Participant

    Hi everyone!!

    I have created a LaunchAgent to run a series of commands when the first user logs in:

    Set computer name based off of webpage query
    Activate SPSS (statistical program needing first boot activation)
    Delete the script and launch agent.
    The script looks something like the following:

    —————————
    #!/bin/sh

    # Modified 060208
    # This script runs on the first login of the machine to finish setting appropriate settings. These are settings
    # that could not be done at first boot.

    # Call Name Computer Sciprt
    /Library/Management/scripts/setcomputername.command

    # Activate SPSS 16
    cd /Applications/SPSS16/SPSS16.0.app/Contents/bin/
    ./licenseafter.sh

    # Remove Files
    rm -R /Library/LaunchAgents/com.gustavus.firstlogin.plist
    rm -R /Library/Management/firstlogin

    —————————–
    [b]The problem:
    [/b]
    I had originally set this up as a LauchDaemon, but these items don’t work correctly unless the user is logging in – they work fine as a log in item as well. The problem is that I am unable to properly execute the computer naming script and then delete the LaunchAgent. I suspect that LaunchAgents don’t run as root, but LaunchDaemons do. Is this correct and is there any way to make it run as root? I have tried adding sudo and su to the sciprt, but that did not work either.
    Let me know if anyone has any ideas!!

    thanks!
    Steve

    #372999
    Patrick Fergus
    Participant

    Your suspicion about rights appears to be correct (under “Timing is everything”):

    [url]http://www.macgeekery.com/tips/some_launchd_recipes[/url]

    To make sure we understand, these items have to run with admin/root privileges but can only run when a user logs in? That’s strange–are they dependent on something relating to the particular user logging in?

    Oh, and shouldn’t that be edu.gustavus.firstlogin.plist ? 😀

    – Patrick

    #373003
    vogtstev
    Participant

    Oops, hahaha. about the .edu. I’ve never noticed I’ve been doing that all year!!! 😀

    Anyway, I can break this down a little more. i just reread my original post and it definitely was kind of confusing.

    # Call Name Computer Sciprt
    /Library/Management/scripts/setcomputername.command
    [b]Doesn’t seem to be running until the user actually logs in. It seems like the login process is happening to fast to happen otherwise. Last year I had this as part of my login hook. I just want it to run once this year. This does not need root privileges to my knowledges. The script is just using scutil to set names.[/b]

    # Activate SPSS 16
    cd /Applications/SPSS16/SPSS16.0.app/Contents/bin/
    ./licenseafter.sh
    [b]This also does not need root privileges. This one is working fine.[/b]

    # Remove Files
    rm -R /Library/LaunchAgents/com.gustavus.firstlogin.plist
    rm -R /Library/Management/firstlogin
    [b]This is where the root privileges come in. I can’t delete /Library/LaunchAgents/com.gustavus.firstlogin.plist without this it seems. In the command line I can only delete if I use sudo or su.[/b]

    Hope that makes more sense!!
    I’m looking at that website now.
    Thanks!!
    Steve

    #373004
    jasonpgignac
    Participant

    Perhaps I’m missing something, but I still don’t understand why you can’t just make it a launchDaemon. What’s up with the computer naming script that it won’t work as a daemon?
    And, if you’re happy with running the other scripts on user login, why not just make them a login hook for whatever account gets logged in the first time the computer is booted up? Then you won’t have to deal with those permissions issues on the last step

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Comments are closed