|
| 1 | +#!/bin/bash |
| 2 | +# info: change dns domain record id |
| 3 | +# options: USER DOMAIN ID NEWID |
| 4 | +# |
| 5 | +# The function for changing internal record id. |
| 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 | +domain_idn=$(idn -t --quiet -a "$domain") |
| 17 | +id=$3 |
| 18 | +newid=$4 |
| 19 | + |
| 20 | +# Includes |
| 21 | +source $VESTA/conf/vesta.conf |
| 22 | +source $VESTA/func/main.sh |
| 23 | +source $VESTA/func/domain.sh |
| 24 | + |
| 25 | + |
| 26 | +#----------------------------------------------------------# |
| 27 | +# Verifications # |
| 28 | +#----------------------------------------------------------# |
| 29 | + |
| 30 | +check_args '4' "$#" 'USER DOMAIN ID NEWID' |
| 31 | +validate_format 'user' 'domain' 'id' 'newid' |
| 32 | +is_system_enabled "$DNS_SYSTEM" |
| 33 | +is_object_valid 'user' 'USER' "$user" |
| 34 | +is_object_unsuspended 'user' 'USER' "$user" |
| 35 | +is_object_valid 'dns' 'DOMAIN' "$domain" |
| 36 | +is_object_unsuspended 'dns' 'DOMAIN' "$domain" |
| 37 | +is_object_valid "dns/$domain" 'ID' "$id" |
| 38 | +is_object_new "dns/$domain" 'ID' "$newid" |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +#----------------------------------------------------------# |
| 43 | +# Action # |
| 44 | +#----------------------------------------------------------# |
| 45 | + |
| 46 | +# Change id |
| 47 | +sed -i "s/^ID='$id'/ID='$newid'/" $USER_DATA/dns/$domain.conf |
| 48 | + |
| 49 | +# Sorting records |
| 50 | +sort_dns_records |
| 51 | + |
| 52 | +# Updating zone |
| 53 | +update_domain_zone |
| 54 | + |
| 55 | + |
| 56 | +#----------------------------------------------------------# |
| 57 | +# Vesta # |
| 58 | +#----------------------------------------------------------# |
| 59 | + |
| 60 | +# Restart named |
| 61 | +$BIN/v-restart-dns "$EVENT" |
| 62 | + |
| 63 | +# Logging |
| 64 | +log_history "changed dns record id on $domain" |
| 65 | +log_event "$OK" "$EVENT" |
| 66 | + |
| 67 | +exit |
0 commit comments