#!/bin/sh

launchd_load()
{
    # most likely it's loaded..
    echo "Attempting to unload $1.."
    /bin/launchctl unload "$1"
    echo "Attempting to load $1.."
    /bin/launchctl load "$1"
}


# load the LaunchDaemons only if we're installing to the currently-booted volume
if [ "$3" = "/" ]; then
    echo "Installation is to the currently-booted volume."
    launchd_load "/Library/LaunchDaemons/com.github.autopkg.autopkgserver.plist"
    launchd_load "/Library/LaunchDaemons/com.github.autopkg.autopkginstalld.plist"
else
    echo "Installation is to non-booted volume."
fi

exit 0
