Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

using launchctl in postflight scripts



I need to start both a daemon and agent process using launchctl, but my postinstall/postupgrade scripts run as root.  When I call /bin/launchctl to load the daemon, I get the correct behavior, but to launch the agent, I need to call launchctl as the current session login user, instead of root.  How can I do this from the script?

#!/bin/sh

    pv=`/usr/bin/sw_vers -productVersion`

    if [ "$2" == "/" ] ; then

        case "$pv" in
            10.3.*)
                /usr/libexec/StartupItemContext /System/Library/Extensions/Maxon.kext/Contents/SharedSupport/MaxonAgent.app/Contents/MacOS/MaxonDaemon
                /bin/sleep 1
                /usr/bin/open /System/Library/Extensions/Maxon.kext/Contents/SharedSupport/MaxonAgent.app
                /bin/sleep 1
                /usr/bin/killall -HUP MaxonAgent 2> /dev/null
                ;;
            10.4.*)
                /usr/libexec/StartupItemContext /System/Library/Extensions/Maxon.kext/Contents/SharedSupport/MaxonAgent.app/Contents/MacOS/MaxonDaemon --install
                /bin/sleep 1
                /bin/launchctl load /Library/LaunchDaemons/au.com.maxon.daemon.plist
                /usr/bin/open /System/Library/Extensions/Maxon.kext/Contents/SharedSupport/MaxonAgent.app
                /bin/sleep 1
                /usr/bin/killall -HUP MaxonAgent 2> /dev/null
                ;;
            *)
                /usr/libexec/StartupItemContext /System/Library/Extensions/Maxon.kext/Contents/SharedSupport/MaxonAgent.app/Contents/MacOS/MaxonDaemon --install
                /bin/sleep 1
                /bin/launchctl load /Library/LaunchDaemons/au.com.maxon.daemon.plist
                /bin/launchctl load /Library/LaunchAgents/au.com.maxon.agent.plist
                ;;
        esac

        

        /sbin/kextload /System/Library/Extensions/Maxon.kext/Contents/PlugIns/* 2> /dev/null

        

    fi

    /usr/bin/touch $2System/Library/Extensions

    if [ "$2" == "/" ] ; then

        case "$pv" in
            10.[34].*)
                /usr/bin/killall -HUP kextd 2> /dev/null
                ;;
            *)
                ;;
        esac

        

    fi

exit 0

-- 
Shaun Wexler
MacFOH

My software never has bugs.  It just develops random features.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/installer-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.