| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/bin/bash
- # info: change user contact email
- # options: user email
- #
- # The function for changing of e-mail associated with a certain user.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument defenition
- user=$1
- email=$2
- # Importing variables
- source $VESTA/conf/vars.conf
- source $V_CONF/vesta.conf
- source $V_FUNC/shared.func
- #----------------------------------------------------------#
- # 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
|