|
| 1 | +#!/bin/bash |
| 2 | +# info: delete mail domain dkim support |
| 3 | +# options: user domain [dkim_size] |
| 4 | +# |
| 5 | +# The function delete DKIM domain pem. |
| 6 | + |
| 7 | + |
| 8 | +#----------------------------------------------------------# |
| 9 | +# Variable&Function # |
| 10 | +#----------------------------------------------------------# |
| 11 | + |
| 12 | +# Argument defenition |
| 13 | +user=$1 |
| 14 | +domain=$(idn -t --quiet -u "$2" ) |
| 15 | +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') |
| 16 | + |
| 17 | +# Importing variables |
| 18 | +source $VESTA/conf/vars.conf |
| 19 | +source $V_CONF/vesta.conf |
| 20 | +source $V_FUNC/shared.func |
| 21 | +source $V_FUNC/domain.func |
| 22 | + |
| 23 | + |
| 24 | +#----------------------------------------------------------# |
| 25 | +# Verifications # |
| 26 | +#----------------------------------------------------------# |
| 27 | + |
| 28 | +# Checking arg number |
| 29 | +check_args '2' "$#" 'user domain' |
| 30 | + |
| 31 | +# Checking argument format |
| 32 | +format_validation 'user' 'domain' |
| 33 | + |
| 34 | +# Checking dns system is enabled |
| 35 | +is_system_enabled 'MAIL_SYSTEM' |
| 36 | + |
| 37 | +# Checking user |
| 38 | +is_user_valid |
| 39 | + |
| 40 | +# Checking user is active |
| 41 | +is_user_suspended |
| 42 | + |
| 43 | +# Checking domain |
| 44 | +is_domain_valid 'mail' |
| 45 | + |
| 46 | +# Checking domain is not suspened |
| 47 | +is_domain_suspended 'mail' |
| 48 | + |
| 49 | +# Checking errorlog is not added |
| 50 | +is_domain_value_exist 'mail' '$DKIM' |
| 51 | + |
| 52 | + |
| 53 | +#----------------------------------------------------------# |
| 54 | +# Action # |
| 55 | +#----------------------------------------------------------# |
| 56 | + |
| 57 | +# Generating dkim |
| 58 | +rm -f $V_USERS/$user/mail/$domain.pem |
| 59 | +rm -f $V_USERS/$user/mail/$domain.pub |
| 60 | +rm -f $V_HOME/$user/conf/mail/$domain/dkim.pem |
| 61 | + |
| 62 | +# Checking dns domain |
| 63 | +check_dns_domain=$(is_domain_valid 'dns') |
| 64 | +if [ "$?" -eq 0 ]; then |
| 65 | + records=$($V_BIN/v_list_dns_domain_records $user $domain plain) |
| 66 | + dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ') |
| 67 | + for id in $dkim_records; do |
| 68 | + $V_BIN/v_delete_dns_domain_record $user $domain $id |
| 69 | + done |
| 70 | +fi |
| 71 | + |
| 72 | + |
| 73 | +#----------------------------------------------------------# |
| 74 | +# Vesta # |
| 75 | +#----------------------------------------------------------# |
| 76 | + |
| 77 | +# Adding dkim in config |
| 78 | +update_domain_value 'mail' '$DKIM' 'no' |
| 79 | + |
| 80 | +# Logging |
| 81 | +log_history "$V_EVENT" "v_add_mail_domain_dkim $user $domain" |
| 82 | +log_event 'system' "$V_EVENT" |
| 83 | + |
| 84 | +exit |
0 commit comments