mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
imapsync tools
This commit is contained in:
parent
560fa67c4b
commit
2aca86432f
2 changed files with 83 additions and 11 deletions
|
@ -35,18 +35,35 @@ fi
|
||||||
|
|
||||||
TESTOPT=""
|
TESTOPT=""
|
||||||
if [[ $TEST -eq 1 ]]; then
|
if [[ $TEST -eq 1 ]]; then
|
||||||
TESTOPT="--justlogin"
|
TESTOPT="--justlogin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "accounts" ]; then
|
if [ ! -d "accounts" ]; then
|
||||||
mkdir accounts
|
mkdir accounts
|
||||||
fi
|
fi
|
||||||
if [ -f "accounts/$EMAIL" ]; then
|
if [ -f "accounts/$EMAIL" ]; then
|
||||||
echo "********* $EMAIL ALREADY EXISTS !!! ************"
|
echo "********* EMAIL $EMAIL ALREADY EXISTS !!! ************"
|
||||||
exit 1;
|
exit 1;
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
euser=$(echo $EMAIL | cut -d '@' -f 1)
|
||||||
|
domain=$(echo $EMAIL | cut -d '@' -f 2)
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
if [ "$user" != "" ]; then
|
||||||
|
echo "=== Email '$EMAIL' has username email part '$euser', domain is '$domain', and belongs to myVesta account: $user"
|
||||||
|
if [ ! -d "/home/$user/mail/$domain" ]; then
|
||||||
|
echo "======= Creating '$domail' in MAIL section"
|
||||||
|
/usr/local/vesta/bin/v-add-mail-domain "$user" "$domain"
|
||||||
|
fi
|
||||||
|
if [ ! -d "/home/$user/mail/$domain/$euser" ]; then
|
||||||
|
echo "======= Creating '$euser' mail account for domain '$domain'"
|
||||||
|
/usr/local/vesta/bin/v-add-mail-account "$user" "$domain" "$euser" "$PASS2"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Writing to: accounts/$EMAIL"
|
echo "Writing to: accounts/$EMAIL"
|
||||||
echo "#!/bin/bash
|
echo "#!/bin/bash
|
||||||
|
|
||||||
|
@ -67,21 +84,20 @@ exit;
|
||||||
chmod a=rwx accounts/$EMAIL
|
chmod a=rwx accounts/$EMAIL
|
||||||
|
|
||||||
if [[ $TEST -eq 0 ]]; then
|
if [[ $TEST -eq 0 ]]; then
|
||||||
exit 0;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
accounts/$EMAIL
|
accounts/$EMAIL
|
||||||
RET=$?
|
RET=$?
|
||||||
|
|
||||||
if [ $RET -eq 0 ]; then
|
if [ $RET -eq 0 ]; then
|
||||||
# echo "./create-mail-sync.sh $EMAIL $PASS $PASS2 $TEST"
|
# echo "./create-mail-sync.sh $EMAIL $PASS $PASS2 $TEST"
|
||||||
sed -i "s/--justlogin//g" accounts/$EMAIL
|
sed -i "s/--justlogin//g" accounts/$EMAIL
|
||||||
echo "--- OK! ---"
|
echo "--- OK! ---"
|
||||||
echo "./create-mail-sync.sh '$SRCHOST' '$EMAIL' '$PASS' '$PASS2' $TEST" >> accounts.log
|
echo "./create-mail-sync.sh '$SRCHOST' '$EMAIL' '$PASS' '$PASS2' $TEST" >> accounts.log
|
||||||
else
|
else
|
||||||
echo "********* $EMAIL ERROR !!! [ret: $RET ] ************"
|
echo "********* $EMAIL ERROR !!! [ret: $RET ] ************"
|
||||||
echo "********* $EMAIL ERROR !!! [ret: $RET ] ************"
|
rm accounts/$EMAIL
|
||||||
echo "********* $EMAIL ERROR !!! [ret: $RET ] ************"
|
read -p "=== Press ENTER to continue ===" entered
|
||||||
rm accounts/$EMAIL
|
|
||||||
fi
|
fi
|
||||||
exit $RET;
|
exit $RET;
|
||||||
|
|
56
src/deb/for-download/tools/imapsync/import-from-file.sh
Normal file
56
src/deb/for-download/tools/imapsync/import-from-file.sh
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This script reads email and password=s in following format:
|
||||||
|
# email1 pass
|
||||||
|
# email2 pass
|
||||||
|
# email3 pass
|
||||||
|
|
||||||
|
# The first parameter is the text file from which we read emails and passwords
|
||||||
|
# The second parameter is SMTP Hostname
|
||||||
|
# The third parameter is domain if lines contains only username part
|
||||||
|
|
||||||
|
|
||||||
|
host=''
|
||||||
|
if [ $# -gt 1 ]; then
|
||||||
|
host=$2
|
||||||
|
else
|
||||||
|
echo "Usage: ./import-from-file.sh 'FILE' 'SMTPHOST' ['DOMAIN']"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
domain=''
|
||||||
|
if [ $# -gt 2 ]; then
|
||||||
|
domain=$3
|
||||||
|
fi
|
||||||
|
|
||||||
|
end_of_file=0
|
||||||
|
while [[ $end_of_file == 0 ]]; do
|
||||||
|
|
||||||
|
read -r line
|
||||||
|
end_of_file=$?
|
||||||
|
|
||||||
|
if [ "$line" == "" ]; then
|
||||||
|
if [[ $end_of_file == 1 ]]; then
|
||||||
|
echo "===EOF==="
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
email=$(echo "$line" | awk '{print $1}')
|
||||||
|
pass=$(echo "$line" | awk '{print $2}')
|
||||||
|
|
||||||
|
if [[ $email != *"@"* ]]; then
|
||||||
|
email="$email@$domain"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Extracted: '$email' = '$pass'"
|
||||||
|
|
||||||
|
./create-mail-sync.sh "$host" "$email" "$pass"
|
||||||
|
|
||||||
|
if [[ $end_of_file == 1 ]]; then
|
||||||
|
echo "===EOF==="
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
|
||||||
|
done < $1
|
Loading…
Add table
Add a link
Reference in a new issue