edit user package

This commit is contained in:
Serghey Rodin 2012-07-31 15:09:21 +03:00
commit 06c7b42204
7 changed files with 364 additions and 17 deletions

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: change user package
# options: user package
# options: user package [force]
#
# The function changes user's hosting package.
@ -12,6 +12,7 @@
# Argument defenition
user=$1
package=$2
force=$3
# Includes
source $VESTA/conf/vesta.conf
@ -54,7 +55,8 @@ change_user_package() {
usr_data=$(cat $USER_DATA/user.conf)
eval $usr_data
pkg_data=$(cat $VESTA/data/packages/$package.pkg)
pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\
grep -v DATE)
eval $pkg_data
echo "FNAME='$FNAME'
@ -114,11 +116,13 @@ DATE='$DATE'" > $USER_DATA/user.conf
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user package'
check_args '2' "$#" 'user package [force]'
validate_format 'user' 'package'
is_object_valid 'user' 'USER' "$user"
is_package_valid
is_package_avalable
if [ "$force" != 'yes' ];then
is_package_avalable
fi
#----------------------------------------------------------#

47
bin/v_update_user_package Executable file
View file

@ -0,0 +1,47 @@
#!/bin/bash
# info: update user package
# options: pacakge
#
# The function propogates package to connected users.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
package=$1
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'package'
validate_format 'package'
is_package_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
for user in $(ls $VESTA/data/users); do
check_package=$(grep "PACKAGE='$package'" $USER_DATA/$user/user.conf)
if [ ! -z "$check_package" ]; then
$BIN/v_change_user_package $user $package 'yes'
fi
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$EVENT"
exit