mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-22 21:40:20 -08:00
86 lines
2.5 KiB
Bash
Executable File
86 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: change user nameservers
|
|
# options: USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]
|
|
#
|
|
# The function for changing default nameservers for specific user.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
user=$1
|
|
ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
ns5=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
ns6=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
ns7=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
ns8=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
# Checking args
|
|
check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]'
|
|
|
|
# Checking argument format
|
|
is_format_valid 'user' 'ns1' 'ns2'
|
|
if [ ! -z "$ns3" ]; then
|
|
ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
is_format_valid 'ns3'
|
|
fi
|
|
if [ ! -z "$ns4" ]; then
|
|
ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
is_format_valid 'ns4'
|
|
fi
|
|
if [ ! -z "$ns5" ]; then
|
|
ns5=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
is_format_valid 'ns5'
|
|
fi
|
|
if [ ! -z "$ns6" ]; then
|
|
ns6=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
is_format_valid 'ns6'
|
|
fi
|
|
if [ ! -z "$ns7" ]; then
|
|
ns7=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
is_format_valid 'ns7'
|
|
fi
|
|
if [ ! -z "$ns8" ]; then
|
|
ns8=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
|
is_format_valid 'ns8'
|
|
fi
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_unsuspended 'user' 'USER' "$user"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Merging values
|
|
ns="$ns1,$ns2,$ns3,$ns4,$ns5,$ns6,$ns7,$ns8"
|
|
ns=$(echo "$ns" | sed -e "s/,,//g" -e "s/,$//")
|
|
|
|
# Changing ns values
|
|
update_user_value "$user" '$NS' "$ns"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Logging
|
|
log_history "updated nameservers $ns1 $ns2 $ns3 $ns4 $ns5 $ns6 $ns7 $ns8"
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
exit
|