feat: improvements based on feedback and useage
This commit is contained in:
parent
342e67e10c
commit
602f9b572b
2 changed files with 36 additions and 24 deletions
|
@ -18,6 +18,11 @@ for dir in $FROM/*;
|
||||||
do
|
do
|
||||||
username=$(basename "$dir");
|
username=$(basename "$dir");
|
||||||
|
|
||||||
|
if [ -z "$(ls -A $FROM/$username)" ]; then
|
||||||
|
rm -rf $FROM/$username
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# a few usernames are bogus, ignore these
|
# a few usernames are bogus, ignore these
|
||||||
if [[ $username == bogus* ]] || [[ $username == BOGUS* ]];
|
if [[ $username == bogus* ]] || [[ $username == BOGUS* ]];
|
||||||
then
|
then
|
||||||
|
@ -36,8 +41,15 @@ do
|
||||||
if [ ! -d "$TO_USER" ]; then
|
if [ ! -d "$TO_USER" ]; then
|
||||||
# if it doesnt exist, create it and do the rest of this script.
|
# if it doesnt exist, create it and do the rest of this script.
|
||||||
mkdir $TO_USER
|
mkdir $TO_USER
|
||||||
|
fi
|
||||||
|
|
||||||
cp -R $FROM/$username/* $TO_USER/
|
# from https://askubuntu.com/a/483192
|
||||||
|
mv $FROM/$username/{*,.[^.]*,..?*} $TO_USER/
|
||||||
|
|
||||||
|
# if empty
|
||||||
|
if [ -z "$(ls -A $FROM/$username)" ]; then
|
||||||
|
rm -rf $FROM/$username
|
||||||
|
fi
|
||||||
|
|
||||||
# set proper permissions
|
# set proper permissions
|
||||||
chmod -R 600 $TO_USER/
|
chmod -R 600 $TO_USER/
|
||||||
|
@ -52,10 +64,6 @@ do
|
||||||
# this pops a new mail in that mailbox
|
# this pops a new mail in that mailbox
|
||||||
sendmail "$username+$MAILBOX@skynet.ie" < email.txt
|
sendmail "$username+$MAILBOX@skynet.ie" < email.txt
|
||||||
|
|
||||||
echo "Complete: $username"
|
echo "Complete: $username";
|
||||||
else
|
|
||||||
# if the sub-mailbox already exists dont touch it again.
|
|
||||||
echo "Already Complete: $username"
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
|
@ -4,8 +4,11 @@
|
||||||
echo "Subject: Testing, please ignore
|
echo "Subject: Testing, please ignore
|
||||||
Testing please ignore" > email.txt
|
Testing please ignore" > email.txt
|
||||||
|
|
||||||
|
FROM=/skynet_old/mail
|
||||||
|
TO=/var/vmail/skynet.ie
|
||||||
|
|
||||||
for dir in /skynet_old/mail/*;
|
|
||||||
|
for dir in $FROM/*;
|
||||||
do
|
do
|
||||||
username=$(basename "$dir");
|
username=$(basename "$dir");
|
||||||
|
|
||||||
|
@ -14,8 +17,9 @@ do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$TO/$username" ]; then
|
||||||
sendmail "$username@skynet.ie" < email.txt
|
sendmail "$username@skynet.ie" < email.txt
|
||||||
|
echo "Mail Sent: $username"
|
||||||
echo "Complete: $username"
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue