mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 10:37:42 -07:00
replaced underscore with dash in api syscalls
This commit is contained in:
parent
7ed705cee7
commit
b6b7eacadb
283 changed files with 438 additions and 412 deletions
81
bin/v-change-sys-ip-owner
Executable file
81
bin/v-change-sys-ip-owner
Executable file
|
@ -0,0 +1,81 @@
|
|||
#!/bin/bash
|
||||
# info: change ip owner
|
||||
# options: ip user
|
||||
#
|
||||
# The function of changing ip address ownership.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
ip=$1
|
||||
user=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/ip.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'ip user'
|
||||
validate_format 'ip' 'user'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_ip_valid
|
||||
is_ip_key_empty '$U_WEB_DOMAINS'
|
||||
is_ip_key_empty '$U_SYS_USERS'
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Changing ip owner
|
||||
ip_owner=$(get_ip_value '$OWNER')
|
||||
if [ "$ip_owner" != "$user" ]; then
|
||||
ip_status="$(get_ip_value '$STATUS')"
|
||||
update_ip_value '$OWNER' "$user"
|
||||
decrease_user_value "$ip_owner" '$IP_OWNED'
|
||||
if [ "$ip_owner" = 'admin' ]; then
|
||||
if [ "$ip_status" = 'shared' ]; then
|
||||
for vesta_user in $(ls $VESTA/data/users); do
|
||||
decrease_user_value "$vesta_user" '$IP_AVAIL'
|
||||
done
|
||||
else
|
||||
decrease_user_value 'admin' '$IP_AVAIL'
|
||||
fi
|
||||
else
|
||||
decrease_user_value "$ip_owner" '$IP_AVAIL'
|
||||
decrease_user_value 'admin' '$IP_AVAIL'
|
||||
fi
|
||||
|
||||
increase_user_value "$user" '$IP_OWNED'
|
||||
if [ "$user" = 'admin' ]; then
|
||||
if [ "$ip_status" = 'shared' ]; then
|
||||
for user in $(ls $VESTA/data/users); do
|
||||
increase_user_value "$user" '$IP_AVAIL'
|
||||
done
|
||||
else
|
||||
increase_user_value 'admin' '$IP_AVAIL'
|
||||
fi
|
||||
else
|
||||
increase_user_value "$user" '$IP_AVAIL'
|
||||
increase_user_value 'admin' '$IP_AVAIL'
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_history "changed owner of $ip to $user" '' 'admin'
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue