bdsmail directory

This commit is contained in:
Bob Mottram 2018-02-12 18:39:44 +00:00
parent 4c8edf2ad6
commit c1643e475b
1 changed files with 37 additions and 36 deletions

View File

@ -35,6 +35,7 @@ SHOW_ON_ABOUT=1
BDSMAIL_REPO="https://github.com/majestrate/bdsmail" BDSMAIL_REPO="https://github.com/majestrate/bdsmail"
BDSMAIL_COMMIT='6a2296b0b8e6c3da61081b85802e7b1cc88ca285' BDSMAIL_COMMIT='6a2296b0b8e6c3da61081b85802e7b1cc88ca285'
BDSMAIL_DIR=/bdsmail
bdsmail=(MY_USERNAME) bdsmail=(MY_USERNAME)
@ -120,14 +121,14 @@ function upgrade_bdsmail {
fi fi
# update to the next commit # update to the next commit
set_repo_commit /etc/bdsmail "bdsmail commit" "$BDSMAIL_COMMIT" $BDSMAIL_REPO set_repo_commit $BDSMAIL_DIR "bdsmail commit" "$BDSMAIL_COMMIT" $BDSMAIL_REPO
chown -R i2psvc:i2psvc /etc/bdsmail chown -R i2psvc:i2psvc $BDSMAIL_DIR
} }
function backup_local_bdsmail { function backup_local_bdsmail {
systemctl stop bdsmail systemctl stop bdsmail
source_directory=/etc/bdsmail source_directory=$BDSMAIL_DIR
function_check backup_directory_to_usb function_check backup_directory_to_usb
dest_directory=bdsmail dest_directory=bdsmail
@ -140,7 +141,7 @@ function restore_local_bdsmail {
systemctl stop bdsmail systemctl stop bdsmail
temp_restore_dir=/root/tempbdsmail temp_restore_dir=/root/tempbdsmail
bdsmail_dir=/etc/bdsmail bdsmail_dir=$BDSMAIL_DIR
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir bdsmail restore_directory_from_usb $temp_restore_dir bdsmail
@ -163,7 +164,7 @@ function restore_local_bdsmail {
function backup_remote_bdsmail { function backup_remote_bdsmail {
systemctl stop bdsmail systemctl stop bdsmail
source_directory=/etc/bdsmail source_directory=$BDSMAIL_DIR
function_check backup_directory_to_friend function_check backup_directory_to_friend
dest_directory=bdsmail dest_directory=bdsmail
@ -176,7 +177,7 @@ function restore_remote_bdsmail {
systemctl stop bdsmail systemctl stop bdsmail
temp_restore_dir=/root/tempbdsmail temp_restore_dir=/root/tempbdsmail
bdsmail_dir=/etc/bdsmail bdsmail_dir=$BDSMAIL_DIR
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir bdsmail restore_directory_from_friend $temp_restore_dir bdsmail
@ -234,36 +235,36 @@ function remove_bdsmail {
remove_completion_param install_bdsmail remove_completion_param install_bdsmail
sed -i '/bdsmail/d' $COMPLETION_FILE sed -i '/bdsmail/d' $COMPLETION_FILE
rm -rf /etc/skel/.mutt rm -rf /etc/skel/.mutt
if [ -d /etc/bdsmail ]; then if [ -d $BDSMAIL_DIR ]; then
rm -rf /etc/bdsmail rm -rf $BDSMAIL_DIR
fi fi
} }
function install_bdsmail { function install_bdsmail {
if [ -d /etc/bdsmail ]; then if [ -d $BDSMAIL_DIR ]; then
remove_bdsmail remove_bdsmail
fi fi
if [ -d /repos/bdsmail ]; then if [ -d /repos/bdsmail ]; then
mkdir /etc/bdsmail mkdir $BDSMAIL_DIR
cp -r -p /repos/bdsmail/. /etc/bdsmail cp -r -p /repos/bdsmail/. $BDSMAIL_DIR
cd /etc/bdsmail cd $BDSMAIL_DIR
git pull git pull
else else
git_clone $BDSMAIL_REPO /etc/bdsmail git_clone $BDSMAIL_REPO $BDSMAIL_DIR
fi fi
if [ ! -d /etc/bdsmail ]; then if [ ! -d $BDSMAIL_DIR ]; then
echo $'Unable to clone bdsmail repo' echo $'Unable to clone bdsmail repo'
exit 5735735 exit 5735735
fi fi
cd /etc/bdsmail cd $BDSMAIL_DIR
git checkout $BDSMAIL_COMMIT -b $BDSMAIL_COMMIT git checkout $BDSMAIL_COMMIT -b $BDSMAIL_COMMIT
set_completion_param "bdsmail commit" "$BDSMAIL_COMMIT" set_completion_param "bdsmail commit" "$BDSMAIL_COMMIT"
make GOROOT=/home/go/go${GO_VERSION} make GOROOT=/home/go/go${GO_VERSION}
if [ ! -f /etc/bdsmail/bin/bdsconfig ]; then if [ ! -f $BDSMAIL_DIR/bin/bdsconfig ]; then
echo $'Unable to make bdsmail' echo $'Unable to make bdsmail'
exit 87923567842 exit 87923567842
fi fi
@ -272,16 +273,16 @@ function install_bdsmail {
i2p_enable_sam i2p_enable_sam
# create configuration file # create configuration file
/etc/bdsmail/bin/bdsconfig > /etc/bdsmail/config.ini $BDSMAIL_DIR/bin/bdsconfig > $BDSMAIL_DIR/config.ini
echo '[maild]' > /etc/bdsmail/config.ini echo '[maild]' > $BDSMAIL_DIR/config.ini
echo 'i2paddr = 127.0.0.1:7656' >> /etc/bdsmail/config.ini echo 'i2paddr = 127.0.0.1:7656' >> $BDSMAIL_DIR/config.ini
echo 'i2pkeyfile = bdsmail-privkey.dat' >> /etc/bdsmail/config.ini echo 'i2pkeyfile = bdsmail-privkey.dat' >> $BDSMAIL_DIR/config.ini
echo 'bindmail = 127.0.0.1:2525' >> /etc/bdsmail/config.ini echo 'bindmail = 127.0.0.1:2525' >> $BDSMAIL_DIR/config.ini
echo 'bindweb = 127.0.0.1:8489' >> /etc/bdsmail/config.ini echo 'bindweb = 127.0.0.1:8489' >> $BDSMAIL_DIR/config.ini
echo 'domain = localhost' >> /etc/bdsmail/config.ini echo 'domain = localhost' >> $BDSMAIL_DIR/config.ini
echo 'maildir = mail' >> /etc/bdsmail/config.ini echo 'maildir = mail' >> $BDSMAIL_DIR/config.ini
echo 'database = localhost.sqlite' >> /etc/bdsmail/config.ini echo 'database = localhost.sqlite' >> $BDSMAIL_DIR/config.ini
echo 'assets = contrib/assets/web' >> /etc/bdsmail/config.ini echo 'assets = contrib/assets/web' >> $BDSMAIL_DIR/config.ini
echo '[Unit]' > /etc/systemd/system/bdsmail.service echo '[Unit]' > /etc/systemd/system/bdsmail.service
echo 'Description=bdsmail' >> /etc/systemd/system/bdsmail.service echo 'Description=bdsmail' >> /etc/systemd/system/bdsmail.service
@ -292,26 +293,26 @@ function install_bdsmail {
echo 'Type=simple' >> /etc/systemd/system/bdsmail.service echo 'Type=simple' >> /etc/systemd/system/bdsmail.service
echo 'User=i2psvc' >> /etc/systemd/system/bdsmail.service echo 'User=i2psvc' >> /etc/systemd/system/bdsmail.service
echo 'Group=i2psvc' >> /etc/systemd/system/bdsmail.service echo 'Group=i2psvc' >> /etc/systemd/system/bdsmail.service
echo 'WorkingDirectory=/etc/bdsmail' >> /etc/systemd/system/bdsmail.service echo "WorkingDirectory=$BDSMAIL_DIR" >> /etc/systemd/system/bdsmail.service
echo 'ExecStart=/etc/bdsmail/bin/maild /etc/bdsmail/config.ini' >> /etc/systemd/system/bdsmail.service echo "ExecStart=$BDSMAIL_DIR/bin/maild $BDSMAIL_DIR/config.ini" >> /etc/systemd/system/bdsmail.service
echo 'Restart=always' >> /etc/systemd/system/bdsmail.service echo 'Restart=always' >> /etc/systemd/system/bdsmail.service
echo 'Environment="USER=i2psvc"' >> /etc/systemd/system/bdsmail.service echo 'Environment="USER=i2psvc"' >> /etc/systemd/system/bdsmail.service
echo '' >> /etc/systemd/system/bdsmail.service echo '' >> /etc/systemd/system/bdsmail.service
echo '[Install]' >> /etc/systemd/system/bdsmail.service echo '[Install]' >> /etc/systemd/system/bdsmail.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/bdsmail.service echo 'WantedBy=multi-user.target' >> /etc/systemd/system/bdsmail.service
echo '#!/usr/bin/env python2' > /etc/bdsmail/get_address echo '#!/usr/bin/env python2' > $BDSMAIL_DIR/get_address
echo 'import base64, hashlib, sys' >> /etc/bdsmail/get_address echo 'import base64, hashlib, sys' >> $BDSMAIL_DIR/get_address
echo 'with open(sys.argv[1]) as f:' >> /etc/bdsmail/get_address echo 'with open(sys.argv[1]) as f:' >> $BDSMAIL_DIR/get_address
echo " print(base64.b32encode(hashlib.sha256(base64.b64decode(f.read(516), '-~')).digest()).strip('=')+\".b32.i2p\")" >> /etc/bdsmail/get_address echo " print(base64.b32encode(hashlib.sha256(base64.b64decode(f.read(516), '-~')).digest()).strip('=')+\".b32.i2p\")" >> $BDSMAIL_DIR/get_address
chmod +x /etc/bdsmail/get_address chmod +x $BDSMAIL_DIR/get_address
chown -R i2psvc:i2psvc /etc/bdsmail chown -R i2psvc:i2psvc $BDSMAIL_DIR
systemctl enable bdsmail systemctl enable bdsmail
systemctl start bdsmail systemctl start bdsmail
echo '#!/bin/bash' > /usr/bin/bdsmail_domain echo '#!/bin/bash' > /usr/bin/bdsmail_domain
echo 'cd /etc/bdsmail' >> /usr/bin/bdsmail_domain echo 'cd $BDSMAIL_DIR' >> /usr/bin/bdsmail_domain
echo 'if [ ! -f bdsmail-privkey.dat ]; then' >> /usr/bin/bdsmail_domain echo 'if [ ! -f bdsmail-privkey.dat ]; then' >> /usr/bin/bdsmail_domain
echo ' exit 1' >> /usr/bin/bdsmail_domain echo ' exit 1' >> /usr/bin/bdsmail_domain
echo 'fi' >> /usr/bin/bdsmail_domain echo 'fi' >> /usr/bin/bdsmail_domain
@ -353,7 +354,7 @@ function install_bdsmail {
echo 'set smtp_url=smtp://127.0.0.1:2525/' >> /etc/skel/.mutt/bdsmail echo 'set smtp_url=smtp://127.0.0.1:2525/' >> /etc/skel/.mutt/bdsmail
echo 'set use_from=yes' >> /etc/skel/.mutt/bdsmail echo 'set use_from=yes' >> /etc/skel/.mutt/bdsmail
echo "set from=username@${bds_domain}" >> /etc/skel/.mutt/bdsmail echo "set from=username@${bds_domain}" >> /etc/skel/.mutt/bdsmail
echo 'set spoolfile=/etc/bdsmail/mail/username' >> /etc/skel/.mutt/bdsmail echo "set spoolfile=$BDSMAIL_DIR/mail/username" >> /etc/skel/.mutt/bdsmail
# mutt configuration for the admin user # mutt configuration for the admin user
if [ ! -d /home/$MY_USERNAME/.mutt ]; then if [ ! -d /home/$MY_USERNAME/.mutt ]; then