removed child user support

This commit is contained in:
Serghey Rodin 2011-10-20 11:17:25 +03:00
commit 72781b5663
18 changed files with 36 additions and 422 deletions

View file

@ -9,7 +9,7 @@
ip="$1"
mask="$2"
interface="${3-eth0}"
owner="${4-vesta}"
user="${4-vesta}"
ip_status="${5-shared}"
ip_name="$6"
@ -24,19 +24,16 @@ source $V_FUNC/domain_func.sh # for namehosting
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'ip mask [interface] [owner] [ip_status] [ip_name]'
check_args '2' "$#" 'ip mask [interface] [user] [ip_status] [ip_name]'
# Checking argument format
format_validation 'ip' 'mask' 'interface'
format_validation 'ip' 'mask' 'interface' 'user'
# Checking system ip
is_sys_ip_free
# Checking owner
if [ ! -z "$owner" ]; then
format_validation 'user'
is_user_valid "$owner"
fi
# Checking user
is_user_valid "$user"
# Checking ip_status
if [ ! -z "$ip_status" ]; then
@ -84,10 +81,7 @@ namehost_ip_support
#----------------------------------------------------------#
# Updating user conf
if [ ! -z "$owner" ]; then
user="$owner"
increase_user_value "$user" '$IP_OWNED'
fi
increase_user_value "$user" '$IP_OWNED'
# Adding task to the vesta pipe
if [ "$web_restart" = 'yes' ]; then

View file

@ -9,11 +9,9 @@
user="$1"
password="$2"
email="$3"
role="$4"
owner="${5-vesta}"
package="${6-default}"
fname=$7
lname=$8
package="${4-default}"
fname=$5
lname=$6
# Importing variables
source $VESTA/conf/vars.conf
@ -25,29 +23,16 @@ source $V_FUNC/shared_func.sh
#----------------------------------------------------------#
# Checking arg number
check_args '5' "$#" 'user password email role owner [package] [fname] [lname]'
check_args '3' "$#" 'user password email [package] [fname] [lname]'
# Checking argument format
format_validation 'user' 'password' 'email' 'role' 'owner' 'package'
format_validation 'fname' 'lname'
format_validation 'user' 'password' 'email' 'package' 'fname' 'lname'
# Checking user
is_user_free "$user"
# Checking 'vesta' user creation
if [ "$user" != 'vesta' ]; then
# Checking owner
is_user_valid "$owner"
# Checking owner role
is_user_privileged "$owner"
# Checking owner permission
is_user_privileged "$owner" "$role"
# Checking package
is_package_valid "$package"
fi
# Checking package
is_package_valid "$package"
#----------------------------------------------------------#
@ -149,12 +134,9 @@ LNAME='$lname'
PACKAGE='$package'
$package_data
SUSPENDED='no'
OWNER='$owner'
ROLE='$role'
CONTACT='$email'
REPORTS='yes'
IP_OWNED='0'
U_CHILDS='0'
U_DIR_DISK='0'
U_DISK='0'
U_BANDWIDTH='0'
@ -165,15 +147,9 @@ U_DATABASES='0'
U_MAIL_DOMAINS='0'
DATE='$V_DATE'" > $V_USERS/$user/user.conf
# Filling owner config
if [ "$user" != 'vesta' ]; then
echo "USER='$user'" >> $V_USERS/$owner/child.conf
increase_user_value "$owner" 'U_CHILDS'
fi
# Hiding password
dt="$(date +%m-%d-%y" "%H:%m:%S)"
V_EVENT="$dt $V_SCRIPT $user ***** $email $role $owner $package $fname $lname"
V_EVENT="$dt $V_SCRIPT $user ***** $email $package $fname $lname"
# Logging
log_event 'system' "$V_EVENT"

View file

@ -1,67 +0,0 @@
#!/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

View file

@ -368,14 +368,6 @@ if [ -e "$V_USERS/$user/billing.log" ]; then
cp -r $V_USERS/$user/billing.log $tmpdir/vesta/
fi
if [ -e "$V_USERS/$user/child.conf" ]; then
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) child.conf"
fi
cp -r $V_USERS/$user/child.conf $tmpdir/vesta/
fi
if [ -e "$V_USERS/$user/history.log" ]; then
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) history.log"

View file

@ -45,20 +45,13 @@ 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"
ip_owner=$(get_sys_ip_value '$OWNER')
if [ "$ip_owner" != "$user" ]; then
update_sys_ip_value '$OWNER' "$user"
decrease_user_value "$ip_owner" '$IP_OWNED'
increase_user_value "$user" '$IP_OWNED'
fi
#----------------------------------------------------------#

View file

