2019-03-19 08:31:05 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# KeePassXC Browser Extension Native Messaging Installer Tool
|
|
|
|
# Copyright (C) 2017 KeePassXC team <https://keepassxc.org/>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
# version 3 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2020-10-12 21:52:45 -04:00
|
|
|
JSON_OUT=""
|
|
|
|
BASE_DIR="."
|
|
|
|
INSTALL_DIR=""
|
|
|
|
INSTALL_FILE="org.keepassxc.keepassxc_browser.json"
|
|
|
|
|
|
|
|
# Early out if the keepassxc.proxy executable cannot be found
|
|
|
|
if ! command -v keepassxc.proxy; then
|
|
|
|
echo "Could not find keepassxc.proxy! Ensure the keepassxc snap is installed properly."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
PROXY_PATH=$(command -v keepassxc.proxy)
|
2019-03-19 08:31:05 -04:00
|
|
|
|
2020-07-06 12:35:29 -04:00
|
|
|
JSON_FIREFOX=$(cat << EOF
|
2019-03-19 08:31:05 -04:00
|
|
|
{
|
|
|
|
"name": "org.keepassxc.keepassxc_browser",
|
|
|
|
"description": "KeePassXC integration with native messaging support",
|
2020-10-12 21:52:45 -04:00
|
|
|
"path": "${PROXY_PATH}",
|
2019-03-19 08:31:05 -04:00
|
|
|
"type": "stdio",
|
2020-07-06 12:35:29 -04:00
|
|
|
"allowed_extensions": [
|
2019-03-19 08:31:05 -04:00
|
|
|
"keepassxc-browser@keepassxc.org"
|
|
|
|
]
|
2020-07-06 12:35:29 -04:00
|
|
|
}
|
2019-03-19 08:31:05 -04:00
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
|
|
|
JSON_CHROME=$(cat << EOF
|
2020-07-06 12:35:29 -04:00
|
|
|
{
|
|
|
|
"name": "org.keepassxc.keepassxc_browser",
|
|
|
|
"description": "KeePassXC integration with native messaging support",
|
2020-10-12 21:52:45 -04:00
|
|
|
"path": "${PROXY_PATH}",
|
2020-07-06 12:35:29 -04:00
|
|
|
"type": "stdio",
|
|
|
|
"allowed_origins": [
|
2019-03-19 08:31:05 -04:00
|
|
|
"chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/",
|
2022-01-08 16:33:52 -05:00
|
|
|
"chrome-extension://oboonakemofpalcgghocfoadofidjkkk/",
|
|
|
|
"chrome-extension://pdffhmdngciaglkoonimfcmckehcpafo/"
|
2019-03-19 08:31:05 -04:00
|
|
|
]
|
2020-07-06 12:35:29 -04:00
|
|
|
}
|
2019-03-19 08:31:05 -04:00
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
|
|
|
setupFirefox() {
|
2020-10-12 21:52:45 -04:00
|
|
|
JSON_OUT=${JSON_FIREFOX}
|
2019-03-19 08:31:05 -04:00
|
|
|
INSTALL_DIR="${BASE_DIR}/.mozilla/native-messaging-hosts"
|
|
|
|
}
|
|
|
|
|
|
|
|
setupChrome() {
|
2020-10-12 21:52:45 -04:00
|
|
|
JSON_OUT=${JSON_CHROME}
|
2019-03-19 08:31:05 -04:00
|
|
|
INSTALL_DIR="${BASE_DIR}/.config/google-chrome/NativeMessagingHosts"
|
|
|
|
}
|
|
|
|
|
|
|
|
setupChromium() {
|
2020-10-12 21:52:45 -04:00
|
|
|
JSON_OUT=${JSON_CHROME}
|
2019-03-19 08:31:05 -04:00
|
|
|
INSTALL_DIR="${BASE_DIR}/.config/chromium/NativeMessagingHosts"
|
|
|
|
}
|
|
|
|
|
|
|
|
setupVivaldi() {
|
2020-10-12 21:52:45 -04:00
|
|
|
JSON_OUT=${JSON_CHROME}
|
2019-03-19 08:31:05 -04:00
|
|
|
INSTALL_DIR="${BASE_DIR}/.config/vivaldi/NativeMessagingHosts"
|
|
|
|
}
|
|
|
|
|
2019-04-05 21:04:56 -04:00
|
|
|
setupBrave() {
|
2020-10-12 21:52:45 -04:00
|
|
|
JSON_OUT=${JSON_CHROME}
|
2019-04-05 21:04:56 -04:00
|
|
|
INSTALL_DIR="${BASE_DIR}/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts"
|
|
|
|
}
|
|
|
|
|
2019-03-19 08:31:05 -04:00
|
|
|
setupTorBrowser() {
|
2020-10-12 21:52:45 -04:00
|
|
|
JSON_OUT=${JSON_FIREFOX}
|
2019-03-19 08:31:05 -04:00
|
|
|
INSTALL_DIR="${BASE_DIR}/.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts"
|
|
|
|
}
|
|
|
|
|
2022-01-08 16:33:52 -05:00
|
|
|
setupEdge() {
|
|
|
|
JSON_OUT=${JSON_CHROME}
|
|
|
|
INSTALL_DIR="${BASE_DIR}/.config/microsoft-edge/NativeMessagingHosts"
|
|
|
|
}
|
|
|
|
|
2019-03-19 08:31:05 -04:00
|
|
|
# --------------------------------
|
|
|
|
# Start of script
|
|
|
|
# --------------------------------
|
|
|
|
|
|
|
|
BROWSER=$(whiptail \
|
|
|
|
--title "Browser Selection" \
|
|
|
|
--menu "Choose a browser to integrate with KeePassXC:" \
|
|
|
|
15 60 5 \
|
|
|
|
"1" "Firefox" \
|
|
|
|
"2" "Chrome" \
|
|
|
|
"3" "Chromium" \
|
|
|
|
"4" "Vivaldi" \
|
2019-04-05 21:04:56 -04:00
|
|
|
"5" "Brave" \
|
|
|
|
"6" "Tor Browser" \
|
2022-01-08 16:33:52 -05:00
|
|
|
"7" "Microsoft Edge" \
|
2019-03-19 08:31:05 -04:00
|
|
|
3>&1 1>&2 2>&3)
|
2019-04-05 21:04:56 -04:00
|
|
|
|
2022-04-08 08:05:34 -04:00
|
|
|
exitstatus=$?
|
|
|
|
|
2019-03-19 08:31:05 -04:00
|
|
|
clear
|
|
|
|
|
2021-09-21 00:17:46 -04:00
|
|
|
if [[ $exitstatus == 0 ]]; then
|
2019-03-19 08:31:05 -04:00
|
|
|
# Configure settings for the chosen browser
|
2021-09-21 00:17:46 -04:00
|
|
|
case $BROWSER in
|
2019-03-19 08:31:05 -04:00
|
|
|
1) setupFirefox ;;
|
|
|
|
2) setupChrome ;;
|
|
|
|
3) setupChromium ;;
|
|
|
|
4) setupVivaldi ;;
|
2019-04-05 21:04:56 -04:00
|
|
|
5) setupBrave ;;
|
|
|
|
6) setupTorBrowser ;;
|
2022-01-08 16:33:52 -05:00
|
|
|
7) setupEdge ;;
|
2019-03-19 08:31:05 -04:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Install the JSON file
|
|
|
|
cd ~
|
|
|
|
mkdir -p "$INSTALL_DIR"
|
2021-09-21 00:17:46 -04:00
|
|
|
echo "$JSON_OUT" > "${INSTALL_DIR}/${INSTALL_FILE}"
|
2019-04-05 21:04:56 -04:00
|
|
|
|
2019-03-19 08:31:05 -04:00
|
|
|
whiptail \
|
|
|
|
--title "Installation Complete" \
|
|
|
|
--msgbox "You will need to restart your browser in order to connect to KeePassXC" \
|
|
|
|
8 50
|
|
|
|
else
|
|
|
|
whiptail --title "Installation Canceled" --msgbox "No changes were made to your system" 8 50
|
|
|
|
fi
|