Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'utils/keepassxc-snap-helper.sh')
-rwxr-xr-xutils/keepassxc-snap-helper.sh46
1 files changed, 20 insertions, 26 deletions
diff --git a/utils/keepassxc-snap-helper.sh b/utils/keepassxc-snap-helper.sh
index ecb290daa..61f966a0b 100755
--- a/utils/keepassxc-snap-helper.sh
+++ b/utils/keepassxc-snap-helper.sh
@@ -18,13 +18,24 @@
set -e
-DEBUG=false
+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)
JSON_FIREFOX=$(cat << EOF
{
"name": "org.keepassxc.keepassxc_browser",
"description": "KeePassXC integration with native messaging support",
- "path": "/snap/bin/keepassxc.proxy",
+ "path": "${PROXY_PATH}",
"type": "stdio",
"allowed_extensions": [
"keepassxc-browser@keepassxc.org"
@@ -37,7 +48,7 @@ JSON_CHROME=$(cat << EOF
{
"name": "org.keepassxc.keepassxc_browser",
"description": "KeePassXC integration with native messaging support",
- "path": "/snap/bin/keepassxc.proxy",
+ "path": "${PROXY_PATH}",
"type": "stdio",
"allowed_origins": [
"chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/",
@@ -47,21 +58,6 @@ JSON_CHROME=$(cat << EOF
EOF
)
-JSON_OUT=""
-BASE_DIR="."
-INSTALL_DIR=""
-INSTALL_FILE="org.keepassxc.keepassxc_browser.json"
-
-buildJson() {
- if [ -n "$1" ]; then
- # Insert Firefox data
- JSON_OUT=$JSON_FIREFOX
- else
- # Insert Chrome data
- JSON_OUT=$JSON_CHROME
- fi
-}
-
askBrowserSnap() {
if (whiptail --title "Snap Choice" --defaultno \
--yesno "Is this browser installed as a snap (usually NO)?" 8 60); then
@@ -73,33 +69,33 @@ askBrowserSnap() {
setupFirefox() {
askBrowserSnap "./snap/firefox/common"
- buildJson "firefox"
+ JSON_OUT=${JSON_FIREFOX}
INSTALL_DIR="${BASE_DIR}/.mozilla/native-messaging-hosts"
}
setupChrome() {
- buildJson
+ JSON_OUT=${JSON_CHROME}
INSTALL_DIR="${BASE_DIR}/.config/google-chrome/NativeMessagingHosts"
}
setupChromium() {
askBrowserSnap "./snap/chromium/current"
- buildJson
+ JSON_OUT=${JSON_CHROME}
INSTALL_DIR="${BASE_DIR}/.config/chromium/NativeMessagingHosts"
}
setupVivaldi() {
- buildJson
+ JSON_OUT=${JSON_CHROME}
INSTALL_DIR="${BASE_DIR}/.config/vivaldi/NativeMessagingHosts"
}
setupBrave() {
- buildJson
+ JSON_OUT=${JSON_CHROME}
INSTALL_DIR="${BASE_DIR}/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts"
}
setupTorBrowser() {
- buildJson "firefox"
+ JSON_OUT=${JSON_FIREFOX}
INSTALL_DIR="${BASE_DIR}/.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts"
}
@@ -138,8 +134,6 @@ if [ $exitstatus = 0 ]; then
mkdir -p "$INSTALL_DIR"
echo "$JSON_OUT" > ${INSTALL_DIR}/${INSTALL_FILE}
- $DEBUG && echo "Installed to: ${INSTALL_DIR}/${INSTALL_FILE}"
-
whiptail \
--title "Installation Complete" \
--msgbox "You will need to restart your browser in order to connect to KeePassXC" \