@ -33,9 +33,10 @@ is_user_valid
# Checking user is active
is_user_suspended
# Checking user childs
is_user_parent
# Checking user vesta
if [ "$user" = 'vesta' ]; then
exit
fi
#----------------------------------------------------------#
# Action #
@ -111,18 +112,6 @@ if [ ! -z "$statp" ]; then
done
fi
# Deleteing user from parent
owner=$(get_user_value '$OWNER')
if [ -e "$V_USERS/$owner/child.conf" ]; then
childc=$(grep -n "USER='$user'" $V_USERS/$owner/child.conf |\
cut -d : -f 1 | sort -n -r)
fi
if [ ! -z "$childc" ]; then
for str in $childc; do
sed -i "$str d" $V_USERS/$owner/child.conf
done
fi
# Removing system user
userdel -f $user
rm -rf $V_HOME/$user

View file

@ -1,65 +0,0 @@
#!/bin/bash
# info: deleting user ip
#----------------------------------------------------------#
# 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 user ip
is_sys_ip_valid
# Checking ownership
is_sys_ip_owner
# Checking webdomains on ip
is_ip_key_empty '$U_WEB_DOMAINS'
# Checking users on ip
is_ip_key_empty '$U_SYS_USERS'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Deleting owner
update_sys_ip_value '$OWNER' ''
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Updating user conf
decrease_user_value $user '$IP_OWNED'
# Logging
log_event 'system' "$V_EVENT"
exit $OK

View file

@ -1,57 +0,0 @@
#!/bin/bash
# info: deleting user ip
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
# 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 '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Starting delete loop
for ip in $(ip_owner_search); do
$V_BIN/v_del_sys_user_ip "$user" "$ip"
rv="$?"
if [ "$rv" -ne '0' ]; then
log_event 'debug' "$rv $V_EVENT"
exit $rv
fi
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit $OK

View file

@ -38,9 +38,9 @@ conf="$V_USERS/$user/user.conf"
# Defining fileds to select
fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES
$DATABASES $MAIL_DOMAINS $MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS
$DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $WEB_TPL $MAX_CHILDS $SUSPENDED
$OWNER $ROLE $IP_OWNED $U_CHILDS $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS
$U_WEB_SSL $U_DNS_DOMAINS $U_DATABASES $U_MAIL_DOMAINS $CONTACT $DATE'
$DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $WEB_TPL $SUSPENDED $IP_OWNED
$U_DISK $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_DNS_DOMAINS $U_DATABASES
$U_MAIL_DOMAINS $CONTACT $DATE'
# Listing user
case $format in

View file

@ -1,55 +0,0 @@
#!/bin/bash
# info: listing user childs
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
format="${2-shell}"
limit="${3-1000}"
offset="${4-1}"
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared_func.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user [format] [limit] [offset]'
# Checking argument format
format_validation 'user' 'limit' 'offset'
# Checking user
is_user_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining fileds to select
fields='$USER'
# Listing domains
case $format in
json) childs_json_list ;;
shell) childs_shell_list ;;
*) check_args '1' '0' 'user [format] [limit] [offset]'
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit $OK

View file

@ -34,9 +34,6 @@ is_user_valid
# Action #
#----------------------------------------------------------#
# Get user owner
owner=$(get_user_value '$OWNER')
# Defining fileds to select
fields='$IP $OWNER $STATUS $NAME'

View file

@ -30,7 +30,7 @@ format_validation 'limit' 'offset'
# Defining fields
fields='$PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES $DATABASES $MAIL_DOMAINS
$MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS $DISK_QUOTA $BANDWIDTH $NS1 $NS2
$SHELL $BACKUPS $WEB_TPL $MAX_CHILDS'
$SHELL $BACKUPS $WEB_TPL'
# Listing domains
case $format in

View file

@ -29,9 +29,9 @@ format_validation 'limit' 'offset'
# Defining fileds to select
fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES
$DATABASES $MAIL_DOMAINS $MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS
$DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $WEB_TPL $MAX_CHILDS $SUSPENDED
$OWNER $ROLE $IP_OWNED $U_CHILDS $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS
$U_WEB_SSL $U_DNS_DOMAINS $U_DATABASES $U_MAIL_DOMAINS $CONTACT $DATE'
$DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $WEB_TPL $SUSPENDED $IP_OWNED
$U_DISK $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_DNS_DOMAINS $U_DATABASES
$U_MAIL_DOMAINS $CONTACT $DATE'
# Listing domains
case $format in

View file

@ -111,7 +111,7 @@ for user in $user_list; do
DATE=$(date -d "$(date +'%m/01') -1day" +%m-%d-%y)
# Compiling report string
v_str="DATE='$DATE' PACKAGE='$PACKAGE' U_CHILDS='$U_CHILDS'"
v_str="DATE='$DATE' PACKAGE='$PACKAGE'"
v_str="$v_str U_DISK='$U_DISK' U_BANDWIDTH='$U_BANDWIDTH'"
v_str="$v_str U_WEB_DOMAINS='$U_WEB_DOMAINS' U_WEB_SSL='$U_WEB_SSL'"
v_str="$v_str U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DATABASES='$U_DATABASES'"