myvesta/bin/v-change-user-name
2016-06-09 16:55:35 +03:00

54 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# info: change user full name
# options: USER FNAME LNAME
#
# The function allow to change user's full name.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
user=$1
fname=$2
lname=$3
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER FNAME LNAME'
is_format_valid 'user' 'fname' 'lname'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get old values
old_fname=$(get_user_value '$FNAME')
old_lname=$(get_user_value '$LNAME')
# Changing ns values
update_user_value "$user" '$FNAME' "$fname"
update_user_value "$user" '$LNAME' "$lname"
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_history "changed user name to $fname $lname"
log_event "$OK" "$ARGUMENTS"
exit