set -u my_app_launchd_service="Library/LaunchDaemons/${my_app_pkg_name}.plist" install_for_launchd() { echo "" echo "Installing as launchd service" echo "" # See http://www.launchd.info/ mkdir -p $(dirname "$my_app_dir/$my_app_launchd_service") dap_dl "$installer_base/$my_app_launchd_service" "$my_app_dir/$my_app_launchd_service" $sudo_cmd mv "$my_app_dir/$my_app_launchd_service" "$my_root/$my_app_launchd_service" $sudo_cmd chown root:wheel "$my_root/$my_app_launchd_service" $sudo_cmd chmod 0644 "$my_root/$my_app_launchd_service" $sudo_cmd launchctl unload -w "$my_root/$my_app_launchd_service" >/dev/null 2>/dev/null $sudo_cmd launchctl load -w "$my_root/$my_app_launchd_service" echo "$my_app_name started with launchd" }