OLD | NEW |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 set -e | 6 set -e |
7 | 7 |
8 DIR="$( cd "$( dirname "$0" )" && pwd )" | 8 DIR="$( cd "$( dirname "$0" )" && pwd )" |
9 if [ $(uname -s) == 'Darwin' ]; then | 9 if [ $(uname -s) == 'Darwin' ]; then |
10 if [ "$(whoami)" == "root" ]; then | 10 if [ "$(whoami)" == "root" ]; then |
11 TARGET_DIR="/Library/Google/Chrome/NativeMessagingHosts" | 11 TARGET_DIR="/Library/Google/Chrome/NativeMessagingHosts" |
12 else | 12 else |
13 TARGET_DIR=\ | 13 TARGET_DIR=" |
14 "$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" | 14 $HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" |
Sergey Ulanov
2014/09/20 17:50:04
This adds spaces in TARGET_DIR, do I don't think y
Patrick Kettner
2014/09/20 18:00:57
It does add a space, however that space doesn't ch
| |
15 fi | 15 fi |
16 else | 16 else |
17 if [ "$(whoami)" == "root" ]; then | 17 if [ "$(whoami)" == "root" ]; then |
18 TARGET_DIR="/etc/opt/chrome/native-messaging-hosts" | 18 TARGET_DIR="/etc/opt/chrome/native-messaging-hosts" |
19 else | 19 else |
20 TARGET_DIR="$HOME/.config/google-chrome/NativeMessagingHosts" | 20 TARGET_DIR="$HOME/.config/google-chrome/NativeMessagingHosts" |
21 fi | 21 fi |
22 fi | 22 fi |
23 | 23 |
24 HOST_NAME=com.google.chrome.example.echo | 24 HOST_NAME=com.google.chrome.example.echo |
25 | 25 |
26 # Create directory to store native messaging host. | 26 # Create directory to store native messaging host. |
27 mkdir -p $TARGET_DIR | 27 mkdir -p "$TARGET_DIR" |
28 | 28 |
29 # Copy native messaging host manifest. | 29 # Copy native messaging host manifest. |
30 cp $DIR/$HOST_NAME.json $TARGET_DIR | 30 cp $DIR/$HOST_NAME.json "$TARGET_DIR" |
31 | 31 |
32 # Update host path in the manifest. | 32 # Update host path in the manifest. |
33 HOST_PATH=$DIR/native-messaging-example-host | 33 HOST_PATH=$DIR/native-messaging-example-host |
34 ESCAPED_HOST_PATH=${HOST_PATH////\\/} | 34 ESCAPED_HOST_PATH=${HOST_PATH////\\/} |
35 sed -i -e "s/HOST_PATH/$ESCAPED_HOST_PATH/" $TARGET_DIR/$HOST_NAME.json | 35 sed -i -e "s/HOST_PATH/$ESCAPED_HOST_PATH/" "$TARGET_DIR/$HOST_NAME.json" |
36 | 36 |
37 # Set permissions for the manifest so that all users can read it. | 37 # Set permissions for the manifest so that all users can read it. |
38 chmod o+r $TARGET_DIR/$HOST_NAME.json | 38 chmod o+r "$TARGET_DIR/$HOST_NAME.json" |
39 | 39 |
40 echo Native messaging host $HOST_NAME has been installed. | 40 echo Native messaging host $HOST_NAME has been installed. |
OLD | NEW |