• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
using launchctl in postflight scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

using launchctl in postflight scripts


  • Subject: using launchctl in postflight scripts
  • From: Shaun Wexler <email@hidden>
  • Date: Tue, 19 Feb 2008 15:13:24 -0800

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
http://www.macfoh.com

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: using launchctl in postflight scripts
      • From: Keith Duncan <email@hidden>
  • Prev by Date: Re: PackageMaker 3.0.1 problems
  • Next by Date: Re: using launchctl in postflight scripts
  • Previous by thread: A Distribution Definition Reference addendum (work in progress)
  • Next by thread: Re: using launchctl in postflight scripts
  • Index(es):
    • Date
    • Thread