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
|
||||
username=$(basename "$dir");
|
||||
|
||||
if [ -z "$(ls -A $FROM/$username)" ]; then
|
||||
rm -rf $FROM/$username
|
||||
continue
|
||||
fi
|
||||
|
||||
# a few usernames are bogus, ignore these
|
||||
if [[ $username == bogus* ]] || [[ $username == BOGUS* ]];
|
||||
then
|
||||
|
@ -36,8 +41,15 @@ do
|
|||
if [ ! -d "$TO_USER" ]; then
|
||||
# if it doesnt exist, create it and do the rest of this script.
|
||||
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
|
||||
chmod -R 600 $TO_USER/
|
||||
|
@ -52,10 +64,6 @@ do
|
|||
# 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
|
||||
echo "Complete: $username";
|
||||
|
||||
done
|
|
@ -4,8 +4,11 @@
|
|||
echo "Subject: Testing, please ignore
|
||||
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
|
||||
username=$(basename "$dir");
|
||||
|
||||
|
@ -14,8 +17,9 @@ do
|
|||
continue
|
||||
fi
|
||||
|
||||
if [ ! -d "$TO/$username" ]; then
|
||||
sendmail "$username@skynet.ie" < email.txt
|
||||
|
||||
echo "Complete: $username"
|
||||
echo "Mail Sent: $username"
|
||||
fi
|
||||
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue