[neomutt-users] Advice on part of program to setup files/dirs for neomutt

Chris Bennett cpb_neomutt at bennettconstruction.us
Tue Oct 19 19:23:32 CEST 2021


Hi,
I'm working on a program to use PostgreSQL with Neomutt (possibly with
other programs such as dovecot and/or something like OpenSMTPD)

But only concentrating on Neomutt, I would like to see what people think
of what I have done for the part that creates files and directories for
Neomutt. Everything below can be done manually or pulled out of the
database instead. This is still WIP, but I'll put up on github in a few
days at most.

This is a shell script to do part of the work. I also attached a copy.

 
#!/bin/sh

# Phase-Two-Test.sh version 1.0.5
# All of the existing files in the EXAMPLES_DIR are copied to the BASEDIR/EMAIL
# of the new user. BASEDIR by itself would also work for a user with only one email
# address. These could be blank files or have a set of default values
# that the system administrator wants new users to start out with.

# The PERSONAL_DIR can then change these files to the values that the new user
# prefers to have. Thus defaults are set, then optionally overridden by the new
# user if desired.

echo "Please enter the user base file directory to create this user personal area into ->\c"
read BASEDIR

echo "Please enter the examples file directory ->\c"
read EXAMPLES_DIR

echo "Please enter your personal files directory to copy existing files ->\c"
read PERSONAL_FILES_DIR

echo "Please enter new username ->\c"
read USER

echo "Please enter new email address ->\c"
read EMAIL

echo "Please enter new name ->\c"
read NAME

echo "Please enter new user_id ->\c"
read USER_ID

echo ${BASEDIR}
echo ${EXAMPLES_DIR}
echo ${PERSONAL_FILES_DIR}
echo ${USER}
echo ${EMAIL}
echo ${NAME}
echo ${USER_ID}

# Dropping the ${EMAIL} part here is also fine. This directory could also be used
# from a database setting.
mkdir ${BASEDIR}/${EMAIL} && chmod 0700 ${BASEDIR}/${EMAIL}

cd ${BASEDIR}/${EMAIL}

# All of the files and directories names can be pulled from the database instead of
# using these names I have chosen. Thus the system administrator or new user can
# decide what to use. This set is just for testing.
mkdir .neomutt_news_cache .neomutt_message_cache .neomutt_header_cache .neomutt_attach_save_dir tmp
chmod 0700 .neomutt_news_cache .neomutt_message_cache .neomutt_header_cache .neomutt_attach_save_dir tmp

touch .signature .neomutt_history .neomutt_mail_aliases
chmod 0600 .signature .neomutt_history .neomutt_mail_aliases

echo "my_hdr From: ${NAME} <${EMAIL}>" >> .neomuttrc-my_variables-${USER_ID}
echo "my_hdr Return-Path: ${NAME} <${EMAIL}>" >> .neomuttrc-my_variables-${USER_ID}
echo "my_hdr Reply-To: ${NAME} <${EMAIL}>" >> .neomuttrc-my_variables-${USER_ID}
chmod 0600 .neomuttrc-my_variables-${USER_ID}

cp -rp ${EXAMPLES_DIR}/* .
cp -rp ${EXAMPLES_DIR}/.* .

# Needs modifications?
# This hits on sourced files from .neomuttrc, but could also add other existing files
# that have personal new or existing macros, etc. Those files can be added to the database
# that they also need to be sourced.
# cp -rp ${PERSONAL_FILES_DIR}/* ${PERSONAL_FILES_DIR}/.* .
cp -rp ${PERSONAL_FILES_DIR}/.mailcap ${PERSONAL_FILES_DIR}/.neomutt_mail_aliases ${PERSONAL_FILES_DIR}/.signature .


ls -la
--------------------------------------------------------------

Are there any files or directories that are missing?

I found some advice on how to create a .neomuttrc that can be accessed
as if it were a temporary file, but never gets written to the file
system. If that works correctly, then no one should ever get access to
the passwords from the rc file. That is written in Perl.

I looked at mutt-wizard a few days ago. This project I am doing is
similar to that program, but far more comprehensive.

I also have a Perl script to make things run and a database set up.
One post at a time about all of this. Github shortly. I'll also put
onto a website of mine first.

-- 
Thanks!
Chris Bennett

-------------- next part --------------
#!/bin/sh

# Phase-Two-Test.sh version 1.0.5
# All of the existing files in the EXAMPLES_DIR are copied to the BASEDIR/EMAIL
# of the new user. BASEDIR by itself would also work for a user with only one email
# address. These could be blank files or have a set of default values
# that the system administrator wants new users to start out with.

# The PERSONAL_DIR can then change these files to the values that the new user
# prefers to have. Thus defaults are set, then optionally overridden by the new
# user if desired.

echo "Please enter the user base file directory to create this user personal area into ->\c"
read BASEDIR

echo "Please enter the examples file directory ->\c"
read EXAMPLES_DIR

echo "Please enter your personal files directory to copy existing files ->\c"
read PERSONAL_FILES_DIR

echo "Please enter new username ->\c"
read USER

echo "Please enter new email address ->\c"
read EMAIL

echo "Please enter new name ->\c"
read NAME

echo "Please enter new user_id ->\c"
read USER_ID

echo ${BASEDIR}
echo ${EXAMPLES_DIR}
echo ${PERSONAL_FILES_DIR}
echo ${USER}
echo ${EMAIL}
echo ${NAME}
echo ${USER_ID}

# Dropping the ${EMAIL} part here is also fine. This directory could also be used
# from a database setting.
mkdir ${BASEDIR}/${EMAIL} && chmod 0700 ${BASEDIR}/${EMAIL}

cd ${BASEDIR}/${EMAIL}

# All of the files and directories names can be pulled from the database instead of
# using these names I have chosen. Thus the system administrator or new user can
# decide what to use. This set is just for testing.
mkdir .neomutt_news_cache .neomutt_message_cache .neomutt_header_cache .neomutt_attach_save_dir tmp
chmod 0700 .neomutt_news_cache .neomutt_message_cache .neomutt_header_cache .neomutt_attach_save_dir tmp

touch .signature .neomutt_history .neomutt_mail_aliases
chmod 0600 .signature .neomutt_history .neomutt_mail_aliases

echo "my_hdr From: ${NAME} <${EMAIL}>" >> .neomuttrc-my_variables-${USER_ID}
echo "my_hdr Return-Path: ${NAME} <${EMAIL}>" >> .neomuttrc-my_variables-${USER_ID}
echo "my_hdr Reply-To: ${NAME} <${EMAIL}>" >> .neomuttrc-my_variables-${USER_ID}
chmod 0600 .neomuttrc-my_variables-${USER_ID}

cp -rp ${EXAMPLES_DIR}/* .
cp -rp ${EXAMPLES_DIR}/.* .

# Needs modifications?
# This hits on sourced files from .neomuttrc, but could also add other existing files
# that have personal new or existing macros, etc. Those files can be added to the database
# that they also need to be sourced.
# cp -rp ${PERSONAL_FILES_DIR}/* ${PERSONAL_FILES_DIR}/.* .
cp -rp ${PERSONAL_FILES_DIR}/.mailcap ${PERSONAL_FILES_DIR}/.neomutt_mail_aliases ${PERSONAL_FILES_DIR}/.signature .


ls -la




More information about the neomutt-users mailing list