|
|
@@ -0,0 +1,67 @@
|
|
|
+#!/bin/bash
|
|
|
+# info: change dns domain record id
|
|
|
+# options: USER DOMAIN ID NEWID
|
|
|
+#
|
|
|
+# The function for changing internal record id.
|
|
|
+
|
|
|
+
|
|
|
+#----------------------------------------------------------#
|
|
|
+# 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")
|
|
|
+id=$3
|
|
|
+newid=$4
|
|
|
+
|
|
|
+# Includes
|
|
|
+source $VESTA/conf/vesta.conf
|
|
|
+source $VESTA/func/main.sh
|
|
|
+source $VESTA/func/domain.sh
|
|
|
+
|
|
|
+
|
|
|
+#----------------------------------------------------------#
|
|
|
+# Verifications #
|
|
|
+#----------------------------------------------------------#
|
|
|
+
|
|
|
+check_args '4' "$#" 'USER DOMAIN ID NEWID'
|
|
|
+validate_format 'user' 'domain' 'id' 'newid'
|
|
|
+is_system_enabled "$DNS_SYSTEM"
|
|
|
+is_object_valid 'user' 'USER' "$user"
|
|
|
+is_object_unsuspended 'user' 'USER' "$user"
|
|
|
+is_object_valid 'dns' 'DOMAIN' "$domain"
|
|
|
+is_object_unsuspended 'dns' 'DOMAIN' "$domain"
|
|
|
+is_object_valid "dns/$domain" 'ID' "$id"
|
|
|
+is_object_new "dns/$domain" 'ID' "$newid"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#----------------------------------------------------------#
|
|
|
+# Action #
|
|
|
+#----------------------------------------------------------#
|
|
|
+
|
|
|
+# Change id
|
|
|
+sed -i "s/^ID='$id'/ID='$newid'/" $USER_DATA/dns/$domain.conf
|
|
|
+
|
|
|
+# Sorting records
|
|
|
+sort_dns_records
|
|
|
+
|
|
|
+# Updating zone
|
|
|
+update_domain_zone
|
|
|
+
|
|
|
+
|
|
|
+#----------------------------------------------------------#
|
|
|
+# Vesta #
|
|
|
+#----------------------------------------------------------#
|
|
|
+
|
|
|
+# Restart named
|
|
|
+$BIN/v-restart-dns "$EVENT"
|
|
|
+
|
|
|
+# Logging
|
|
|
+log_history "changed dns record id on $domain"
|
|
|
+log_event "$OK" "$EVENT"
|
|
|
+
|
|
|
+exit
|