From 2b2f17f3109923ab5179e613f3cd74254b9d0e80 Mon Sep 17 00:00:00 2001
From: "Stanko K.R" <me@stanko.io>
Date: Sat, 4 May 2019 22:47:01 +0200
Subject: Prefix binary path correctly on MacOS

---
 Makefile |  7 ++++++-
 bin/mw   | 10 ++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e4a1440..1b17344 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,11 @@
 .POSIX:
 
-PREFIX = /usr
+OS = $(shell uname -s)
+ifeq ($(OS), Darwin)
+  PREFIX = /usr/local
+else
+  PREFIX = /usr
+endif
 MANPREFIX = $(PREFIX)/share/man
 
 install:
diff --git a/bin/mw b/bin/mw
index 7e09e9a..0010a67 100755
--- a/bin/mw
+++ b/bin/mw
@@ -2,12 +2,18 @@
 command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"
 ! "$GPG" --list-secret-keys "<$(cat "$HOME/.password-store/.gpg-id")>" >/dev/null 2>&1 && printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`gpg --full-gen-key\` first.\\n" && exit
 ! command -v mbsync >/dev/null && printf "\`mbsync\` must be installed to run mutt-wizard.\\n" && exit
+
+if [[ "$OSTYPE" == "darwin"* ]]; then
+  prefix="/usr/local"
+else
+  prefix="/usr"
+fi
 muttdir="$HOME/.config/mutt"		# Main mutt config location
 accdir="$muttdir/accounts"		# Directory for account settings
 maildir="$HOME/.local/share/mail"	# Location of mail storage
 namere="^[a-z_][a-z0-9_-]*$"		# Regex to ensure viable username
 emailre=".\+@.\+\\..\+" 		# Regex to confirm valid email address
-muttshare="/usr/share/mutt-wizard"
+muttshare="$prefix/share/mutt-wizard"
 mbsyncrc="$HOME/.mbsyncrc"
 mwconfig="$muttshare/mutt-wizard.muttrc"
 cachedir="$HOME/.cache/mutt-wizard"
@@ -89,7 +95,7 @@ mutt_profile="# vim: filetype=neomuttrc
 # muttrc file for account $title
 set realname = \"$realname\"
 set from = \"$fulladdr\"
-set sendmail = \"/usr/bin/msmtp -a $title\"
+set sendmail = \"$prefix/bin/msmtp -a $title\"
 alias me $realname <$fulladdr>
 set folder = \"imaps://$fulladdr@$imap:$iport\"
 set imap_user = \"$login\"
-- 
cgit v1.2.3


From aaa188ce722c7da4a71112b0b0f6ef441a9bdceb Mon Sep 17 00:00:00 2001
From: "Stanko K.R" <me@stanko.io>
Date: Sat, 4 May 2019 22:47:20 +0200
Subject: Relax pass store check

Checking for a secret key with format `<foo@bar.com>` may not work for
people that store key IDs in .gpg-id. Removing the `<` and `>` makes it
work for both beople that use emails and people that use IDs.
---
 bin/mw | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/mw b/bin/mw
index 0010a67..7484c9f 100755
--- a/bin/mw
+++ b/bin/mw
@@ -1,6 +1,6 @@
 #!/bin/sh
 command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"
-! "$GPG" --list-secret-keys "<$(cat "$HOME/.password-store/.gpg-id")>" >/dev/null 2>&1 && printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`gpg --full-gen-key\` first.\\n" && exit
+! "$GPG" --list-secret-keys $(cat "$HOME/.password-store/.gpg-id") >/dev/null 2>&1 && printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`gpg --full-gen-key\` first.\\n" && exit
 ! command -v mbsync >/dev/null && printf "\`mbsync\` must be installed to run mutt-wizard.\\n" && exit
 
 if [[ "$OSTYPE" == "darwin"* ]]; then
-- 
cgit v1.2.3


From 41c5040b6adfaa0eb33337dfe22fa6ec2503797f Mon Sep 17 00:00:00 2001
From: "Stanko K.R" <me@stanko.io>
Date: Sat, 4 May 2019 22:47:26 +0200
Subject: Add MacOS certificate store to search list

---
 bin/mw | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/mw b/bin/mw
index 7484c9f..0deb448 100755
--- a/bin/mw
+++ b/bin/mw
@@ -21,7 +21,7 @@ muttrc="$muttdir/muttrc"
 msmtprc="$HOME/.config/msmtp/config"
 ssltype="IMAPS"				# This is later changed to `None` later in the script if using Protonmail
 
-for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
+for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem"
 do
 	[ -f "$x" ] && sslcert="$x" && break
 done || { echo "CA Certificate not found. Please install one or link it to /etc/ssl/certs/ca-certificates.crt" && exit 1 ;}
-- 
cgit v1.2.3