| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #!/bin/bash
- # info: change user nameservers
- # options: user ns1 ns2 [ns3] [ns4]
- #
- # The function for changing default nameservers for speciefic user.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument defenition
- user=$1
- ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
- ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
- ns3=$4
- ns4=$5
- # Includes
- source $VESTA/conf/vesta.conf
- source $VESTA/func/main.sh
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- # Checking args
- check_args '3' "$#" 'user ns1 ns2 [ns3] [ns4]'
- # Checking argument format
- validate_format 'user' 'ns1' 'ns2'
- if [ ! -z "$ns3" ]; then
- ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
- validate_format 'ns3'
- fi
- if [ ! -z "$ns4" ]; then
- ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
- validate_format 'ns4'
- fi
- is_object_valid 'user' 'USER' "$user"
- is_object_unsuspended 'user' 'USER' "$user"
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Merging values
- ns="$ns1,$ns2,$ns3,$ns4"
- ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//")
- # Changing ns values
- update_user_value "$user" '$NS' "$ns"
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- # Logging
- log_history "changed user nameservers to $ns1, $ns2"
- log_event "$OK" "$EVENT"
- exit
|