remoting_preflight.sh revision 5821806d5e7f356e8fa4b058a389a808ea183019
1#!/bin/sh 2 3# Copyright (c) 2012 The Chromium Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7# Version = @@VERSION@@ 8 9HELPERTOOLS=/Library/PrivilegedHelperTools 10NAME=org.chromium.chromoting 11CONFIG_FILE="$HELPERTOOLS/$NAME.json" 12PLIST=/Library/LaunchAgents/org.chromium.chromoting.plist 13ENABLED_FILE="$HELPERTOOLS/$NAME.me2me_enabled" 14ENABLED_FILE_BACKUP="$ENABLED_FILE.backup" 15 16trap onexit ERR 17 18function onexit { 19 # Log an error but don't report an install failure if this script has errors. 20 logger An error occurred while launching the service 21 exit 0 22} 23 24logger Running Chrome Remote Desktop preflight script @@VERSION@@ 25 26# If there is an _enabled file, rename it while upgrading. 27if [[ -f "$ENABLED_FILE" ]]; then 28 mv "$ENABLED_FILE" "$ENABLED_FILE_BACKUP" 29fi 30 31# Stop and unload the service. 32set `ps aux | grep loginwindow.app | grep -v grep` 33USERNAME=$1 34USERID=$2 35if [[ -n "$USERNAME" && -n "$USERID" ]]; then 36 launchctl bsexec "$USERID" sudo -u "$USERNAME" launchctl stop "$NAME" 37 launchctl bsexec "$USERID" sudo -u "$USERNAME" launchctl unload -w -S Aqua "$PLIST" 38fi 39