diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-22 00:40:13 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-22 00:40:13 +0000 |
commit | 1936c46b5190c9e1caf0e102fa5b7a571d8b7f0a (patch) | |
tree | 746c5b5930369dc889b50eaa428620e64fbf729c /remoting/tools | |
parent | c5f057dbbb26bced0b549a6e4f5eb9d120d55627 (diff) | |
download | chromium_src-1936c46b5190c9e1caf0e102fa5b7a571d8b7f0a.zip chromium_src-1936c46b5190c9e1caf0e102fa5b7a571d8b7f0a.tar.gz chromium_src-1936c46b5190c9e1caf0e102fa5b7a571d8b7f0a.tar.bz2 |
Add helper script that registers local NM hosts on user level.
The script is useful for testing locally built NM hosts
without building the whole package.
R=lambroslambrou@chromium.org
Review URL: https://codereview.chromium.org/168603005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/tools')
-rwxr-xr-x | remoting/tools/register_local_nm_hosts.sh | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/remoting/tools/register_local_nm_hosts.sh b/remoting/tools/register_local_nm_hosts.sh new file mode 100755 index 0000000..b59bf21 --- /dev/null +++ b/remoting/tools/register_local_nm_hosts.sh @@ -0,0 +1,114 @@ +#!/bin/sh +# Copyright 2014 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. +# +# Script that can be used to register native messaging hosts in the output +# directory. + +set -e + +SRC_DIR="$(readlink -f "$(dirname "$0")/../..")" +ME2ME_HOST_NAME="com.google.chrome.remote_desktop" +IT2ME_HOST_NAME="com.google.chrome.remote_assistance" + +install_manifest() { + local manifest_template="$1" + local host_path="$2" + local host_path_var_name="$3" + local target_dir="$4" + + local template_name="$(basename ${manifest_template})" + local manifest_name="${template_name%.*}" + local target_manifest="${target_dir}/${manifest_name}" + + echo Registering ${host_path} in ${target_manifest} + mkdir -p "${target_dir}" + sed -e "s#{{ ${host_path_var_name} }}#${host_path}#g" \ + < "$manifest_template" > "$target_manifest" +} + +register_hosts() { + local build_dir="$1" + local chrome_data_dir="$2" + + install_manifest \ + "${SRC_DIR}/remoting/host/setup/${ME2ME_HOST_NAME}.json.jinja2" \ + "${build_dir}/remoting_native_messaging_host" \ + ME2ME_HOST_PATH "${chrome_data_dir}" + + install_manifest \ + "${SRC_DIR}/remoting/host/it2me/${IT2ME_HOST_NAME}.json.jinja2" \ + "${build_dir}/remoting_it2me_native_messaging_host" \ + IT2ME_HOST_PATH "${chrome_data_dir}" +} + +register_hosts_for_all_channels() { + local build_dir="$1" + + if [ $(uname -s) == "Darwin" ]; then + register_hosts "${build_dir}" \ + "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts" + register_hosts "${build_dir}" \ + "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts" + else + register_hosts "${build_dir}" \ + "${HOME}/.config/google-chrome/NativeMessagingHosts" + register_hosts "${build_dir}" \ + "${HOME}/.config/google-chrome-beta/NativeMessagingHosts" + register_hosts "${build_dir}" \ + "${HOME}/.config/google-chrome-unstable/NativeMessagingHosts" + register_hosts "${build_dir}" \ + "${HOME}/.config/chromium/NativeMessagingHosts" + fi +} + +unregister_hosts() { + local chrome_data_dir="$1" + + rm -f "${chrome_data_dir}/${ME2ME_HOST_NAME}.json" + rm -f "${chrome_data_dir}/${IT2ME_HOST_NAME}.json" +} + +unregister_hosts_for_all_channels() { + if [ $(uname -s) == "Darwin" ]; then + unregister_hosts \ + "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts" + unregister_hosts \ + "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts" + else + unregister_hosts "${HOME}/.config/google-chrome/NativeMessagingHosts" + unregister_hosts "${HOME}/.config/google-chrome-beta/NativeMessagingHosts" + unregister_hosts \ + "${HOME}/.config/google-chrome-unstable/NativeMessagingHosts" + unregister_hosts "${HOME}/.config/chromium/NativeMessagingHosts" + fi +} + +print_usage() { + echo "Usage: $0 [-r|-u]" >&2 + echo " -r Register Release build instead of Debug" >&2 + echo " -u Unregister" >&2 +} + +build_dir="Debug" + +if [[ $# -gt 1 ]]; then + print_usage +elif [[ $# -eq 1 ]]; then + case "$1" in + "-r") + build_dir="Release" + ;; + "-u") + unregister_hosts_for_all_channels + exit 0 + ;; + *) + print_usage + exit 1 + ;; + esac +fi + +register_hosts_for_all_channels "${SRC_DIR}/out/${build_dir}" |