summaryrefslogtreecommitdiffstats
path: root/remoting/tools/mac/chromoting-set-channel.sh
blob: ab1e37a9d66a1b4688152f8c51ca4f7e83631f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

set -e -u

ME="$(basename "$0")"
readonly ME

KSADMIN=/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/MacOS/ksadmin
KSPID=com.google.chrome_remote_desktop

usage() {
  echo "Usage: ${ME} <channel>" >&2
  echo "where <channel> is 'beta' or 'stable'" >&2
}

log() {
  local message="$1"
  echo "${message}"
  logger "${message}"
}

checkroot() {
  if [[ "$(id -u)" != "0" ]]; then
     echo "This script requires root permissions" 1>&2
     exit 1
  fi
}

main() {
  local channel="$1"

  if [[ "${channel}" != "beta" && "${channel}" != "stable" ]]; then
    usage
    exit 1
  fi

  local channeltag="${channel}"
  if [[ "${channel}" == "stable" ]]; then
    channeltag=""
  fi

  log "Switching Chrome Remote Desktop channel to ${channel}"

  $KSADMIN --productid "$KSPID" --tag "${channeltag}"

  if [[ "${channel}" == "stable" ]]; then
    echo "You're not done yet!"
    echo "You must now UNINSTALL and RE-INSTALL the latest version of Chrome"
    echo "Remote Desktop to get your machine back on the stable channel."
    echo "Thank you!"
  else
    echo "Switch to ${channel} channel complete."
    echo "You will download ${channel} binaries during the next update check."
  fi
}

checkroot

if [[ $# < 1 ]]; then
  usage
  exit 1
fi

main "$@"