refactoring: log_event(), is_format_valid()

This commit is contained in:
Serghey Rodin 2016-06-09 16:31:56 +03:00
commit e05dca61a6
211 changed files with 756 additions and 1091 deletions

View file

@ -25,7 +25,7 @@ is_user_free() {
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
echo "Error: user $user exists"
log_event "$E_EXISTS" "$EVENT"
log_event "$E_EXISTS" "$ARGUMENTS"
exit $E_EXISTS
fi
}
@ -36,9 +36,9 @@ is_user_free() {
#----------------------------------------------------------#
check_args '3' "$#" 'USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]'
validate_format 'user' 'email' 'package'
is_format_valid 'user' 'email' 'package'
if [ ! -z "$fname" ]; then
validate_format 'fname' 'lname'
is_format_valid 'fname' 'lname'
fi
is_user_free "$user"
is_password_valid
@ -50,7 +50,7 @@ is_package_valid
#----------------------------------------------------------#
# Parsing package data
pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |grep -v DATE)
pkg_data=$(cat $VESTA/data/packages/$package.pkg |egrep -v "TIME|DATE")
# Checking shell
shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \')
@ -134,6 +134,10 @@ if [ ! -z "$DB_SYSTEM" ]; then
echo "$BIN/v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe
fi
# Generating timestamp
time_n_date=$(date +'%T %F')
time=$(echo "$time_n_date" |cut -f 1 -d \ )
date=$(echo "$time_n_date" |cut -f 2 -d \ )
# Filling user config
if [ "$user" != 'admin' ]; then
@ -181,8 +185,8 @@ U_CRON_JOBS='0'
U_BACKUPS='0'
LANGUAGE=''
NOTIFICATIONS='no'
TIME='$TIME'
DATE='$DATE'" > $USER_DATA/user.conf
TIME='$time'
DATE='$date'" > $USER_DATA/user.conf
chmod 660 $USER_DATA/user.conf
# Updating quota
@ -207,6 +211,6 @@ fi
# Logging
log_history "added system user $user" '' 'admin'
log_event "$OK" "$EVENT"
log_event "$OK" "$ARGUMENTS"
exit