Home | History | Annotate | Download | only in mac
      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 set -e -u
      8 
      9 ME="$(basename "$0")"
     10 readonly ME
     11 
     12 KSADMIN=/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/MacOS/ksadmin
     13 KSPID=com.google.chrome_remote_desktop
     14 
     15 usage() {
     16   echo "Usage: ${ME} <channel>" >&2
     17   echo "where <channel> is 'beta' or 'stable'" >&2
     18 }
     19 
     20 log() {
     21   local message="$1"
     22   echo "${message}"
     23   logger "${message}"
     24 }
     25 
     26 checkroot() {
     27   if [[ "$(id -u)" != "0" ]]; then
     28      echo "This script requires root permissions" 1>&2
     29      exit 1
     30   fi
     31 }
     32 
     33 main() {
     34   local channel="$1"
     35 
     36   if [[ "${channel}" != "beta" && "${channel}" != "stable" ]]; then
     37     usage
     38     exit 1
     39   fi
     40 
     41   local channeltag="${channel}"
     42   if [[ "${channel}" == "stable" ]]; then
     43     channeltag=""
     44   fi
     45 
     46   log "Switching Chrome Remote Desktop channel to ${channel}"
     47 
     48   $KSADMIN --productid "$KSPID" --tag "${channeltag}"
     49 
     50   if [[ "${channel}" == "stable" ]]; then
     51     echo "You're not done yet!"
     52     echo "You must now UNINSTALL and RE-INSTALL the latest version of Chrome"
     53     echo "Remote Desktop to get your machine back on the stable channel."
     54     echo "Thank you!"
     55   else
     56     echo "Switch to ${channel} channel complete."
     57     echo "You will download ${channel} binaries during the next update check."
     58   fi
     59 }
     60 
     61 checkroot
     62 
     63 if [[ $# < 1 ]]; then
     64   usage
     65   exit 1
     66 fi
     67 
     68 main "$@"
     69