Reconfigure for bdsmail

This commit is contained in:
Bob Mottram 2018-02-14 12:54:08 +00:00
parent 63c42cb6ff
commit 53f0a66f6e
1 changed files with 38 additions and 16 deletions

View File

@ -112,9 +112,44 @@ function change_password_bdsmail {
new_user_password="$2"
}
function bdsmail_update_domain {
sed -i "s|set from=.*|set from=username@$(bdsmail_domain)|g" /etc/skel/.mutt/bdsmail
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
cp /etc/skel/.mutt/bdsmail /home/${USERNAME}/.mutt/bdsmail
sed -i "s|set from=.*|set from=${USERNAME}@$(bdsmail_domain)|g" /home/${USERNAME}/.mutt/bdsmail
chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.mutt/bdsmail
fi
done
}
function bdsmail_wait_for_key_generation {
# wait for domain to be generated by the daemon
# This can take a while, probably because i2p is connecting
bds_domain=
sleep_ctr=0
while [ ! $bds_domain ]; do
echo $"Waiting for i2p domain to be generated ${sleep_ctr}/100"
systemctl restart bdsmail
sleep 30
bds_domain=$(bdsmail_domain)
sleep_ctr=$((sleep_ctr + 1))
if [ $sleep_ctr -gt 100 ]; then
break
fi
done
}
function reconfigure_bdsmail {
# This is used if you need to switch identity. Dump old keys and generate new ones
echo -n ''
systemctl stop bdsmail
rm $BDSMAIL_DIR/*.dat
rm $BDSMAIL_DIR/*.pem
bdsmail_wait_for_key_generation
if [ ! -f $BDSMAIL_DIR/bdsmail-privkey.dat ]; then
return
fi
bdsmail_update_domain
}
function upgrade_bdsmail {
@ -362,20 +397,7 @@ function install_bdsmail {
echo $'This may take a while.'
echo ''
# wait for domain to be generated by the daemon
# This can take a while, probably because i2p is connecting
bds_domain=
sleep_ctr=0
while [ ! $bds_domain ]; do
echo $"Waiting for i2p domain to be generated ${sleep_ctr}/100"
systemctl restart bdsmail
sleep 30
bds_domain=$(bdsmail_domain)
sleep_ctr=$((sleep_ctr + 1))
if [ $sleep_ctr -gt 100 ]; then
break
fi
done
bdsmail_wait_for_key_generation
if [ ! $bds_domain ]; then
systemctl stop bdsmail