mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-01-23 11:13:01 -08:00
72 lines
1.7 KiB
Bash
Executable File
72 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: changing ip owner
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument defenition
|
|
user="$1"
|
|
ip="$2"
|
|
|
|
# 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'
|
|
|
|
# Checking argument format
|
|
format_validation 'user' 'ip'
|
|
|
|
# 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'
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Get ip and user owner
|
|
ip_owner=$(get_sys_ip_value '$OWNER')
|
|
user_owner=$(get_user_value '$OWNER')
|
|
owner_role=$(get_user_value '$ROLE')
|
|
|
|
# Checking permissions
|
|
if [ "$owner_role" != 'admin' ] || [ "$ip_owner" != "$user_owner" ]; then
|
|
echo "Error: ip owner is not admin"
|
|
log_event 'debug' "$E_PERMS_REQUEIURED $V_EVENT"
|
|
exit $E_PERMS_REQUEIURED
|
|
fi
|
|
|
|
# Changing ip owner
|
|
update_sys_ip_value '$OWNER' "$user"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Logging
|
|
log_event 'system' "$V_EVENT"
|
|
|
|
exit $OK
|