OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Version = @@VERSION@@ | 7 # Version = @@VERSION@@ |
8 | 8 |
9 HELPERTOOLS=/Library/PrivilegedHelperTools | 9 HELPERTOOLS=/Library/PrivilegedHelperTools |
10 SERVICE_NAME=org.chromium.chromoting | 10 SERVICE_NAME=org.chromium.chromoting |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 return 1 | 51 return 1 |
52 fi | 52 fi |
53 } | 53 } |
54 | 54 |
55 trap on_error ERR | 55 trap on_error ERR |
56 | 56 |
57 logger Running Chrome Remote Desktop preflight script @@VERSION@@ | 57 logger Running Chrome Remote Desktop preflight script @@VERSION@@ |
58 | 58 |
59 # If there is an _enabled file, rename it while upgrading. | 59 # If there is an _enabled file, rename it while upgrading. |
60 if [[ -f "$ENABLED_FILE" ]]; then | 60 if [[ -f "$ENABLED_FILE" ]]; then |
| 61 logger Moving _enabled file |
61 mv "$ENABLED_FILE" "$ENABLED_FILE_BACKUP" | 62 mv "$ENABLED_FILE" "$ENABLED_FILE_BACKUP" |
62 fi | 63 fi |
63 | 64 |
64 # Stop and unload the service for each user currently running the service, and | 65 # Stop and unload the service for each user currently running the service, and |
65 # record the user IDs so the service can be restarted for the same users in the | 66 # record the user IDs so the service can be restarted for the same users in the |
66 # postflight script. | 67 # postflight script. |
67 rm -f "$USERS_TMP_FILE" | 68 rm -f "$USERS_TMP_FILE" |
68 | 69 |
69 for uid in $(find_users_with_active_hosts); do | 70 for uid in $(find_users_with_active_hosts); do |
| 71 logger Unloading service for user "$uid" |
70 if [[ -n "$uid" ]]; then | 72 if [[ -n "$uid" ]]; then |
71 echo "$uid" >> "$USERS_TMP_FILE" | 73 echo "$uid" >> "$USERS_TMP_FILE" |
72 if [[ "$uid" = "0" ]]; then | 74 if [[ "$uid" = "0" ]]; then |
73 context="LoginWindow" | 75 context="LoginWindow" |
74 else | 76 else |
75 context="Aqua" | 77 context="Aqua" |
76 fi | 78 fi |
77 | 79 |
78 sudo_user="sudo -u #$uid" | 80 sudo_user="sudo -u #$uid" |
79 stop="launchctl stop $SERVICE_NAME" | 81 stop="launchctl stop $SERVICE_NAME" |
80 unload="launchctl unload -w -S $context $PLIST" | 82 unload="launchctl unload -w -S $context $PLIST" |
81 | 83 |
82 if is_el_capitan_or_newer; then | 84 if is_el_capitan_or_newer; then |
83 boostrap_user="launchctl asuser $uid" | 85 boostrap_user="launchctl asuser $uid" |
84 else | 86 else |
85 # Load the launchd agent in the bootstrap context of user $uid's | 87 # Load the launchd agent in the bootstrap context of user $uid's |
86 # graphical session, so that screen-capture and input-injection can | 88 # graphical session, so that screen-capture and input-injection can |
87 # work. To do this, find the PID of a process which is running in that | 89 # work. To do this, find the PID of a process which is running in that |
88 # context. The loginwindow process is a good candidate since the user | 90 # context. The loginwindow process is a good candidate since the user |
89 # (if logged in to a session) will definitely be running it. | 91 # (if logged in to a session) will definitely be running it. |
90 pid="$(find_login_window_for_user "$uid")" | 92 pid="$(find_login_window_for_user "$uid")" |
91 if [[ ! -n "$pid" ]]; then | 93 if [[ ! -n "$pid" ]]; then |
92 exit 1 | 94 exit 1 |
93 fi | 95 fi |
94 bootstrap_user="launchctl bsexec $pid" | 96 bootstrap_user="launchctl bsexec $pid" |
95 fi | 97 fi |
96 | 98 |
| 99 logger $bootstrap_user $sudo_user $stop |
97 $bootstrap_user $sudo_user $stop | 100 $bootstrap_user $sudo_user $stop |
| 101 logger $bootstrap_user $sudo_user $unload |
98 $bootstrap_user $sudo_user $unload | 102 $bootstrap_user $sudo_user $unload |
99 fi | 103 fi |
100 done | 104 done |
101 | 105 |
102 exit 0 | 106 exit 0 |
OLD | NEW |