blob: 6c37f2a597bb193dc19166f241aa1585a895c090 [file] [log] [blame]
#!/bin/sh
# Copyright 2013 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
DIR="$( cd "$( dirname "$0" )" && pwd )"
if [ $(uname -s) == 'Darwin' ]; then
TARGET_DIR='/Library/Google/Chrome/NativeMessagingHosts'
else
TARGET_DIR='/etc/opt/chrome/native-messaging-hosts'
fi
HOST_NAME=com.google.chrome.example.echo
# Create directory to store native messaging host.
mkdir -p $TARGET_DIR
# Copy native messaging host manifest.
cp $DIR/$HOST_NAME.json $TARGET_DIR
# Update host path in the manifest.
HOST_PATH=$DIR/native-messaging-example-host
ESCAPED_HOST_PATH=${HOST_PATH////\\/}
sed -i -e "s/HOST_PATH/$ESCAPED_HOST_PATH/" $TARGET_DIR/$HOST_NAME.json
# Set permissions for the manifest so that all users can read it.
chmod o+r $TARGET_DIR/$HOST_NAME.json
echo Native messaging host $HOST_NAME has been installed.