mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 13:01:52 -07:00
Update v-import-cpanel-backup
This commit is contained in:
parent
ef5ef95194
commit
7ee011a9d3
1 changed files with 23 additions and 22 deletions
|
@ -269,28 +269,29 @@ cd $sk_mdir
|
||||||
for sk_maild in $(ls -1)
|
for sk_maild in $(ls -1)
|
||||||
do
|
do
|
||||||
if [[ "$sk_maild" != "cur" && "$sk_maild" != "new" && "$sk_maild" != "tmp" ]]; then
|
if [[ "$sk_maild" != "cur" && "$sk_maild" != "new" && "$sk_maild" != "tmp" ]]; then
|
||||||
if [ -d "$sk_maild" ]; then
|
if [ -d "$sk_maild" ]; then
|
||||||
for sk_mail_account in $(ls $sk_maild/)
|
for sk_mail_account in $(ls $sk_maild/)
|
||||||
do
|
do
|
||||||
|
echo "Create and restore mail account: $sk_mail_account@$sk_maild"
|
||||||
echo "Create and restore mail account: $sk_mail_account@$sk_maild"
|
sk_mail_pass1=$(generate_password)
|
||||||
sk_mail_pass1=$(generate_password)
|
/usr/local/vesta/bin/v-add-mail-account $sk_cp_user $sk_maild $sk_mail_account $sk_mail_pass1
|
||||||
/usr/local/vesta/bin/v-add-mail-account $sk_cp_user $sk_maild $sk_mail_account $sk_mail_pass1
|
mv ${sk_maild}/${sk_mail_account} /home/${sk_cp_user}/mail/${sk_maild}
|
||||||
mv ${sk_maild}/${sk_mail_account} /home/${sk_cp_user}/mail/${sk_maild}
|
chown ${sk_cp_user}:mail -R /home/${sk_cp_user}/mail/${sk_maild}
|
||||||
chown ${sk_cp_user}:mail -R /home/${sk_cp_user}/mail/${sk_maild}
|
find /home/${sk_cp_user}/mail/${sk_maild} -type f -name 'dovecot*' -delete
|
||||||
find /home/${sk_cp_user}/mail/${sk_maild} -type f -name 'dovecot*' -delete
|
# echo "${sk_mail_account}@${sk_maild} | $sk_mail_pass1" >> /root/sk_mail_password_${sk_cp_user}-${sk_cod}
|
||||||
# echo "${sk_mail_account}@${sk_maild} | $sk_mail_pass1" >> /root/sk_mail_password_${sk_cp_user}-${sk_cod}
|
if [ -f "${sk_importer_in}/homedir/etc/${sk_maild}/shadow" ]; then
|
||||||
echo "Set password for ${sk_mail_account}@${sk_maild}"
|
echo "Set password for ${sk_mail_account}@${sk_maild}"
|
||||||
pass=$(grep "^${sk_mail_account}:" ${sk_importer_in}/homedir/etc/${sk_maild}/shadow | awk -F ":" '{print $2}')
|
pass=$(grep "^${sk_mail_account}:" ${sk_importer_in}/homedir/etc/${sk_maild}/shadow | awk -F ":" '{print $2}')
|
||||||
newline="${sk_mail_account}:{SHA512-CRYPT}$pass:${sk_cp_user}:mail::/home/${sk_cp_user}:0"
|
newline="${sk_mail_account}:{SHA512-CRYPT}$pass:${sk_cp_user}:mail::/home/${sk_cp_user}:0"
|
||||||
newline2="ACCOUNT='${sk_mail_account}' ALIAS='' AUTOREPLY='no' FWD='' FWD_ONLY='' MD5='{SHA512-CRYPT}$pass' QUOTA='unlimited' U_DISK='0' SUSPENDED='no' TIME='$time' DATE='$date'"
|
newline2="ACCOUNT='${sk_mail_account}' ALIAS='' AUTOREPLY='no' FWD='' FWD_ONLY='' MD5='{SHA512-CRYPT}$pass' QUOTA='unlimited' U_DISK='0' SUSPENDED='no' TIME='$time' DATE='$date'"
|
||||||
# echo $newline
|
# echo $newline
|
||||||
escaped=$(printf '%s\n' "$newline" | sed -e 's/[\/&]/\\&/g')
|
escaped=$(printf '%s\n' "$newline" | sed -e 's/[\/&]/\\&/g')
|
||||||
escaped2=$(printf '%s\n' "$newline2" | sed -e 's/[\/&]/\\&/g')
|
escaped2=$(printf '%s\n' "$newline2" | sed -e 's/[\/&]/\\&/g')
|
||||||
sed -i "s/^${sk_mail_account}:.*/$escaped/g" /home/${sk_cp_user}/conf/mail/${sk_maild}/passwd
|
sed -i "s/^${sk_mail_account}:.*/$escaped/g" /home/${sk_cp_user}/conf/mail/${sk_maild}/passwd
|
||||||
sed -i "s/^ACCOUNT='${sk_mail_account}.*/$escaped2/g" /usr/local/vesta/data/users/${sk_cp_user}/mail/${sk_maild}.conf
|
sed -i "s/^ACCOUNT='${sk_mail_account}.*/$escaped2/g" /usr/local/vesta/data/users/${sk_cp_user}/mail/${sk_maild}.conf
|
||||||
done
|
fi
|
||||||
fi
|
done
|
||||||
|
fi
|
||||||
#else
|
#else
|
||||||
# this only detect default dirs account new, cur, tmp etc
|
# this only detect default dirs account new, cur, tmp etc
|
||||||
# maybe can do something with this, but on most cpanel default account have only spam.
|
# maybe can do something with this, but on most cpanel default account have only spam.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue