feat: added two mailbox scripts related to importing the mails fom old skynet (pre Jan 2023)
This commit is contained in:
parent
882f9aa78e
commit
342e67e10c
2 changed files with 82 additions and 0 deletions
61
skynet_old_mail-import.sh
Normal file
61
skynet_old_mail-import.sh
Normal file
|
@ -0,0 +1,61 @@
|
|||
# This script is to move all teh old mail into a subfolder and to scribe the user to that folder (so it pops up in their mail client)
|
||||
# This needs to be run on the mailserver else sendmail and doveadm wont be available
|
||||
|
||||
echo "Subject: [Skynet] Old emails restored
|
||||
Hi all,
|
||||
|
||||
All the old emails from Skynet prior to Jan 2023 that were on the server have been restored to this folder.
|
||||
|
||||
Brendan." > email.txt
|
||||
|
||||
|
||||
FROM=/skynet_old/mail
|
||||
TO=/var/vmail/skynet.ie
|
||||
MAILBOX="skynet_old"
|
||||
|
||||
|
||||
for dir in $FROM/*;
|
||||
do
|
||||
username=$(basename "$dir");
|
||||
|
||||
# a few usernames are bogus, ignore these
|
||||
if [[ $username == bogus* ]] || [[ $username == BOGUS* ]];
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
# should only deal with folks who got mailbox created, did ye run skynet_old_mailbox-send.sh ?
|
||||
if [ ! -d "$TO/$username" ]; then
|
||||
echo "Fail: $TO/$username does not exist."
|
||||
continue
|
||||
fi
|
||||
|
||||
# we want to put teh main into a sub mailbox
|
||||
TO_USER="$TO/$username/.$MAILBOX"
|
||||
|
||||
if [ ! -d "$TO_USER" ]; then
|
||||
# if it doesnt exist, create it and do the rest of this script.
|
||||
mkdir $TO_USER
|
||||
|
||||
cp -R $FROM/$username/* $TO_USER/
|
||||
|
||||
# set proper permissions
|
||||
chmod -R 600 $TO_USER/
|
||||
chmod -R u+X $TO_USER/
|
||||
|
||||
# change owner to the mailserver
|
||||
chown -R virtualMail:virtualMail $TO_USER/
|
||||
|
||||
# subscribe the user to the mailbox show it shows up
|
||||
doveadm mailbox subscribe -u "$username@skynet.ie" $MAILBOX
|
||||
|
||||
# this pops a new mail in that mailbox
|
||||
sendmail "$username+$MAILBOX@skynet.ie" < email.txt
|
||||
|
||||
echo "Complete: $username"
|
||||
else
|
||||
# if the sub-mailbox already exists dont touch it again.
|
||||
echo "Already Complete: $username"
|
||||
fi
|
||||
|
||||
done
|
21
skynet_old_mail-send.sh
Normal file
21
skynet_old_mail-send.sh
Normal file
|
@ -0,0 +1,21 @@
|
|||
# This script is to send an email to everyone in order to create their email folder.
|
||||
# would create it using doveadm but that seems like its not possible.
|
||||
|
||||
echo "Subject: Testing, please ignore
|
||||
Testing please ignore" > email.txt
|
||||
|
||||
|
||||
for dir in /skynet_old/mail/*;
|
||||
do
|
||||
username=$(basename "$dir");
|
||||
|
||||
if [[ $username == bogus* ]] || [[ $username == BOGUS* ]];
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
sendmail "$username@skynet.ie" < email.txt
|
||||
|
||||
echo "Complete: $username"
|
||||
|
||||
done
|
Loading…
Reference in a new issue