Skip to content

Instantly share code, notes, and snippets.

@neverkas
Last active June 5, 2023 19:20
Show Gist options
  • Save neverkas/5c1493ef7d20b4ef0d9627beba42b83a to your computer and use it in GitHub Desktop.
Save neverkas/5c1493ef7d20b4ef0d9627beba42b83a to your computer and use it in GitHub Desktop.
configuration neomutt + gmail + oauth2
install-mailreader-neomutt:
sudo aptitude install neomutt
install-muttwizard-dependencies: install-mailreader-neomutt
sudo aptitude install curl isync msmtp pass
install-mailreader-muttwizard: install-muttwizard-dependencies
cd /tmp \
&& git clone https://github.com/LukeSmithxyz/mutt-wizard \
&& cd mutt-wizard \
&& sudo make install
.PHONY: install-mailreader-neomutt install-muttwizard-dependencies install-mailreader-muttwizard
include install-packages.mk
include mutt.mk
APP_MUTT_DIR=$${HOME}/.config/mutt
SCRIPT_MUTT_OAUTH2_NAME=mutt_oauth2.py
SCRIPT_MUTT_OAUTH2_DIR=$(APP_MUTT_DIR)/$(SCRIPT_MUTT_OAUTH2_NAME)
SCRIPT_MUTT_OAUTH2_URL=https://gitlab.com/muttmua/mutt/-/raw/master/contrib/$(SCRIPT_MUTT_OAUTH2_NAME)
ASK_USER_EMAIL=read -p "Escriba su email: " USER_EMAIL
ASK_GPG_SUBKEY_ENCRYPT_ID=read -p " > ingrese el ID de la Clave Secundaria que Encripte/Desencripte: " GPG_SUBKEY_ENCRYPT_ID
muttwizard-add-email:
$(ASK_USER_EMAIL) \
&& mw -a $${USER_EMAIL} -o
mutt-oauth2-download-script:
cd $(APP_MUTT_DIR) \
&& curl -O $(SCRIPT_MUTT_OAUTH2_URL) \
&& sed -i 's/urn:ietf:wg:oauth:2.0:oob/http:\/\/localhost:1\//g' $(SCRIPT_MUTT_OAUTH2_NAME) \
&& chmod u+x $(SCRIPT_MUTT_OAUTH2_NAME)
# personalizamos el script original, para que tenga más interacción con el usuario
# https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py.README
# https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py
mutt-oauth2-modify-script:
SCRIPT_MUTT_OAUTH2_INPUTS="MY_CLIENT_ID = input('client id: '); MY_CLIENT_SECRET = input('client secret: ')"; \
SCRIPT_MUTT_OAUTH2_LINE_INSERT=`awk '/DECRYPTION_PIPE =/{getline; print NR}' $(SCRIPT_MUTT_OAUTH2_DIR)`; \
sed -i "$${SCRIPT_MUTT_OAUTH2_LINE_INSERT} i $${SCRIPT_MUTT_OAUTH2_INPUTS}" $(SCRIPT_MUTT_OAUTH2_DIR) \
&& sed -i -E "s/'client_id':(.*),/'client_id':MY_CLIENT_ID,/" $(SCRIPT_MUTT_OAUTH2_DIR) \
&& sed -i -E "s/'client_secret':(.*),/'client_secret':MY_CLIENT_SECRET,/" $(SCRIPT_MUTT_OAUTH2_DIR) \
mutt-configure-oauth2: mutt-oauth2-download-script mutt-oauth2-modify-script
cd $(APP_MUTT_DIR) \
&& $(ASK_USER_EMAIL) \
&& $(ASK_GPG_SUBKEY_ENCRYPT_ID) \
&& sed -i "s/YOUR_GPG_IDENTITY/$${GPG_SUBKEY_ENCRYPT_ID}/" $(SCRIPT_MUTT_OAUTH2_NAME) \
&& $(SCRIPT_MUTT_OAUTH2_DIR) $${USER_EMAIL} --verbose --authorize
mutt-test-oauth2:
$(ASK_USER_EMAIL) \
&& cd $(DIR_APP_MUTT) \
&& $(SCRIPT_MUTT_OAUTH2_DIR) $${USER_EMAIL} --verbose --test
.PHONY: muttwizard-add-email mutt-oauth2-download-script mutt-oauth2-modify-script mutt-configure-oauth2 mutt-test-oauth2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment