mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-01-23 11:13:01 -08:00
58 lines
1.5 KiB
Bash
Executable File
58 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: changing user contact email
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument defenition
|
|
user="$1"
|
|
email="$2"
|
|
|
|
# Importing variables
|
|
source $VESTA/conf/vars.conf
|
|
source $V_FUNC/shared_func.sh
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
# Checking arg number
|
|
check_args '2' "$#" 'user email'
|
|
|
|
# Checking argument format
|
|
format_validation 'user' 'email'
|
|
|
|
# Checking user
|
|
is_user_valid
|
|
|
|
# Checking user is active
|
|
is_user_suspended
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Get old value
|
|
old_email=$(get_user_value '$CONTACT')
|
|
|
|
# Changing user contact email
|
|
update_user_value "$user" '$CONTACT' "$email"
|
|
|
|
# Changing passwd file
|
|
pw_str=$(grep -n "^$user:" /etc/passwd)
|
|
str=$(echo "$pw_str" | cut -f 1 -d :)
|
|
sed -i "$str s/$old_email/$email/g" /etc/passwd
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Logging
|
|
log_history "$V_EVENT" "$V_SCRIPT $user $old_email"
|
|
log_event 'system' "$V_EVENT"
|
|
|
|
exit $OK
|