vesta/bin/v_add_sys_user_ip
2011-06-14 00:22:25 +03:00

68 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# info: addding ip to user
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
ip="$2"
ip_status="${3-exclusive}"
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared_func.sh
source $V_FUNC/ip_func.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user ip [ip_status]'
# Checking argument format
format_validation 'user' 'ip' 'ip_status'
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
# Checking system ip
is_sys_ip_valid
# Checking webdomains on ip
is_ip_key_empty '$U_WEB_DOMAINS'
# Checking users on ip
is_ip_key_empty '$U_SYS_USERS'
# Checking ip owner
is_ip_key_empty '$OWNER'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Adding ip to user
update_sys_ip_value '$OWNER' "$user"
update_sys_ip_value '$STATUS' "$ip_status"
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Updating user conf
increase_user_value "$user" '$IP_OWNED'
# Logging
log_event 'system' "$V_EVENT"
exit $OK