mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 18:49:17 -07:00
fwd-only flag
This commit is contained in:
parent
6e75b6e4b4
commit
3e521cb8a2
11 changed files with 202 additions and 6 deletions
|
@ -63,7 +63,8 @@ echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
|||
#----------------------------------------------------------#
|
||||
|
||||
str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''"
|
||||
str="$str MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
|
||||
str="$str FWD_ONLY='' MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME'"
|
||||
str="$str DATE='$DATE'"
|
||||
echo "$str" >> $USER_DATA/mail/$domain.conf
|
||||
chmod 660 $USER_DATA/mail/$domain.conf
|
||||
|
||||
|
|
79
bin/v-add-mail-account-fwd-only
Executable file
79
bin/v-add-mail-account-fwd-only
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
# info: add mail account forward-only flag
|
||||
# options: USER DOMAIN ACCOUNT
|
||||
#
|
||||
# The function adds fwd-only flag
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
account=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN ACCOUNT'
|
||||
validate_format 'user' 'domain' 'account'
|
||||
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'mail' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
|
||||
is_object_valid "mail/$domain" 'ACCOUNT' "$account"
|
||||
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
|
||||
fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD')
|
||||
if [ -z "$fwd" ]; then
|
||||
echo "Error: forward doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Adding account to fwd_only
|
||||
touch $HOMEDIR/$user/conf/mail/$domain/fwd_only
|
||||
check_fwd=$(grep "^$account$" $HOMEDIR/$user/conf/mail/$domain/fwd_only)
|
||||
if [ -z "$check_fwd" ]; then
|
||||
echo "$account" > $HOMEDIR/$user/conf/mail/$domain/fwd_only
|
||||
fi
|
||||
|
||||
# Set ownership
|
||||
if [ "$MAIL_SYSTEM" = 'exim' ]; then
|
||||
mail_user=exim
|
||||
fi
|
||||
if [ "$MAIL_SYSTEM" = 'exim4' ]; then
|
||||
mail_user=Debian-exim
|
||||
fi
|
||||
chown -R $mail_user:mail $HOMEDIR/$user/conf/mail/$domain/fwd_only
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating config
|
||||
add_object_key "mail/$domain" 'ACCOUNT' "$account" 'FWD_ONLY' 'MD5'
|
||||
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD_ONLY' "yes"
|
||||
|
||||
# Logging
|
||||
log_history "added fwd_only flag for $account@$domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
59
bin/v-delete-mail-account-fwd-only
Executable file
59
bin/v-delete-mail-account-fwd-only
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash
|
||||
# info: delete mail account forward-only flag
|
||||
# options: USER DOMAIN ACCOUNT
|
||||
#
|
||||
# The function deletes fwd-only flag
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
account=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN ACCOUNT'
|
||||
validate_format 'user' 'domain' 'account'
|
||||
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'mail' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
|
||||
is_object_valid "mail/$domain" 'ACCOUNT' "$account"
|
||||
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Deleting account from fwd_only
|
||||
sed -i "/^$account$/d" $HOMEDIR/$user/conf/mail/$domain/fwd_only
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating config
|
||||
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD_ONLY' ''
|
||||
|
||||
# Logging
|
||||
log_history "deleted fwd_only flag for $account@$domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -75,8 +75,8 @@ is_object_valid "mail/$domain" 'ACCOUNT' "$account"
|
|||
|
||||
# Defining config and fields to select
|
||||
conf=$USER_DATA/mail/$domain.conf
|
||||
fields="\$ACCOUNT \$ALIAS \$FWD \$QUOTA \$AUTOREPLY \$U_DISK \$SUSPENDED"
|
||||
fields="$fields \$TIME \$DATE"
|
||||
fields="\$ACCOUNT \$ALIAS \$FWD \$FWD_ONLY \$QUOTA \$AUTOREPLY \$U_DISK"
|
||||
fields="$fields \$SUSPENDED \$TIME \$DATE"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
|
|
|
@ -34,8 +34,8 @@ is_object_valid 'mail' 'DOMAIN' "$domain"
|
|||
|
||||
# Defining fileds to select
|
||||
conf=$USER_DATA/mail/$domain.conf
|
||||
fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$QUOTA \$U_DISK \$SUSPENDED"
|
||||
fields="$fields \$TIME \$DATE"
|
||||
fields="\$ACCOUNT \$ALIAS \$FWD \$FWD_ONLY \$QUOTA \$AUTOREPLY \$U_DISK"
|
||||
fields="$fields \$SUSPENDED \$TIME \$DATE"
|
||||
|
||||
# Listing domain accounts
|
||||
case $format in
|
||||
|
|
11
func/main.sh
11
func/main.sh
|
@ -287,6 +287,17 @@ update_object_value() {
|
|||
$USER_DATA/$1.conf
|
||||
}
|
||||
|
||||
# Add object key
|
||||
add_object_key() {
|
||||
row=$(grep -n "$2='$3'" $USER_DATA/$1.conf)
|
||||
lnr=$(echo $row | cut -f 1 -d ':')
|
||||
object=$(echo $row | sed "s/^$lnr://")
|
||||
if [ -z "$(echo $object |grep $4=)" ]; then
|
||||
eval old="$4"
|
||||
sed -i "$lnr s/$5='/$4='' $5='/" $USER_DATA/$1.conf
|
||||
fi
|
||||
}
|
||||
|
||||
# Search objects
|
||||
search_objects() {
|
||||
OLD_IFS="$IFS"
|
||||
|
|
|
@ -435,8 +435,10 @@ rebuild_mail_domain_conf() {
|
|||
rm -f $HOMEDIR/$user/conf/mail/$domain/antivirus
|
||||
rm -f $HOMEDIR/$user/conf/mail/$domain/protection
|
||||
rm -f $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||
rm -f $HOMEDIR/$user/conf/mail/$domain/fwd_only
|
||||
touch $HOMEDIR/$user/conf/mail/$domain/aliases
|
||||
touch $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||
touch $HOMEDIR/$user/conf/mail/$domain/fwd_only
|
||||
|
||||
# Adding antispam protection
|
||||
if [ "$ANTISPAM" = 'yes' ]; then
|
||||
|
@ -519,6 +521,9 @@ rebuild_mail_domain_conf() {
|
|||
if [ ! -z "$FWD" ]; then
|
||||
echo "$account@$domain:$FWD" >> $dom_aliases
|
||||
fi
|
||||
if [ "$FWD_ONLY" = 'yes' ]; then
|
||||
echo "$account" >> $HOMEDIR/$user/conf/mail/$domain/fwd_only
|
||||
fi
|
||||
done
|
||||
|
||||
# Set permissions
|
||||
|
|
|
@ -130,8 +130,13 @@ if (!empty($_POST['ok_acc'])) {
|
|||
}
|
||||
unset($output);
|
||||
}
|
||||
// Add fwd_only flag
|
||||
if ((!empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-add-mail-account-fwd-only ".$user." ".$v_domain." ".$v_account, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
unset($output);
|
||||
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
|
||||
|
|
|
@ -140,6 +140,7 @@ if ((!empty($_GET['domain'])) && (empty($_GET['account']))) {
|
|||
$valiases = explode(",", $data[$v_account]['ALIAS']);
|
||||
$v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']);
|
||||
$vfwd = explode(",", $data[$v_account]['FWD']);
|
||||
$v_fwd_only = $data[$v_account]['FWD_ONLY'];
|
||||
$v_quota = $data[$v_account]['QUOTA'];
|
||||
$v_autoreply = $data[$v_account]['AUTOREPLY'];
|
||||
if ( $v_autoreply == 'yes' ) {
|
||||
|
@ -234,6 +235,20 @@ if ((!empty($_GET['domain'])) && (empty($_GET['account']))) {
|
|||
}
|
||||
}
|
||||
|
||||
// FWD_ONLY flag
|
||||
if (($v_fwd_only == 'yes') && (empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-mail-account-fwd-only ".$v_username." ".$v_domain." ".$v_account, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_fwd_only = '';
|
||||
}
|
||||
if (($v_fwd_only != 'yes') && (!empty($_POST['v_fwd_only'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-add-mail-account-fwd-only ".$v_username." ".$v_domain." ".$v_account, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
$v_fwd_only = 'yes';
|
||||
}
|
||||
|
||||
// Autoreply
|
||||
if (($v_autoreply == 'yes') && (empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) {
|
||||
exec (VESTA_CMD."v-delete-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account, $output, $return_var);
|
||||
|
|
|
@ -127,6 +127,17 @@
|
|||
<textarea size="20" class="vst-textinput" name="v_fwd"><?php if (!empty($v_fwd)) echo $v_fwd; ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="vst-text" style="padding: 10 0 0 2px;">
|
||||
<?php print __("Don't store forwarded mail");?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" size="20" class="vst-checkbox" name="v_fwd_only" <?php if ($v_fwd_only == 'yes') echo "checked=yes" ?>>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -118,6 +118,16 @@
|
|||
<textarea size="20" class="vst-textinput" name="v_fwd"><?php if (!empty($v_fwd)) echo $v_fwd; ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="vst-text" style="padding: 10 0 0 2px;">
|
||||
<?php print __("Don't store forwarded mail");?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" size="20" class="vst-checkbox" name="v_fwd_only" <?php if ($v_fwd_only == 'yes') echo "checked=yes" ?>>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="vst-text" style="padding: 10px 0 0 2px;">
|
||||
<?php print __('Autoreply');?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue