Skip to content

Commit

Permalink
Merge pull request #4 from wezm/bsd-macos-compat
Browse files Browse the repository at this point in the history
Fix syntax error using BSD flavored sed for macOS and BSD
  • Loading branch information
tuxor1337 authored Mar 25, 2018
2 parents 7821b0b + 9a364e1 commit 1feab77
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/install_host_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ APP_NAME="passff"
VERSION="_VERSIONHOLDER_"
HOST_URL="https://github.com/passff/passff-host/releases/download/$VERSION/passff.py"
MANIFEST_URL="https://github.com/passff/passff-host/releases/download/$VERSION/passff.json"
KERNEL_NAME=$(uname -s)

case "$KERNEL_NAME" in
*BSD*)
IS_BSD=true
;;
*)
IS_BSD=false
;;
esac

# Find target dirs for various browsers & OS'es
# https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location
# https://wiki.mozilla.org/WebExtensions/Native_Messaging
if [ $(uname -s) == 'Darwin' ]; then
if [ "$KERNEL_NAME" == 'Darwin' ]; then
if [ "$(whoami)" == "root" ]; then
TARGET_DIR_CHROME="/Library/Google/Chrome/NativeMessagingHosts"
TARGET_DIR_CHROMIUM="/Library/Application Support/Chromium/NativeMessagingHosts"
Expand Down Expand Up @@ -116,11 +126,18 @@ else
curl -sSL "$MANIFEST_URL" > "$MANIFEST_FILE_PATH"
fi

# Replace path to host
sed -i -e "s/PLACEHOLDER/$ESCAPED_HOST_FILE_PATH/" "$MANIFEST_FILE_PATH"

# Replace path to python3 executable
sed -i "1c#\!${PYTHON3_PATH}" "$HOST_FILE_PATH"
if [ "$KERNEL_NAME" == 'Darwin' ] || [ "$IS_BSD" = true ]; then
# Use BSD style sed on macOS and BSD systems
# Replace path to python3 executable
/usr/bin/sed -i '' "1 s@.*@#\!${PYTHON3_PATH}@" "$HOST_FILE_PATH"
# Replace path to host
/usr/bin/sed -i '' -e "s/PLACEHOLDER/$ESCAPED_HOST_FILE_PATH/" "$MANIFEST_FILE_PATH"
else
# Replace path to python3 executable
sed -i "1c#\!${PYTHON3_PATH}" "$HOST_FILE_PATH"
# Replace path to host
sed -i -e "s/PLACEHOLDER/$ESCAPED_HOST_FILE_PATH/" "$MANIFEST_FILE_PATH"
fi

# Set permissions for the manifest so that all users can read it.
chmod a+x "$HOST_FILE_PATH"
Expand Down

0 comments on commit 1feab77

Please sign in to comment.