1
0
mirror of https://github.com/myvesta/vesta.git synced 2025-03-12 04:35:23 -07:00

Merge branch 'master' of github.com:serghey-rodin/vesta

This commit is contained in:
Malishev Dmitry 2011-12-19 11:22:31 +02:00
commit 8a91c6ecf9
53 changed files with 990 additions and 875 deletions

@ -62,7 +62,7 @@ iconf='/etc/sysconfig/network-scripts/ifcfg'
rconf='/etc/httpd/conf.d/rpaf.conf'
# Adding ip
ifconfig "$iface" "$ip" netmask "$mask"
/sbin/ifconfig "$iface" "$ip" netmask "$mask"
# Adding startup script
ip_add_startup

@ -18,6 +18,18 @@ source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
is_user_free() {
# Parsing domain values
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
# Checking result
if [ ! -z "$check_sysuser" ] || [ -e "$V_USERS/$user" ]; then
echo "Error: user $user exist"
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
#----------------------------------------------------------#
# Verifications #

@ -31,9 +31,6 @@ is_user_valid
# Checking user is active
is_user_suspended
# Checking reports existance
is_user_key_empty '$REPORTS'
#----------------------------------------------------------#
# Action #

@ -30,7 +30,6 @@ format_validation 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'web'
check_func_result $?
# Checking user
is_user_valid "$user"

@ -46,8 +46,8 @@ while [ "$la" -ge "$V_BACKUP_LA_LIMIT" ]; do
if [ "$i" -ge "15" ]; then
echo "Error: LA is too high"
log_event 'debug' "$E_LOAD_AVERAGE $V_EVENT"
exit $E_LOAD_AVERAGE
log_event 'debug' "$E_LA $V_EVENT"
exit $E_LA
fi
(( ++i))
@ -367,8 +367,8 @@ local_backup(){
disk_usage=$(df $V_BACKUP | awk '{print $5}'|tail -n1|cut -f 1 -d '%')
if [ "$disk_usage" -ge "$V_BACKUP_DISK_LIMIT" ]; then
echo "Error: Not enough disk space"
log_event 'debug' "$E_DISK_SPACE $V_EVENT"
exit $E_DISK_SPACE
log_event 'debug' "$E_DISK $V_EVENT"
exit $E_DISK
fi
# Creating final tarball
@ -402,8 +402,8 @@ ftp_backup(){
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
[ -z "$BPATH" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Debug info
@ -417,8 +417,8 @@ ftp_backup(){
rm $ftmpdir"
if [ ! -z "$(ftpc "$command")" ] ; then
echo "Error: FTP error"
log_event 'debug' "$E_FTP_ERROR $V_EVENT"
exit $E_FTP_ERROR
log_event 'debug' "$E_FTP $V_EVENT"
exit $E_FTP
fi
# Checking retention

@ -6,8 +6,9 @@
#----------------------------------------------------------#
# Argument defenition
user=$1
ip=$2
ip=$1
user=$2
# Importing variables
source $VESTA/conf/vars.conf
@ -21,10 +22,10 @@ source $V_FUNC/ip.func
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user ip'
check_args '2' "$#" 'ip user'
# Checking argument format
format_validation 'user' 'ip'
format_validation 'ip' 'user'
# Checking user
is_user_valid

@ -33,8 +33,8 @@ is_sys_ip_valid
current_status=$(get_sys_ip_value '$STATUS')
if [ "$ip_status" = "$current_status" ]; then
echo "Error: status is already set"
log_event 'debug' "$E_VALUE_EXIST $V_EVENT"
exit $E_VALUE_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
# Parsing current ip usage
@ -45,8 +45,8 @@ ip_owner=$(get_sys_ip_value '$OWNER')
# Checking condition
if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
echo "Error: ip is used"
log_event 'debug' "$E_IP_USED $V_EVENT"
exit $E_IP_USED
log_event 'debug' "$E_INUSE $V_EVENT"
exit $E_INUSE
fi

@ -14,6 +14,89 @@ source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
is_package_avalable() {
# Parsing user data
usr_data=$(cat $V_USERS/$user/user.conf)
for key in $usr_data; do
eval ${key%%=*}=${key#*=}
done
# Clearing vars
WEB_DOMAINS='0'
WEB_SSL='0'
DATABASES='0'
MAIL_DOMAINS='0'
MAIL_BOXES='0'
MAIL_FORWARDERS='0'
DNS_DOMAINS='0'
DISK_QUOTA='0'
BANDWIDTH='0'
# Parsing package
pkg_data=$(cat $V_PKG/$package.pkg)
for key in $pkg_data; do
eval ${key%%=*}=${key#*=}
done
# Comparing user data with package
if [ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ] ||\
[ "$WEB_SSL" -lt "$U_WEB_SSL" ] ||\
[ "$DATABASES" -lt "$U_DATABASES" ] ||\
[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ] ||\
[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ] ||\
[ "$DISK_QUOTA" -lt "$U_DISK" ] ||\
[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]; then
echo "Error: Upgrade package"
log_event 'debug' "$E_LIMIT $v_log"
exit $E_LIMIT
fi
}
change_user_package() {
# Parsing user data
usr_data=$(cat $V_USERS/$user/user.conf)
for key in $usr_data; do
eval ${key%%=*}=${key#*=}
done
# Parsing package
pkg_data=$(cat $V_PKG/$package.pkg)
for key in $pkg_data; do
eval ${key%%=*}=${key#*=}
done
echo "FNAME='$FNAME'
LNAME='$LNAME'
PACKAGE='$package'
WEB_DOMAINS='$WEB_DOMAINS'
WEB_SSL='$WEB_SSL'
WEB_ALIASES='$WEB_ALIASES'
DATABASES='$DATABASES'
MAIL_DOMAINS='$MAIL_DOMAINS'
MAIL_BOXES='$MAIL_BOXES'
MAIL_FORWARDERS='$MAIL_FORWARDERS'
DNS_DOMAINS='$DNS_DOMAINS'
DISK_QUOTA='$DISK_QUOTA'
BANDWIDTH='$BANDWIDTH'
NS='$NS'
SHELL='$SHELL'
BACKUPS='$BACKUPS'
WEB_TPL='$WEB_TPL'
SUSPENDED='$SUSPENDED'
CONTACT='$CONTACT'
REPORTS='$REPORTS'
IP_OWNED='$IP_OWNED'
U_DIR_DISK='$U_DIR_DISK'
U_DISK='$U_DISK'
U_BANDWIDTH='$U_BANDWIDTH'
U_WEB_DOMAINS='$U_WEB_DOMAINS'
U_WEB_SSL='$U_WEB_SSL'
U_DNS_DOMAINS='$U_DNS_DOMAINS'
U_DATABASES='$U_DATABASES'
U_MAIL_DOMAINS='$U_MAIL_DOMAINS'
DATE='$DATE'" > $V_USERS/$user/user.conf
}
#----------------------------------------------------------#
# Verifications #

@ -40,7 +40,7 @@ is_user_suspended
update_user_value "$user" '$SHELL' "$shell"
# Get shell full path
shell_path=$(get_shell_path)
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
# Changing passwd file
/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1

Binary file not shown.

@ -56,7 +56,7 @@ rconf='/etc/httpd/conf.d/rpaf.conf'
user="$(get_sys_ip_value '$OWNER')"
# Deleting interface
ifconfig "$interface" down
/sbin/ifconfig "$interface" down
# Deleting startup script
rm -f $iconf-$interface

67
bin/v_del_sys_user_ips Executable file

@ -0,0 +1,67 @@
#!/bin/bash
# info: deliting system user ips
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/ip.func
#----------------------------------------------------------#
# 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
# Checking user vesta
if [ "$user" = 'vesta' ]; then
exit
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Parsing user ips
ip_list=$(grep -H "OWNER='$user'" $V_IPS/* | cut -f 1 -d:)
for ip in $ip_list; do
ip=$(basename $ip)
# Checking webdomains and users
is_ip_key_empty '$U_WEB_DOMAINS'
is_ip_key_empty '$U_SYS_USERS'
# Assig ip to main account
update_sys_ip_value '$OWNER' 'vesta'
update_sys_ip_value '$STATUS' 'exclusive'
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit

@ -31,9 +31,6 @@ is_user_valid
# Checking user is active
is_user_suspended
# Checking reports existance
is_user_value_exist '$REPORTS'
#----------------------------------------------------------#
# Action #

@ -49,8 +49,8 @@ get_web_domain_values
check_alias=$(echo ${ALIAS//,/ }|grep -w "$dom_alias")
if [ -z "$check_alias" ]; then
echo "Error: alias not exist"
log_event 'debug' "$E_DOM_NOTEXIST $V_EVENT"
exit $E_DOM_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
#----------------------------------------------------------#

@ -29,9 +29,7 @@ json_list_db() {
echo '{'
# Parsing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Starting output loop
for field in $fields; do
@ -70,9 +68,7 @@ shell_list_db() {
line=$(grep "DB='$database'" $conf)
# Parsing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result line
for field in $fields; do

@ -30,9 +30,7 @@ json_list_dbhost() {
echo '{'
# Assign key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Starting output loop
for field in $fields; do
@ -68,9 +66,7 @@ shell_list_dbhost() {
line=$(grep "HOST='$host'" $conf)
# Parsing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result line
for field in $fields; do

@ -29,9 +29,7 @@ json_list_dns() {
IFS=$'\n'
# Assing key=value pair
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -86,9 +84,7 @@ shell_list_dns() {
# New delimeter
IFS=$'\n'
# Assing key=value pair
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result
eval echo "$fields" | sed -e "s/%quote%/'/g"

@ -42,9 +42,7 @@ json_list_dns() {
IFS=$'\n'
# Assing key=value pair
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -96,12 +94,8 @@ shell_list_dns() {
# Reading file line by line
while read line ; do
# New delimeter
IFS=$'\n'
# Assing key=value pair
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result
eval echo "$fields" | sed -e "s/%quote%/'/g"

@ -27,9 +27,7 @@ json_list_cron() {
IFS=$'\n'
# Assing key=value pair
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -81,12 +79,8 @@ shell_list_cron() {
# Reading file line by line
while read line ; do
# New delimeter
IFS=$'\n'
# Assing key=value pair
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result
eval echo "$fields" | sed -e "s/%quote%/'/g"

@ -25,9 +25,7 @@ json_list_ip() {
echo '{'
# Assign key=value
for key in $ip_data; do
eval ${key%%=*}=${key#*=}
done
eval $ip_data
for field in $fields; do
eval value=$field
@ -59,9 +57,7 @@ shell_list_ip() {
line=$(cat $V_IPS/$IP)
# Assing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result line
for field in $fields; do

@ -26,9 +26,7 @@ json_list_ips() {
for IP in $ip_list; do
# Assing key=value
ip_data=$(cat $V_IPS/$IP)
for key in $ip_data; do
eval ${key%%=*}=${key#*=}
done
eval $ip_data
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -83,9 +81,7 @@ shell_list_ips() {
ip_data=$(cat $V_IPS/$IP)
# Assign key/value config
for key in $ip_data; do
eval ${key%%=*}=${key#*=}
done
eval $ip_data
# Print result line
eval echo "$fields"

@ -24,9 +24,7 @@ json_list_user() {
echo '{'
# Assing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Starting output loop
for field in $fields; do
@ -60,9 +58,7 @@ shell_list_user() {
line=$(cat $V_USERS/$USER/user.conf)
# Parsing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result line
for field in $fields; do

@ -32,9 +32,7 @@ json_list_user_ips() {
ip_data=$(cat $V_IPS/$IP)
# Assing key=value
for key in $ip_data; do
eval ${key%%=*}=${key#*=}
done
eval $ip_data
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -93,9 +91,7 @@ shell_list_user_ips() {
ip_data=$(cat $V_IPS/$IP)
# Assign key/value config
for key in $ip_data; do
eval ${key%%=*}=${key#*=}
done
eval $ip_data
# Print result line
eval echo "$fields"

@ -24,9 +24,7 @@ json_list_pkgs() {
PACKAGE=${package/.pkg/}
# Assing key=value
pkg_data=$(cat $V_DATA/packages/$package)
for key in $pkg_data; do
eval ${key%%=*}=${key#*=}
done
eval $pkg_data
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -69,9 +67,7 @@ shell_list_pkgs() {
PACKAGE=${package/.pkg/}
# Assign key=value
pkg_descr=$(cat $V_DATA/packages/$package)
for key in $pkg_descr; do
eval ${key%%=*}=${key#*=}
done
eval $pkg_descr
if [ -z "$nohead" ]; then

@ -23,9 +23,7 @@ json_list_users() {
user_data=$(cat $V_USERS/$USER/user.conf)
# Assign key/value config
for key in $user_data; do
eval ${key%%=*}=${key#*=}
done
eval $user_data
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -76,9 +74,7 @@ shell_list_users() {
user_data=$(cat $V_USERS/$USER/user.conf)
# Assign key/value config
for key in $user_data; do
eval ${key%%=*}=${key#*=}
done
eval $user_data
eval echo "$fields"
done

@ -25,9 +25,7 @@ json_list_domain() {
echo '{'
# Assing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Starting output loop
for field in $fields; do
@ -61,9 +59,7 @@ shell_list_domain() {
line=$(grep "DOMAIN='$domain'" $conf)
# Parsing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result line
for field in $fields; do

85
bin/v_suspend_sys_user Executable file

@ -0,0 +1,85 @@
#!/bin/bash
# info: Suspending sys user
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
# Checking user status
is_user_suspended
# Checking user vesta
if [ "$user" = 'vesta' ]; then
exit
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Adding '!' in front of the password
/usr/sbin/usermod --lock $user
# Suspending web domains
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
$V_BIN/v_suspend_web_domains $user
fi
# Suspending dns domains
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
$V_BIN/v_suspend_dns_domains $user
fi
# Suspending mail domains
# TBD
# Suspending datbabases
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
$V_BIN/v_suspend_db_bases $user
fi
# Suspending cron jobs
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
$V_BIN/v_suspend_sys_cron_jobs $user
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'cron'
restart_schedule 'web'
restart_schedule 'dns'
# Changing suspend value
update_user_value "$user" '$SUSPENDED' 'yes'
# Logging
log_event 'system' "$V_EVENT"
exit

82
bin/v_unsuspend_sys_user Executable file

@ -0,0 +1,82 @@
#!/bin/bash
# info: Unsuspending sys user
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
# Checking user vesta
if [ "$user" = 'vesta' ]; then
exit
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Deleting '!' in front of the password
/usr/sbin/usermod --unlock $user
# Unsuspending web domains
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_web_domains $user
fi
# Unsuspending dns domains
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_dns_domains $user
fi
# Unsuspending mail domains
# TBD
# Unsuspending datbabases
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_db_bases $user
fi
# Unsuspending cron jobs
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_sys_cron_jobs $user
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'cron'
restart_schedule 'web'
restart_schedule 'dns'
# Changing suspend value
update_user_value "$user" '$SUSPENDED' 'no'
# Logging
log_event 'system' "$V_EVENT"
exit

@ -19,29 +19,32 @@ source $V_FUNC/shared.func
PATH="$PATH:$V_BIN"
export PATH
# Argument defenition
period=$1
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Updateing system stats
$V_BIN/v_upd_sys_rrd_la
$V_BIN/v_upd_sys_rrd_net
$V_BIN/v_upd_sys_rrd_mem
$V_BIN/v_upd_sys_rrd_ssh
$V_BIN/v_upd_sys_rrd_la $period
$V_BIN/v_upd_sys_rrd_net $period
$V_BIN/v_upd_sys_rrd_mem $period
$V_BIN/v_upd_sys_rrd_ssh $period
# Updating web stats
if [ "$WEB_SYSTEM" = 'apache' ]; then
$V_BIN/v_upd_sys_rrd_httpd
$V_BIN/v_upd_sys_rrd_httpd $period
fi
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
$V_BIN/v_upd_sys_rrd_nginx
$V_BIN/v_upd_sys_rrd_nginx $period
fi
# Updating ftp stats
if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then
$V_BIN/v_upd_sys_rrd_ftp
$V_BIN/v_upd_sys_rrd_ftp $period
fi
# Updating db stats
@ -49,8 +52,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
for type in ${DB_SYSTEM//,/ }; do
# Switching on db type
case $type in
mysql) $V_BIN/v_upd_sys_rrd_mysql ;;
pgsql) $V_BIN/v_upd_sys_rrd_pgsql ;;
mysql) $V_BIN/v_upd_sys_rrd_mysql $period ;;
pgsql) $V_BIN/v_upd_sys_rrd_pgsql $period ;;
esac
done
fi

@ -6,9 +6,8 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
@ -19,6 +18,15 @@ source $V_CONF/vesta.conf
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/ftp" ]; then
mkdir $V_RRD/ftp
@ -40,7 +48,7 @@ if [ ! -e "$V_RRD/ftp/ftp.rrd" ]; then
fi
# Parsing data
if [ -z "$1" ]; then
if [ -z "$update" ]; then
a=0
a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\
grep -v root|wc -l)
@ -50,15 +58,15 @@ if [ -z "$1" ]; then
fi
# Updating rrd graph
rrdtool graph $V_RRD/ftp/ftp.png \
rrdtool graph $V_RRD/ftp/$period-ftp.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage" \
--start "$start" \
--end "$end" \
--title "$(echo $FTP_SYSTEM|tr '[a-z]' '[A-Z]') Usage ($period)" \
--vertical-label "Connections" \
--x-grid "$rrd_grid" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -81,7 +89,7 @@ rrdtool graph $V_RRD/ftp/ftp.png \
#----------------------------------------------------------#
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
exit

@ -6,21 +6,27 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/web" ]; then
mkdir $V_RRD/web
@ -42,9 +48,8 @@ if [ ! -e "$V_RRD/web/httpd.rrd" ]; then
fi
# Parsing data
if [ -z "$1" ]; then
web_port=$(get_config_value '$WEB_PORT')
server_status=$(wget -qO- http://localhost:$web_port/server-status |\
if [ -z "$update" ]; then
server_status=$(wget -qO- http://localhost:$WEB_PORT/server-status |\
grep 'currently being processed'| \
cut -f 2 -d '>' |\
sed 's/requests currently being processed, //' | \
@ -58,15 +63,15 @@ if [ -z "$1" ]; then
fi
# Updating rrd graph
rrdtool graph $V_RRD/web/httpd.png \
rrdtool graph $V_RRD/web/$period-httpd.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--title "HTTPD Usage" \
--start "$start" \
--end "$end" \
--title "HTTPD Usage ($period)" \
--vertical-label "Connections" \
--x-grid "$rrd_grid" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -89,7 +94,7 @@ rrdtool graph $V_RRD/web/httpd.png \
#----------------------------------------------------------#
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
exit

@ -6,19 +6,26 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/la" ]; then
mkdir $V_RRD/la
@ -41,7 +48,7 @@ if [ ! -e "$V_RRD/la/la.rrd" ]; then
fi
# Parsing data
if [ -z "$1" ]; then
if [ -z "$update" ]; then
loadavg=$(cat /proc/loadavg )
la=$(echo "$loadavg"|cut -f 2 -d ' ')
pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /)
@ -51,15 +58,15 @@ if [ -z "$1" ]; then
fi
# Updating graph
rrdtool graph $V_RRD/la/la.png \
rrdtool graph $V_RRD/la/$period-la.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--title "Load Average" \
--start "$start" \
--end "$end" \
--title "Load Average ($period)" \
--vertical-label "Points" \
--x-grid "$rrd_grid" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -87,7 +94,7 @@ rrdtool graph $V_RRD/la/la.png \
#----------------------------------------------------------#
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
exit

@ -6,19 +6,26 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/mem" ]; then
mkdir $V_RRD/mem
@ -41,7 +48,7 @@ if [ ! -e "$V_RRD/mem/mem.rrd" ]; then
fi
# Parsing data
if [ -z "$1" ]; then
if [ -z "$update" ]; then
mem=$(free -m)
ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1)
swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
@ -51,15 +58,15 @@ if [ -z "$1" ]; then
fi
# Updating rrd graph
rrdtool graph $V_RRD/mem/mem.png \
rrdtool graph $V_RRD/mem/$period-mem.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--title "Memory Usage" \
--start "$start" \
--end "$end" \
--title "Memory Usage ($period)" \
--vertical-label "Mbytes" \
--x-grid "$rrd_grid" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -87,7 +94,7 @@ rrdtool graph $V_RRD/mem/mem.png \
#----------------------------------------------------------#
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
exit

@ -6,21 +6,27 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/db" ]; then
mkdir $V_RRD/db
@ -58,7 +64,7 @@ for host in $hosts; do
RRA:MAX:0.5:288:797
fi
if [ -z "$1" ]; then
if [ -z "$update" ]; then
# Defining host credentials
host_str=$(grep "HOST='$host'" $conf)
for key in $host_str; do
@ -70,8 +76,8 @@ for host in $hosts; do
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]
then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Parsing data
@ -89,15 +95,15 @@ for host in $hosts; do
fi
# Updating daily graph
rrdtool graph $V_RRD/db/mysql_$host.png \
rrdtool graph $V_RRD/db/$period-mysql_$host.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--title "MySQL Usage on $host" \
--start "$start" \
--end "$end" \
--title "MySQL Usage on $host ($period)" \
--vertical-label "Queries" \
--x-grid "$rrd_grid" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -120,7 +126,7 @@ for host in $hosts; do
GPRINT:s:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
done

@ -6,19 +6,26 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/net" ]; then
mkdir $V_RRD/net
@ -50,7 +57,7 @@ for iface in $ifaces; do
fi
# Parsing device stats
if [ -z "$1" ]; then
if [ -z "$update" ]; then
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
rx=$(echo "$raw_iface" |awk '{print $2}')
tx=$(echo "$raw_iface" |awk '{print $10}')
@ -60,15 +67,15 @@ for iface in $ifaces; do
fi
# Updating rrd graph
rrdtool graph $V_RRD/net/$iface.png \
rrdtool graph $V_RRD/net/$period-$iface.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--title "Bandwidth Usage $iface" \
--start "$start" \
--end "$end" \
--title "Bandwidth Usage $iface ($period)" \
--vertical-label "KBytes" \
--x-grid "$rrd_grid" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -93,7 +100,7 @@ for iface in $ifaces; do
GPRINT:out:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
done

@ -6,19 +6,26 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/web" ]; then
mkdir $V_RRD/web
@ -40,7 +47,7 @@ if [ ! -e "$V_RRD/web/nginx.rrd" ]; then
fi
# Parsing data
if [ -z "$1" ]; then
if [ -z "$update" ]; then
a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ')
# Updating rrd database
@ -48,15 +55,15 @@ if [ -z "$1" ]; then
fi
# Updating rrd graph
rrdtool graph $V_RRD/web/nginx.png \
rrdtool graph $V_RRD/web/$period-nginx.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--title "NGINX Usage" \
--start "$start" \
--end "$end" \
--title "NGINX Usage ($period)" \
--vertical-label "Connections" \
--x-grid "$rrd_grid" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -79,7 +86,7 @@ rrdtool graph $V_RRD/web/nginx.png \
#----------------------------------------------------------#
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
exit

@ -6,21 +6,27 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/db" ]; then
mkdir $V_RRD/db
@ -58,7 +64,7 @@ for host in $hosts; do
RRA:MAX:0.5:288:797
fi
if [ -z "$1" ]; then
if [ -z "$update" ]; then
# Defining host credentials
host_str=$(grep "HOST='$host'" $conf)
for key in $host_str; do
@ -72,8 +78,8 @@ for host in $hosts; do
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]
then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
@ -95,15 +101,15 @@ for host in $hosts; do
fi
# Updating rrd graph
rrdtool graph $V_RRD/db/pgsql_$host.png \
rrdtool graph $V_RRD/db/$period-pgsql_$host.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--title "PostgreSQL Usage on $host" \
--start "$start" \
--end "$end" \
--title "PostgreSQL Usage on $host ($period)" \
--vertical-label "Queries" \
--x-grid "$rrd_grid" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -126,7 +132,7 @@ for host in $hosts; do
GPRINT:t:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$?
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
done

@ -6,19 +6,26 @@
#----------------------------------------------------------#
# Argument defenition
rrd_start=${1--1d}
rrd_end=${2-now}
rrd_grid=${3-MINUTE:30:HOUR:1:HOUR:4:0:%H:%M}
update=$1
period=${1-daily}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Switching on time period
case $period in
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
*) exit $E_RRD ;;
esac
# Checking directory
if [ ! -d "$V_RRD/ssh" ]; then
mkdir $V_RRD/ssh
@ -40,7 +47,7 @@ if [ ! -e "$V_RRD/ssh/ssh.rrd" ]; then
fi
# Parsing data
if [ -z "$1" ]; then
if [ -z "$update" ]; then
a=0
a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l)
@ -49,15 +56,15 @@ if [ -z "$1" ]; then
fi
# Updating daily graph
rrdtool graph $V_RRD/ssh/ssh.png \
rrdtool graph $V_RRD/ssh/$period-ssh.png \
--imgformat PNG \
--height="120" \
--width="440" \
--start "$rrd_start" \
--end "$rrd_end" \
--start "$start" \
--end "$end" \
--title "SSH Usage" \
--vertical-label "Connections" \
--x-grid "$rrd_grid" \
--vertical-label "Connections ($period)" \
--x-grid "$grid" \
-c "BACK#484439" \
-c "SHADEA#484439" \
-c "SHADEB#484439" \
@ -80,7 +87,7 @@ rrdtool graph $V_RRD/ssh/ssh.png \
#----------------------------------------------------------#
if [ "$result" -ne 0 ]; then
exit $E_RRD_FAILED
exit $E_RRD
fi
exit

@ -158,8 +158,8 @@ init_ftp_variables() {
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
[ -z "$BPATH" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
}
@ -171,8 +171,8 @@ check_ftp_connection(){
rm $ftmpdir"
if [ ! -z "$(ftpc "$command")" ] ; then
echo "Error: FTP error"
log_event 'debug' "$E_FTP_ERROR $V_EVENT"
exit $E_FTP_ERROR
log_event 'debug' "$E_FTP $V_EVENT"
exit $E_FTP
fi
}
@ -197,8 +197,8 @@ is_user_valid
# Checking load averages
la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.')
if [ "$la" -ge "$V_BACKUP_LA_LIMIT" ]; then
log_event 'debug' "$E_LOAD_AVERAGE $V_EVENT"
exit $E_LOAD_AVERAGE
log_event 'debug' "$E_LA $V_EVENT"
exit $E_LA
fi
@ -232,8 +232,8 @@ if [ "$type" = 'ftp' ]; then
cd $tmpdir
if [ ! -z "$(ftpc "get $backup")" ]; then
echo "Error: FTP transfer error"
log_event 'debug' "$E_FTP_ERROR $V_EVENT"
exit $E_FTP_ERROR
log_event 'debug' "$E_FTP $V_EVENT"
exit $E_FTP
fi
get_backup_info $tmpdir/$backup $type >> $tmp_file
rm -f $tmpdir/$backup
@ -259,8 +259,8 @@ if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then
cd $tmpdir
if [ ! -z "$(ftpc "get $backup")" ]; then
echo "Error: FTP transfer error"
log_event 'debug' "$E_FTP_ERROR $V_EVENT"
exit $E_FTP_ERROR
log_event 'debug' "$E_FTP $V_EVENT"
exit $E_FTP
fi
get_backup_info $tmpdir/$backup ftp >> $tmp_file
rm -f $tmpdir/$backup

@ -43,8 +43,8 @@ if [ "$version" != "$VERSION" ]; then
# Checking download result
if [ "$?" -ne "0" ]; then
echo "Error: version tree update failed"
log_event 'debug' "$E_UPD_FAILED $V_EVENT"
exit $E_UPD_FAILED
log_event 'debug' "$E_UPDATE $V_EVENT"
exit $E_UPDATE
fi
# Deviding version
@ -89,8 +89,8 @@ if [ "$version" != "$VERSION" ]; then
# Checking download result
if [ "$?" -ne "0" ]; then
echo "Error: version tree update failed"
log_event 'debug' "$E_UPD_FAILED $V_EVENT"
exit $E_UPD_FAILED
log_event 'debug' "$E_UPDATE $V_EVENT"
exit $E_UPDATE
fi
bash $V_BIN/updates/$update.sh
done

@ -53,8 +53,8 @@ stats=$(get_web_domain_value '$STATS')
config="$V_HOME/$user/conf/$stats.$domain.conf"
if [ ! -e "$config" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking statistics directory

@ -1,145 +1,54 @@
#############################################################
# #
# This file contains vesta global variable defenitions #
# #
#############################################################
# Paths
VESTA='/usr/local/vesta'
V_BIN="$VESTA/bin"
V_FUNC="$VESTA/func"
V_CONF="$VESTA/conf"
V_DATA="$VESTA/data"
V_LOG="$VESTA/log"
V_SRC="$VESTA/src"
V_PKG="$V_DATA/packages"
V_USERS="$V_DATA/users"
V_DB="$VESTA/conf"
V_QUEUE="$V_DATA/queue"
V_IPS="$V_DATA/ips"
V_WEBTPL="$V_DATA/templates"
V_DNSTPL="$V_WEBTPL/dns"
VESTA=/usr/local/vesta
V_BIN=$VESTA/bin
V_FUNC=$VESTA/func
V_CONF=$VESTA/conf
V_DATA=$VESTA/data
V_LOG=$VESTA/log
V_SRC=$VESTA/src
V_PKG=$V_DATA/packages
V_USERS=$V_DATA/users
V_DB=$V_CONF
V_QUEUE=$V_DATA/queue
V_IPS=$V_DATA/ips
V_WEBTPL=$V_DATA/templates
V_DNSTPL=$V_WEBTPL/dns
V_LOCK=/var/lock/vesta
V_HOME='/home'
V_TMP='/tmp'
V_BACKUP='/backup'
V_HOME=/home
V_TMP=/tmp
V_BACKUP=/backup
V_WEB=$VESTA/web
V_RRD=$V_WEB/rrd
# Other vars
V_BACKUP_GZIP='5'
V_SUSPEND_URL='vestacp.com/faq/acc_suspended/'
V_BACKUP_GZIP=5
V_BACKUP_DISK_LIMIT=95
V_BACKUP_LA_LIMIT=5
V_SUSPEND_URL=vestacp.com/error/suspend/
V_SCRIPT=$(basename $0)
V_EVENT="$(date +%m-%d-%y" "%H:%m:%S) $V_SCRIPT $*"
V_DATE=$(date +%m-%d-%y)
V_EVENT="$(date '+%F %T') $V_SCRIPT $*"
V_DATE=$(date +%F)
V_UPD_HOST=yum.vestacp.com
V_RRD_STEP=300
V_RRD_IFACE_EXCLUDE=lo
# Return codes
OK=0
ERROR=1
E_BAD_CMD=2
E_BAD_ARGS=3
E_BAD_STATUS=4
E_BAD_TYPE=5
E_BAD_FORMAT=6
E_PARSE_ERROR=7
E_STR_NOTFOUND=8
E_OUTOFRANGE=9
E_WEB_ENABLED=10
E_WEB_DISABLED=11
E_MAIL_ENABLED=12
E_MAIL_DISABLED=13
E_DNS_ENABLED=14
E_DNS_DISABLED=15
E_DB_ENABLED=16
E_DB_DISABLED=17
E_IM_ENABLED=18
E_IM_DISABLED=19
E_USER_EXIST=20
E_USER_NOTEXIST=21
E_USER_BADSTATUS=22
E_USER_SUSPENDED=23
E_USER_UNSUSPENDED=24
E_USER_UNKNOWN=25
E_DOM_EXIST=30
E_DOM_NOTEXIST=31
E_DOM_ADDED=32
E_DOM_NOTADDED=33
E_DOM_SUSPENDED=34
E_DOM_UNSUSPENDED=35
E_DOM_OWNED=36
E_DOM_NOTOWNED=37
E_DOM_ISALIAS=38
E_DOM_NOTALIAS=39
E_IP_EXIST=40
E_IP_NOTEXIST=41
E_IP_USED=42
E_IP_UNUSED=33
E_IP_OWNED=34
E_IP_NOTOWNED=35
E_QUOTA_ENABLED=1
E_QUOTA_DISABLED=6
E_LOG_EXIST=36
E_LOG_NOTEXIST=37
E_LOG_ENABLED=38
E_LOG_DISABLED=39
E_PKG_EXIST=7
E_PKG_NOTEXIST=7
E_PKG_UPGRADE=20
E_PASSWORD_SHORT=23
E_PASSWORD_WRONG=24
E_FWD_EXISTS=25
E_FWD_NOTFOUND=29
E_CONF_EXISTS=30
E_CONF_NOTEXIST=31
E_PID_EXIST=32
E_PID_NOTEXIST=32
E_FILE_BROKEN=33
E_LIMIT_NOTFOUND=34
E_BACKUP_ENABLED=40
E_BACKUP_DISABLED=41
E_LOCK_EXIST=42
E_DIR_NOTEXIST=43
E_DIR_EXIST=44
E_EMAIL_INVALID=45
E_HOST_NOTFOUND=47
E_HOST_EXIST=48
E_HOST_USED=53
E_CONN_FAILED=49
E_PERMS_REQUEIURED=50
E_TPL_EXIST=51
E_TPL_NOTEXIST=52
E_AUTH_ENABLED=55
E_AUTH_DISABLED=56
E_STATS_ENABLED=57
E_STATS_DISABLED=58
E_CERT_EXIST=59
E_CERT_NOTEXIST=60
E_CERT_INVALID=61
E_KEY_INVALID=62
E_CERTKEY_INVALID=63
E_CERT_USED=64
E_VALUE_EMPTY=65
E_VALUE_EXIST=66
E_ALIAS_NOTEXIST=67
E_ALIAS_EXIST=68
E_SHELL_INVALID=69
E_INTERFACE_NOTEXIST=70
E_IP_FIRST=71
E_JOB_NOTEXIST=72
E_JOB_EXIST=73
E_ID_NOTEXIST=74
E_ID_EXIST=75
E_DB_NOTEXIST=76
E_DB_EXIST=77
E_DBHOST_NOTEXIST=78
E_DBHOST_EXIST=79
E_DBHOST_UNAVAILABLE=80
E_JOB_SUSPENDED=81
E_JOB_UNSUSPENDED=82
E_DB_SUSPENDED=83
E_DB_UNSUSPENDED=84
E_DBUSER_NOTEXIST=85
E_DBUSER_EXIST=86
E_DBHOST_BUSY=87
E_DBHOST_FREE=88
E_UPD_FAILED=89
E_PROXY_DISABLED='90'
E_ARGS=1
E_INVALID=2
E_NOTEXIST=3
E_EXISTS=4
E_SUSPENDED=5
E_UNSUSPENDED=6
E_INUSE=7
E_LIMIT=8
E_PASSWORD=9
E_FORBIDEN=10
E_DISABLED=11
E_PARSING=12
E_DISK=13
E_LA=14
E_FTP=15
E_SSH=16
E_DB=17
E_RRD=18
E_UPDATE=19

@ -1,17 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>403 &mdash; Forbidden</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="You do not have permission to view this" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="description" content="You do not have permission to view this"/>
<style type="text/css">
body {font-size:14px; color:#777777; font-family:arial; text-align:center;}
h1 {font-size:180px; color:#333333; margin: 70px 0 0 0;}
h2 {color: #ED6C42; font-family: georgia; font-size: 20px; font-style: italic; font-weight: bold; letter-spacing: -1px; margin: -3px 0 39px;}
p {width:320px; text-align:center; margin-left:auto;margin-right:auto; margin-top: 30px }
div {width:320px; text-align:center; margin-left:auto;margin-right:auto;}
a:link {color: #28A0CB;}
a:visited {color: #28A0CB;}
a:active {color: #BCBA30;}
a:hover {color: #BCBA30;}
</style>
</head>
<body>
<div style="width:600px; margin-left: auto; margin-right: auto; text-align: center; font-family: Georgia;}">
<br />
<a style="font-size: 12pt; color: #333333;" href="http://%domain%">http://%domain%</a>
<p style="font-size: 48pt; color: #485357;">Forbidden<br> 403</p>
<p style="font-size: 14pt; color: gray;">Unfortunately, you do not have permission to view this.</p>
<p><a href="http://%domain%/">%domain%</a></p>
<h1>403</h1>
<h2>Forbidden</h2>
<div>
Unfortunately, you do not have permission to view this
</div>
</body>

@ -1,18 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>404 &mdash; Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Sorry, page not found" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Sorry, page not found"/>
<style type="text/css">
body {font-size:14px; color:#777777; font-family:arial; text-align:center;}
h1 {font-size:180px; color:#333333; margin: 70px 0 0 0;}
h2 {color: #ED6C42; font-family: georgia; font-size: 20px; font-style: italic; font-weight: bold; letter-spacing: -1px; margin: -3px 0 39px;}
p {width:320px; text-align:center; margin-left:auto;margin-right:auto; margin-top: 30px }
div {width:320px; text-align:center; margin-left:auto;margin-right:auto;}
a:link {color: #28A0CB;}
a:visited {color: #28A0CB;}
a:active {color: #BCBA30;}
a:hover {color: #BCBA30;}
</style>
</head>
<body>
<div style="width:600px; margin-left: auto; margin-right: auto; text-align: center; font-family: Georgia;}">
<br />
<a style="font-size: 12pt; color: #333333;" href="http://%domain%">http://%domain%</a>
<p style="font-size: 48pt; color: #485357;">Page Not Found <br> 404</p>
<p style="font-size: 14pt; color: gray;">It seems that the page you were trying to reach does not exist anymore, or maybe it has just moved. You can start again from the <a style="color: gray;" href="/">home</a> or go back to <a style="color: gray;" href="javascript: history.go(-1)">previous page</a>.</p>
<p><a href="http://%domain%/">%domain%</a></p>
<h1>404</h1>
<h2>Page Not Found</h2>
<div>
It seems that the page you were trying to reach does not exist anymore, or maybe it has just moved.
You can start again from the <a href="http://%domain%/">home</a> or go back to <a href="javascript:%20history.go(-1)">previous page</a>.
</div>
</body>
</html>

@ -1,17 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>500 &mdash; Internal Sever Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Sorry, something went wrong. Internal Server Error" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Sorry, something went wrong. Internal Server Error"/>
<style type="text/css">
body {font-size:14px; color:#777777; font-family:arial; text-align:center;}
h1 {font-size:180px; color:#333333; margin: 70px 0 0 0;}
h2 {color: #ED6C42; font-family: georgia; font-size: 20px; font-style: italic; font-weight: bold; letter-spacing: -1px; margin: -3px 0 39px;}
p {width:320px; text-align:center; margin-left:auto;margin-right:auto; margin-top: 30px }
div {width:320px; text-align:center; margin-left:auto;margin-right:auto;}
a:link {color: #28A0CB;}
a:visited {color: #28A0CB;}
a:active {color: #BCBA30;}
a:hover {color: #BCBA30;}
</style>
</head>
<body>
<div style="width:600px; margin-left: auto; margin-right: auto; text-align: center; font-family: Georgia;}">
<br />
<a style="font-size: 12pt; color: #333333;" href="http://%domain%">http://%domain%</a>
<p style="font-size: 48pt; color: #485357;">Internal Sever Error <br> 500</p>
<p style="font-size: 14pt; color: gray;"> Sorry, something went wrong :( </p>
<p><a href="http://%domain%/">%domain%</a></p>
<h1>500</h1>
<h2>Internal Sever Error</h2>
<div>
Sorry, something went wrong :(
</div>
</body>

@ -1,21 +1,29 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>%domain% &mdash; coming soon </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Vesta Control Panel. This is a default index page for a new domain." />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>%domain% &mdash; Coming Soon</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="description" content="This is a default index page for a new domain."/>
<style type="text/css">
body {font-size:14px; color:#777777; font-family:arial; text-align:center;}
h1 {font-size:64px; color:#333333; margin: 70px 0 50px 0;}
p {width:320px; text-align:center; margin-left:auto;margin-right:auto; margin-top: 30px }
div {width:320px; text-align:center; margin-left:auto;margin-right:auto;}
a:link {color: #28A0CB;}
a:visited {color: #28A0CB;}
a:active {color: #BCBA30;}
a:hover {color: #BCBA30;}
</style>
</head>
<body>
<div style="width:600px; margin-left: auto; margin-right: auto; text-align: center; font-family: Georgia;}">
<p style="font-size: 48pt; color: #485357;">%domain%</p>
<p style="font-size: 14pt; color: gray;">
<a style="color: gray;" href="http://httpd.apache.org/">apache</a> +
<a style="color: gray;" href="http://nginx.net/">nginx</a> +
<a style="color: gray;" href="http://www.percona.com/">percona</a> +
<a style="color: gray;" href="http://vestacp.com/">vesta</a>
</p>
<h1>%domain%</h1>
<div>
<a href="http://httpd.apache.org/">apache</a> +
<a href="http://nginx.com/">nginx</a> +
<a href="http://www.percona.com/">percona</a> +
<a href="http://vestacp.com/">vesta</a>
</div>
</body>
</html>

@ -1,21 +1,29 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>%domain% &mdash; coming soon </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Vesta Control Panel. This is a default index page for a new domain." />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>%domain% &mdash; Coming Soon</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="description" content="This is a default index page for a new domain."/>
<style type="text/css">
body {font-size:14px; color:#777777; font-family:arial; text-align:center;}
h1 {font-size:64px; color:#333333; margin: 70px 0 50px 0;}
p {width:320px; text-align:center; margin-left:auto;margin-right:auto; margin-top: 30px }
div {width:320px; text-align:center; margin-left:auto;margin-right:auto;}
a:link {color: #28A0CB;}
a:visited {color: #28A0CB;}
a:active {color: #BCBA30;}
a:hover {color: #BCBA30;}
</style>
</head>
<body>
<div style="width:600px; margin-left: auto; margin-right: auto; text-align: center; font-family: Georgia;}">
<p style="font-size: 48pt; color: #485357;">%domain%</p>
<p style="font-size: 14pt; color: gray;">
<a style="color: gray;" href="http://httpd.apache.org/">apache</a> +
<a style="color: gray;" href="http://nginx.net/">nginx</a> +
<a style="color: gray;" href="http://www.percona.com/">percona</a> +
<a style="color: gray;" href="http://vestacp.com/">vesta</a>
</p>
<h1>%domain%</h1>
<div>
<a href="http://httpd.apache.org/">apache</a> +
<a href="http://nginx.com/">nginx</a> +
<a href="http://www.percona.com/">percona</a> +
<a href="http://vestacp.com/">vesta</a>
</div>
</body>
</html>

@ -12,9 +12,9 @@ is_cron_job_free() {
check_job=$(grep "JOB='$job'" $V_USERS/$user/cron.conf)
if [ ! -z "$check_job" ]; then
echo "Error: job exist"
log_event 'debug' "$E_JOB_EXIST $V_EVENT"
exit $E_JOB_EXIST
echo "Error: job id exist"
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
@ -61,9 +61,9 @@ is_job_valid() {
result=$(grep "JOB='$job'" $V_USERS/$user/cron.conf)
if [ -z "$result" ]; then
echo "Error: job not exists"
log_event 'debug' "$E_JOB_NOTEXIST $V_EVENT"
exit $E_JOB_NOTEXIST
echo "Error: job id not exists"
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -80,8 +80,8 @@ is_job_suspended() {
# Checkng key
if [ ! -z "$str" ]; then
echo "Error: job suspended"
log_event 'debug' "$E_JOB_SUSPENDED $V_EVENT"
exit $E_JOB_SUSPENDED
log_event 'debug' "$E_SUSPENDED $V_EVENT"
exit $E_SUSPENDED
fi
}
@ -92,8 +92,8 @@ is_job_unsuspended() {
# Checkng key
if [ ! -z "$str" ]; then
echo "Error: job unsuspended"
log_event 'debug' "$E_JOB_UNSUSPENDED $V_EVENT"
exit $E_JOB_UNSUSPENDED
log_event 'debug' "$E_UNSUSPENDED $V_EVENT"
exit $E_UNSUSPENDED
fi
}

@ -5,8 +5,8 @@ is_db_valid() {
# Checking result
if [ -z "$check_db" ]; then
echo "Error: db not added"
log_event 'debug' "$E_DB_NOTEXIST $V_EVENT"
exit $E_DB_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -17,8 +17,8 @@ is_db_new() {
# Checking result
if [ ! -z "$check_db" ]; then
echo "Error: db exist"
log_event 'debug' "$E_DB_EXIST $V_EVENT"
exit $E_DB_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
@ -31,8 +31,8 @@ is_db_host_valid() {
# Checking result
if [ -z "$check_db" ]; then
echo "Error: host not added"
log_event 'debug' "$E_DBHOST_NOTEXIST $V_EVENT"
exit $E_DBHOST_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -231,16 +231,16 @@ create_db_mysql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Adding database & checking result
@ -248,8 +248,8 @@ create_db_mysql() {
code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Adding user with password (% will give access to db from any ip)
@ -279,16 +279,16 @@ create_db_pgsql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Adding new role
@ -296,8 +296,8 @@ create_db_pgsql() {
code=$?
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Adding database & checking result
@ -320,8 +320,8 @@ is_db_host_new() {
check_host=$(grep "HOST='$host'" $V_DB/$type.conf)
if [ ! -z "$check_host" ]; then
echo "Error: db host exist"
log_event 'debug' "$E_DBHOST_EXIST $V_EVENT"
exit $E_DBHOST_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
fi
}
@ -332,8 +332,8 @@ is_mysql_host_alive() {
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
}
@ -344,8 +344,8 @@ is_pgsql_host_alive() {
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
}
@ -356,8 +356,8 @@ is_db_suspended() {
# Checking result
if [ ! -z "$check_db" ]; then
echo "Error: db suspended"
log_event 'debug' "$E_DB_SUSPENDED $V_EVENT"
exit $E_DB_SUSPENDED
log_event 'debug' "$E_SUSPENDED $V_EVENT"
exit $E_SUSPENDED
fi
}
@ -368,8 +368,8 @@ is_db_unsuspended() {
# Checking result
if [ -z "$check_db" ]; then
echo "Error: db unsuspended"
log_event 'debug' "$E_DB_UNSUSPENDED $V_EVENT"
exit $E_DB_UNSUSPENDED
log_event 'debug' "$E_UNSUSPENDED $V_EVENT"
exit $E_UNSUSPENDED
fi
}
@ -380,8 +380,8 @@ is_db_user_valid() {
# Checking result
if [ -z "$check_db" ]; then
echo "Error: dbuser not exist"
log_event 'debug' "$E_DBUSER_NOTEXIST $V_EVENT"
exit $E_DBUSER_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -396,16 +396,16 @@ change_db_mysql_password() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Changing user password
@ -430,16 +430,16 @@ change_db_pgsql_password() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
$sql "ALTER ROLE $db_user WITH LOGIN PASSWORD '$db_password'" >/dev/null
@ -474,24 +474,24 @@ del_db_mysql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Deleting database & checking result
$sql "DROP DATABASE $database" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Deleting user
@ -523,16 +523,16 @@ del_db_pgsql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Deleting database & checking result
@ -540,8 +540,8 @@ del_db_pgsql() {
$sql "DROP DATABASE $database" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Deleting user
@ -562,8 +562,8 @@ del_db_vesta() {
string=$( grep -n "DB='$database'" $conf | cut -f 1 -d : )
if [ -z "$string" ]; then
echo "Error: parse error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
sed -i "$string d" $conf
}
@ -580,16 +580,16 @@ dump_db_mysql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Dumping database
@ -613,16 +613,16 @@ dump_db_pgsql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Dumping database
@ -649,8 +649,8 @@ is_db_host_free() {
# Checking U_DB_BASES
if [ 0 -ne "$U_DB_BASES" ]; then
echo "Error: host is used"
log_event 'debug' "$E_DBHOST_BUSY $V_EVENT"
exit $E_DBHOST_BUSY
log_event 'debug' "$E_INUSE $V_EVENT"
exit $E_INUSE
fi
}
@ -661,8 +661,8 @@ del_dbhost_vesta() {
string=$( grep -n "HOST='$host'" $conf | cut -f 1 -d : )
if [ -z "$string" ]; then
echo "Error: parse error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
sed -i "$string d" $conf
}
@ -709,16 +709,16 @@ suspend_db_mysql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Suspending user
@ -739,16 +739,16 @@ suspend_db_pgsql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Suspending user
@ -767,16 +767,16 @@ unsuspend_db_mysql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Unsuspending user
@ -797,16 +797,16 @@ unsuspend_db_pgsql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Unsuspending user
@ -840,16 +840,16 @@ get_disk_db_mysql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Deleting database & checking result
@ -885,16 +885,16 @@ get_disk_db_pgsql() {
# Checking empty vars
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
log_event 'debug' "$E_DB $V_EVENT"
exit $E_DB
fi
# Raw query

@ -19,10 +19,10 @@ is_domain_new() {
if [ ! -z "$check_domain" ] || [ ! -z "$check_alias" ]; then
if [ "$output_mode" != 'quiet' ]; then
echo "Error: domain exist"
log_event 'debug' "$E_DOM_EXIST $V_EVENT"
exit $E_DOM_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
return $E_DOM_EXIST
return $E_EXISTS
fi
}
@ -43,8 +43,8 @@ is_domain_owner() {
# Checking result
if [ -z "$check_domain" ] && [ -z "$check_alias" ]; then
echo "Error: domain not owned"
log_event 'debug' "$E_DOM_NOTOWNED $V_EVENT"
exit $E_DOM_NOTOWNED
log_event 'debug' "$E_FORBIDEN $V_EVENT"
exit $E_FORBIDEN
fi
}
@ -55,8 +55,8 @@ is_dns_domain_free() {
# Checking result
if [ ! -z "$check_domain" ]; then
echo "Error: domain exist"
log_event 'debug' "$E_DOM_EXIST $V_EVENT"
exit $E_DOM_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
@ -75,8 +75,8 @@ is_web_domain_free() {
# Checking result
if [ ! -z "$check_domain" ] || [ ! -z "$check_alias" ]; then
echo "Error: domain exist"
log_event 'debug' "$E_DOM_EXIST $V_EVENT"
exit $E_DOM_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
@ -87,8 +87,8 @@ is_dns_domain_valid() {
# Checking result
if [ -z "$check_domain" ]; then
echo "Error: domain not exist"
log_event 'debug' "$E_DOM_NOTEXIST $V_EVENT"
exit $E_DOM_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -99,8 +99,8 @@ is_web_domain_valid() {
# Checking result
if [ -z "$check_domain" ]; then
echo "Error: domain not exist"
log_event 'debug' "$E_DOM_NOTEXIST $V_EVENT"
exit $E_DOM_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -113,8 +113,8 @@ is_domain_suspended() {
# Checking result
if [ ! -z "$check_domain" ]; then
echo "Error: domain suspended"
log_event 'debug' "$E_DOM_SUSPENDED $V_EVENT"
exit $E_DOM_SUSPENDED
log_event 'debug' "$E_SUSPENDED $V_EVENT"
exit $E_SUSPENDED
fi
}
@ -127,8 +127,8 @@ is_domain_unsuspended() {
# Checking result
if [ ! -z "$check_domain" ]; then
echo "Error: domain unsuspended"
log_event 'debug' "$E_DOM_UNSUSPENDED $V_EVENT"
exit $E_DOM_UNSUSPENDED
log_event 'debug' "$E_UNSUSPENDED $V_EVENT"
exit $E_UNSUSPENDED
fi
}
@ -207,8 +207,8 @@ is_dns_record_free() {
if [ ! -z "$check_id" ]; then
echo "Error: ID exist"
log_event 'debug' "$E_ID_EXIST $V_EVENT"
exit $E_ID_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
@ -254,8 +254,8 @@ get_web_config_brds() {
# Defining template borders
serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :)
if [ -z "$serv_line" ]; then
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
return $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
return $E_PARSING
fi
# Template lines
@ -444,8 +444,8 @@ is_web_domain_key_empty() {
# Checkng key
if [ ! -z "$value" ] && [ "$value" != 'no' ]; then
echo "Error: value is not empty = $value"
log_event 'debug' "$E_VALUE_EXIST $V_EVENT"
exit $E_VALUE_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
@ -453,34 +453,34 @@ is_web_domain_cert_valid() {
# Checking file existance
if [ ! -e "$ssl_dir/$domain.crt" ] || [ ! -e "$ssl_dir/$domain.key" ]; then
echo "Error: certificate not exist"
log_event 'debug' "$E_CERT_NOTEXIST $V_EVENT"
exit $E_CERT_NOTEXIST
echo "Error: ssl certificate not exist"
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
# Checking certificate
crt=$(openssl verify $ssl_dir/$domain.crt 2>/dev/null |grep '/C=')
if [ -z "$crt" ]; then
echo "Error: certificate invalid"
log_event 'debug' "$E_CERT_INVALID $V_EVENT"
exit $E_CERT_INVALID
echo "Error: ssl certificate invalid"
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
# Checking certificate key
openssl rsa -in "$ssl_dir/$domain.key" -check >/dev/null 2>/dev/null
if [ "$?" -ne 0 ]; then
echo "Error: key invalid"
log_event 'debug' "$E_KEY_INVALID $V_EVENT"
exit $E_KEY_INVALID
echo "Error: ssl key invalid"
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
# Checking certificate authority
if [ -e "$ssl_dir/$domain.ca" ]; then
ca=$(openssl verify $ssl_dir/$domain.ca 2>/dev/null |grep '/C=')
if [ -z "$ca" ]; then
echo "Error: certificate invalid"
log_event 'debug' "$E_CERT_INVALID $V_EVENT"
exit $E_CERT_INVALID
echo "Error: ssl certificate invalid"
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
fi
@ -493,9 +493,9 @@ is_web_domain_cert_valid() {
kill $pid > /dev/null 2>&1
result=$?
if [ "$result" -ne '0' ]; then
echo "Error: certificate key pair invalid"
log_event 'debug' "$E_CERTKEY_INVALID $V_EVENT"
exit $E_CERTKEY_INVALID
echo "Error: ssl certificate key pair invalid"
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -506,8 +506,8 @@ is_dns_record_valid() {
if [ -z "$check_id" ]; then
echo "Error: ID not exist"
log_event 'debug' "$E_ID_NOTEXIST $V_EVENT"
exit $E_ID_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -528,8 +528,8 @@ is_web_domain_value_exist() {
# Checking result
if [ -z "$value" ] || [ "$value" = 'no' ]; then
echo "Error: ${key//$/} is empty"
log_event 'debug' "$E_VALUE_EMPTY $V_EVENT"
exit $E_VALUE_EMPTY
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -550,8 +550,8 @@ is_dns_domain_value_exist() {
# Checking result
if [ -z "$value" ] || [ "$value" = 'no' ]; then
echo "Error: ${key//$/} is empty"
log_event 'debug' "$E_VALUE_EMPTY $V_EVENT"
exit $E_VALUE_EXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_EXISTS
fi
}
@ -571,8 +571,8 @@ del_dns_domain() {
string=$( grep -n "DOMAIN='$domain'" $conf | cut -f 1 -d : )
if [ -z "$string" ]; then
echo "Error: parse error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
sed -i "$string d" $conf
rm -f $V_USERS/$user/dns/$domain
@ -585,8 +585,8 @@ del_web_domain() {
string=$( grep -n "DOMAIN='$domain'" $conf | cut -f 1 -d : )
if [ -z "$string" ]; then
echo "Error: parse error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
sed -i "$string d" $conf
}
@ -678,8 +678,8 @@ namehost_ip_disable() {
if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ]
then
echo "Error: nginx config paring error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
up_line=$((ip_line - 1))
@ -689,8 +689,8 @@ namehost_ip_disable() {
# Checking parsed lines
if [ -z "$first_line" ] || [ -z "$last_line" ]; then
echo "Error: nginx config paring error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
sed -i "$first_line,$last_line d" $nconf

@ -6,8 +6,8 @@ is_sys_ip_free() {
ip_check=$(echo "$ip_list"|grep -w "$ip")
if [ -n "$ip_check" ] || [ -e "$V_IPS/$ip" ]; then
echo "Error: IP exist"
log_event 'debug' "$E_IP_EXIST $V_EVENT"
exit $E_IP_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
@ -32,8 +32,8 @@ is_sys_ip_valid() {
# Checking ip existance
if [ ! -e "$V_IPS/$ip" ] || [ -z "$check_ifc" ]; then
echo "Error: IP not exist"
log_event 'debug' "$E_IP_NOTEXIST $V_EVENT"
exit $E_IP_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
@ -54,8 +54,8 @@ is_ip_key_empty() {
# Checkng key
if [ ! -z "$value" ] && [ "$value" != '0' ]; then
echo "Error: value is not empty = $value "
log_event 'debug' "$E_VALUE_EXIST $V_EVENT"
exit $E_VALUE_EXIST
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
@ -92,8 +92,8 @@ is_ip_avalable() {
# Checking ip existance
if [ ! -e "$V_IPS/$ip" ]; then
echo "Error: IP not exist"
log_event 'debug' "$E_IP_NOTEXIST $V_EVENT"
exit $E_IP_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
# Parsing ip data
@ -110,8 +110,8 @@ is_ip_avalable() {
if [ "$ip_owner" != "$user" ] && [ "$ip_shared" != 'yes' ]; then
echo "Error: ip not owned by user"
log_event 'debug' "$E_IP_NOTOWNED $V_EVENT"
exit $E_IP_NOTOWNED
log_event 'debug' "$E_FORBIDEN $V_EVENT"
exit $E_FORBIDEN
fi
}
@ -121,8 +121,8 @@ is_sys_ip_owner() {
ip_owner=$(grep 'OWNER=' $V_IPS/$ip|cut -f 2 -d \')
if [ "$ip_owner" != "$user" ]; then
echo "Error: IP not owned"
log_event 'debug' "$E_IP_NOTOWNED $V_EVENT"
exit $E_IP_NOTOWNED
log_event 'debug' "$E_FORBIDEN $V_EVENT"
exit $E_FORBIDEN
fi
}
@ -144,8 +144,8 @@ increase_ip_value() {
# Checking result
if [ -z "$current_web" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# +1 webdomain
@ -181,8 +181,8 @@ decrease_ip_value() {
# Checking result
if [ -z "$current_web" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# -1 webdomain
@ -230,16 +230,16 @@ get_current_interface() {
# Checking result
if [ -z "$i" ]; then
echo "Error: IP not exist"
log_event 'debug' "$E_IP_NOTEXIST $V_EVENT"
exit $E_IP_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
# Checking ip is alias
check_alias=$(echo $i| cut -s -f 2 -d :)
if [ -z "$check_alias" ]; then
echo "Error: IP is first on interface"
log_event 'debug' "$E_IP_FIRST $V_EVENT"
exit $E_IP_FIRST
echo "Error: Main IP on interface"
log_event 'debug' "$E_FORBIDEN $V_EVENT"
exit $E_FORBIDEN
fi
echo "$i"
}

@ -6,9 +6,8 @@ log_event() {
# Checking logging system
if [ "$LOG_SYSTEM" = 'yes' ]; then
# Checking logging level
log=$(echo "$LOG_LEVEL" | cut -f 2 -d \' | grep -w "$level" )
if [ ! -z "$log" ]; then
log=$(echo "$LOG_LEVEL" | grep -w "$level" )
if [ -n "$log" ]; then
echo "$event" >> $V_LOG/$level.log
fi
fi
@ -25,20 +24,8 @@ log_history() {
fi
}
# External function result checker
check_func_result() {
return_code="$1"
if [[ "$return_code" -ne "$OK" ]]; then
log_event 'debug' "$return_code $V_EVENT"
exit $return_code
fi
}
# Argument list checker
check_args() {
sys_args="$1"
user_args="$2"
usage="$3"
@ -46,8 +33,8 @@ check_args() {
if [ "$user_args" -lt "$sys_args" ]; then
echo "Error: bad args"
echo "Usage: $V_SCRIPT $usage"
log_event 'debug' "$E_BAD_ARGS $V_EVENT"
exit $E_BAD_ARGS
log_event 'debug' "$E_ARGS $V_EVENT"
exit $E_ARGS
fi
}
@ -62,9 +49,9 @@ format_validation() {
check_http=$( echo "$val" |grep "^https://" )
needed_chars=$(echo "$val" | cut -s -f 2 -d '.')
if [ -z "$check_http" ] || [ -z "$needed_chars" ]; then
echo "Error: shell not found"
log_event 'debug' "$E_SHELL_INVALID $V_EVENT"
exit $E_SHELL_INVALID
echo "Error: invalid url"
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -76,8 +63,8 @@ format_validation() {
check_shell=$(/usr/bin/chsh --list-shells | grep -w "$val" )
if [ -z "$check_shell" ]; then
echo "Error: shell not found"
log_event 'debug' "$E_SHELL_INVALID $V_EVENT"
exit $E_SHELL_INVALID
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -88,8 +75,8 @@ format_validation() {
# Checking password lenght
if [ "${#val}" -lt '6' ]; then
echo "Error: password is shorter than 6 chars"
log_event 'debug' "$E_PASSWORD_SHORT $V_EVENT"
exit $E_PASSWORD_SHORT
log_event 'debug' "$E_PASSWORD $V_EVENT"
exit $E_PASSWORD
fi
}
@ -99,27 +86,27 @@ format_validation() {
# Defining exlude mask
special_chars=$(echo "$val" | \
grep -c "[!|@|#|$|^|&|*|(|)|-|+|=|{|}|:|_|,|.|<|>|?|/|\|\"|'|;|%]" )
grep -c "[!|@|#|$|^|&|*|(|)|-|+|=|{|}|:|_|,|.|<|>|?|/|\|\"|'|;|%| ]" )
if [[ 0 -ne "$special_chars" ]]; then
echo "Error: $var out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
# Checking letters
letters=$(echo "$val" | grep -c "[a-Z]")
if [ 0 -ne "$letters" ]; then
echo "Error: $var out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
# Checking -zero
if [[ 0 -ne "$val" ]] && [[ 0 -gt "$val" ]]; then
echo "Error: $var out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -136,8 +123,8 @@ format_validation() {
if [ -z "$oc1" ] || [ -z "$oc2" ] || [ -z "$oc3" ] || [ -z "$oc4" ]
then
echo "Error: $var out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -150,8 +137,8 @@ format_validation() {
# Checking status
if [ -z "$check_status" ]; then
echo "Error: $var out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -168,8 +155,8 @@ format_validation() {
[ "${#check_dt}" -lt 2 ] &&\
[ "$val" != 'vesta@localhost' ]; then
echo "Error: email format is wrong"
log_event 'debug' "$E_EMAIL_INVALID $V_EVENT"
exit $E_EMAIL_INVALID
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -183,8 +170,8 @@ format_validation() {
if [ "$return_val" -ne 0 ]; then
echo "Error: intreface not exist"
log_event 'debug' "$E_INTERFACE_NOTEXIST"
exit $E_INTERFACE_NOTEXIST
log_event 'debug' "$E_NOTEXIST"
exit $E_NOTEXIST
fi
}
@ -194,13 +181,13 @@ format_validation() {
# Defining exlude mask
special_chars=$(echo "$val" | \
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:| |,|<|>|?|/|\|\"|'|;|%]" )
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:| |,|<|>|?|/|\|\"|'|;|%| ]" )
# Checking result
if [[ 0 -ne "$special_chars" ]]; then
echo "Error: $var is out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -210,14 +197,14 @@ format_validation() {
# Defining exlude mask
special_chars=$(echo "$val" | \
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%]" )
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%| ]" )
needed_chars=$(echo "$val" | cut -s -f 2 -d '.')
# Checking result
if [[ 0 -ne "$special_chars" ]] || [ -z "$needed_chars" ]; then
echo "Error: $var is out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -227,13 +214,13 @@ format_validation() {
# Defining exlude mask
special_chars=$(echo "$val" | \
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%]" )
grep -c "[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%| ]" )
# Checking result
if [[ 0 -ne "$special_chars" ]] || [ 17 -le ${#val} ]; then
echo "Error: $var is out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -244,8 +231,8 @@ format_validation() {
# Checking result
if [ 17 -le ${#val} ]; then
echo "Error: $var is out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -271,8 +258,8 @@ format_validation() {
if [[ "$known" != 'yes' ]]; then
echo "Error: $var is out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -283,8 +270,8 @@ format_validation() {
# Checking result
if [ 200 -le ${#val} ]; then
echo "Error: $var is out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -297,8 +284,8 @@ format_validation() {
check_rtype="$(echo "A AAAA NS CNAME" | grep -i -w "$rtype")"
if [ ! -z "$check_spaces" ] && [ ! -z "$check_rtype" ]; then
echo "Error: $var is out of range"
log_event 'debug' "$E_OUTOFRANGE $V_EVENT"
exit $E_OUTOFRANGE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
# Checking ip
@ -373,48 +360,48 @@ is_system_enabled() {
web_function() {
if [ -z "$WEB_SYSTEM" ] || [ "$WEB_SYSTEM" = "no" ]; then
echo "Error: web hosting support disabled"
log_event 'debug' "$E_WEB_DISABLED $V_EVENT"
exit $E_WEB_DISABLED
log_event 'debug' "$E_DISABLED $V_EVENT"
exit $E_DISABLED
fi
}
proxy_function() {
if [ "$PROXY_SYSTEM" != 'nginx' ]; then # only nginx
echo "Error: proxy hosting support disabled" # support for
log_event 'debug' "$E_PROXY_DISABLED $V_EVENT" # now
exit $E_PROXY_DISABLED
if [ "$PROXY_SYSTEM" != 'nginx' ]; then
echo "Error: proxy hosting support disabled"
log_event 'debug' "$E_DISABLED $V_EVENT"
exit $E_DISABLED
fi
}
dns_function() {
if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = "no" ]; then
echo "Error: dns support disabled"
log_event 'debug' "$E_DNS_DISABLED $V_EVENT"
exit $E_DNS_DISABLED
log_event 'debug' "$E_DISABLED $V_EVENT"
exit $E_DISABLED
fi
}
cron_function() {
if [ -z "$CRON_SYSTEM" ] || [ "$CRON_SYSTEM" = "no" ]; then
echo "Error: crond support disabled"
log_event 'debug' "$E_CRON_DISABLED $V_EVENT"
exit $E_CRON_DISABLED
log_event 'debug' "$E_DISABLED $V_EVENT"
exit $E_DISABLED
fi
}
db_function() {
if [ -z "$DB_SYSTEM" ] || [ "$DB_SYSTEM" = "no" ]; then
echo "Error: db support disabled"
log_event 'debug' "$E_DB_DISABLED $V_EVENT"
exit $E_DB_DISABLED
log_event 'debug' "$E_DISABLED $V_EVENT"
exit $E_DISABLED
fi
}
backup_function() {
if [ -z "$BACKUP_SYSTEM" ] || [ "$BACKUP_SYSTEM" = "no" ]; then
echo "Error: backup support disabled"
log_event 'debug' "$E_BACKUP_DISABLED $V_EVENT"
exit $E_BACKUP_DISABLED
log_event 'debug' "$E_DISABLED $V_EVENT"
exit $E_DISABLED
fi
}
@ -432,17 +419,17 @@ is_system_enabled() {
# System user check
is_user_valid() {
search_user="${1-$user}"
check_user=$(cut -f 1 -d : /etc/passwd | grep -w "$search_user" )
check_user=$(grep -w "$search_user" /etc/passwd )
if [ -z "$check_user" ]; then
echo "Error: user not found"
log_event 'debug' "$E_USER_NOTEXIST $V_EVENT"
exit $E_USER_NOTEXIST
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
if [ ! -d "$V_USERS/$search_user" ]; then
echo "Error: unknown user"
log_event 'debug' "$E_USER_UNKNOWN $V_EVENT"
exit $E_USER_UNKNOWN
log_event 'debug' "$E_USER_NOTEXIST $V_EVENT"
exit $E_USER_NOTEXIST
fi
}
@ -451,8 +438,8 @@ is_user_suspended() {
check_suspend=$(grep "SUSPENDED='yes'" $V_USERS/$user/user.conf)
if [ ! -z "$check_suspend" ]; then
echo "Error: User is suspended"
log_event 'debug' "$E_USER_SUSPENDED $V_EVENT"
exit $E_USER_SUSPENDED
log_event 'debug' "$E_SUSPENDED $V_EVENT"
exit $E_SUSPENDED
fi
}
@ -468,8 +455,8 @@ is_package_full() {
val=$(grep '^WEB_DOMAINS=' $V_USERS/$user/user.conf|cut -f 2 -d \' )
if [ "$domain_number" -ge "$val" ]; then
echo "Error: Upgrade package"
log_event 'debug' "$E_PKG_UPGRADE $v_log"
exit $E_PKG_UPGRADE
log_event 'debug' "$E_LIMIT $v_log"
exit $E_LIMIT
fi
}
@ -483,8 +470,8 @@ is_package_full() {
val=$(grep 'WEB_ALIASES=' $V_USERS/$user/user.conf | cut -f 2 -d \' )
if [ "$alias_nmb" -ge "$val" ]; then
echo "Error: Upgrade package"
log_event 'debug' "$E_PKG_UPGRADE $v_log"
exit $E_PKG_UPGRADE
log_event 'debug' "$E_LIMIT $v_log"
exit $E_LIMIT
fi
}
@ -493,8 +480,8 @@ is_package_full() {
val=$(grep '^WEB_SSL=' $V_USERS/$user/user.conf | cut -f 2 -d \' )
if [ "$val" -eq '0' ]; then
echo "Error: Upgrade package"
log_event 'debug' "$E_PKG_UPGRADE $v_log"
exit $E_PKG_UPGRADE
log_event 'debug' "$E_LIMIT $v_log"
exit $E_LIMIT
fi
# Checking domains
@ -502,8 +489,8 @@ is_package_full() {
# Comparing current val with conf
if [ "$domain_nmb" -ge "$val" ]; then
echo "Error: Upgrade package"
log_event 'debug' "$E_PKG_UPGRADE $v_log"
exit $E_PKG_UPGRADE
log_event 'debug' "$E_LIMIT $v_log"
exit $E_LIMIT
fi
}
@ -515,8 +502,8 @@ is_package_full() {
val=$(grep '^DNS_DOMAINS=' $V_USERS/$user/user.conf | cut -f 2 -d \' )
if [ "$domain_number" -ge "$val" ]; then
echo "Error: Upgrade package"
log_event 'debug' "$E_PKG_UPGRADE $v_log"
exit $E_PKG_UPGRADE
log_event 'debug' "$E_LIMIT $v_log"
exit $E_LIMIT
fi
}
@ -528,8 +515,8 @@ is_package_full() {
val=$(grep '^DATABASES=' $V_USERS/$user/user.conf | cut -f 2 -d \' )
if [ "$db_number" -ge "$val" ]; then
echo "Error: Upgrade package"
log_event 'debug' "$E_PKG_UPGRADE $v_log"
exit $E_PKG_UPGRADE
log_event 'debug' "$E_LIMIT $v_log"
exit $E_LIMIT
fi
}
@ -547,50 +534,12 @@ is_package_full() {
mail_forwarder) mail_forwarder "$user" "$domain";;
*)
echo "Error: bad type"
log_event 'debug' "$E_BAD_TYPE $V_EVENT"
exit $E_BAD_TYPE
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
;;
esac
}
is_package_avalable() {
# Parsing user data
usr_data=$(cat $V_USERS/$user/user.conf)
for key in $usr_data; do
eval ${key%%=*}=${key#*=}
done
# Clearing vars
WEB_DOMAINS='0'
WEB_SSL='0'
DATABASES='0'
MAIL_DOMAINS='0'
MAIL_BOXES='0'
MAIL_FORWARDERS='0'
DNS_DOMAINS='0'
DISK_QUOTA='0'
BANDWIDTH='0'
# Parsing package
pkg_data=$(cat $V_PKG/$package.pkg)
for key in $pkg_data; do
eval ${key%%=*}=${key#*=}
done
# Comparing user data with package
if [ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ] ||\
[ "$WEB_SSL" -lt "$U_WEB_SSL" ] ||\
[ "$DATABASES" -lt "$U_DATABASES" ] ||\
[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ] ||\
[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ] ||\
[ "$DISK_QUOTA" -lt "$U_DISK" ] ||\
[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]; then
echo "Error: Upgrade package"
log_event 'debug' "$E_PKG_UPGRADE $v_log"
exit $E_PKG_UPGRADE
fi
}
is_template_valid() {
stype="$1"
@ -604,8 +553,8 @@ is_template_valid() {
if [ -z "$check_tpl" ] || [ ! -e $tpl ] || \
[ ! -e $descr ] || [ ! -e $ssl ]; then
echo "Error: template not found"
log_event 'debug' "$E_TPL_NOTEXIST"
exit $E_TPL_NOTEXIST
log_event 'debug' "$E_NOTEXIST"
exit $E_NOTEXIST
fi
}
@ -616,8 +565,8 @@ is_template_valid() {
if [ ! -e $tpl ] || [ ! -e $descr ] || [ ! -e $ssl ]; then
echo "Error: template not found"
log_event 'debug' "$E_TPL_NOTEXIST"
exit $E_TPL_NOTEXIST
log_event 'debug' "$E_NOTEXIST"
exit $E_NOTEXIST
fi
}
@ -627,8 +576,8 @@ is_template_valid() {
if [ ! -e $tpl ] || [ ! -e $descr ]; then
echo "Error: template not found"
log_event 'debug' "$E_TPL_NOTEXIST"
exit $E_TPL_NOTEXIST
log_event 'debug' "$E_NOTEXIST"
exit $E_NOTEXIST
fi
}
@ -676,45 +625,11 @@ restart_schedule() {
fi
}
is_user_free() {
# Parsing domain values
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
# Checking result
if [ ! -z "$check_sysuser" ] || [ -e "$V_USERS/$user" ]; then
echo "Error: user $user exist"
log_event 'debug' "$E_USER_EXIST $V_EVENT"
exit $E_USER_EXIST
fi
}
is_package_valid() {
if [ ! -e "$V_PKG/$package.pkg" ]; then
echo "Error: package is not exist"
log_event 'debug' "$E_PKG_NOTEXIST $v_log"
exit $E_PKG_NOTEXIST
fi
}
is_user_key_empty() {
key="$1"
# Parsing ip
string=$(cat $V_USERS/$user/user.conf )
# Parsing key=value
for keys in $string; do
eval ${keys%%=*}=${keys#*=}
done
# Self reference
eval value="$key"
# Checkng key
if [ ! -z "$value" ] && [ "$value" != 'no' ] && [ "$value" != '0' ]; then
echo "Error: value is not empty = $value "
log_event 'debug' "$E_VALUE_EXIST $V_EVENT"
exit $E_VALUE_EXIST
log_event 'debug' "$E_NOTEXIST $v_log"
exit $E_NOTEXIST
fi
}
@ -763,8 +678,8 @@ increase_user_value() {
# Checking result
if [ -z "$current_value" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Plus one
@ -792,78 +707,8 @@ is_type_valid() {
# Checking result
if [ -z "$check_type" ]; then
echo "Error: unknown type"
log_event 'debug' "$E_BAD_TYPE $V_EVENT"
exit $E_BAD_TYPE
fi
}
change_user_package() {
# Parsing user data
usr_data=$(cat $V_USERS/$user/user.conf)
for key in $usr_data; do
eval ${key%%=*}=${key#*=}
done
# Parsing package
pkg_data=$(cat $V_PKG/$package.pkg)
for key in $pkg_data; do
eval ${key%%=*}=${key#*=}
done
echo "FNAME='$FNAME'
LNAME='$LNAME'
PACKAGE='$package'
WEB_DOMAINS='$WEB_DOMAINS'
WEB_SSL='$WEB_SSL'
WEB_ALIASES='$WEB_ALIASES'
DATABASES='$DATABASES'
MAIL_DOMAINS='$MAIL_DOMAINS'
MAIL_BOXES='$MAIL_BOXES'
MAIL_FORWARDERS='$MAIL_FORWARDERS'
DNS_DOMAINS='$DNS_DOMAINS'
DISK_QUOTA='$DISK_QUOTA'
BANDWIDTH='$BANDWIDTH'
NS='$NS'
SHELL='$SHELL'
BACKUPS='$BACKUPS'
WEB_TPL='$WEB_TPL'
SUSPENDED='$SUSPENDED'
CONTACT='$CONTACT'
REPORTS='$REPORTS'
IP_OWNED='$IP_OWNED'
U_DIR_DISK='$U_DIR_DISK'
U_DISK='$U_DISK'
U_BANDWIDTH='$U_BANDWIDTH'
U_WEB_DOMAINS='$U_WEB_DOMAINS'
U_WEB_SSL='$U_WEB_SSL'
U_DNS_DOMAINS='$U_DNS_DOMAINS'
U_DATABASES='$U_DATABASES'
U_MAIL_DOMAINS='$U_MAIL_DOMAINS'
DATE='$DATE'" > $V_USERS/$user/user.conf
}
get_shell_path() {
check_shell=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
echo "$check_shell"
}
is_user_value_exist() {
key="$1"
string=$(cat $V_USERS/$user/user.conf )
# Parsing key=value
for keys in $string; do
eval ${keys%%=*}=${keys#*=}
done
# Self reference
eval value="$key"
# Checking result
if [ -z "$value" ] || [ "$value" = 'no' ]; then
echo "Error: ${key//$/} is empty"
log_event 'debug' "$E_VALUE_EMPTY $V_EVENT"
exit $E_VALUE_EMPTY
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
@ -881,8 +726,8 @@ decrease_user_value() {
# Checking result
if [ -z "$current_value" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
# Checking zero val
@ -907,9 +752,7 @@ json_list() {
while read line; do
# Assing key=value pair
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -960,9 +803,7 @@ shell_list() {
# Reading file line by line
while read line ; do
# Assing key=value pair
for key in $line; do
eval ${key%%=*}=${key#*=}
done
eval $line
# Print result
eval echo "$fields"
@ -1028,29 +869,12 @@ get_usr_traff() {
echo "$size"
}
get_config_value() {
key="$1"
# Parsing config
string=$(cat $V_CONF/vesta.conf)
# Parsing key=value
for keys in $string; do
eval ${keys%%=*}=${keys#*=}
done
# Self reference
eval value="$key"
# Print value
echo "$value"
}
is_backup_enabled() {
BACKUPS=$(grep "BACKUPS='" $V_USERS/$user/user.conf |cut -f 2 -d \')
if [ -z "$BACKUPS" ] || [[ "$BACKUPS" -le '0' ]]; then
echo "Error: User backups are disabled"
log_event 'debug' "$E_BACKUP_DISABLED $V_EVENT"
exit $E_BACKUP_DISABLED
log_event 'debug' "$E_DISABLED $V_EVENT"
exit $E_DISABLED
fi
}

@ -28,7 +28,7 @@ int main (int argc, char** argv) {
if (3 > argc) {
printf("Error: bad args\n",argv[0]);
printf("Usage: %s user password [ip]\n",argv[0]);
exit(3);
exit(1);
};
// checking ip
@ -47,7 +47,7 @@ int main (int argc, char** argv) {
FILE* pFile = fopen ("/usr/local/vesta/log/auth.log","a+");
if (NULL == pFile) {
printf("Error: can not open file %s \n", argv[0]);
exit(7);
exit(12);
}
// parsing user argument
@ -74,12 +74,12 @@ int main (int argc, char** argv) {
strcat(str, " failed to login \n");
fputs (str,pFile); // writing
fclose (pFile); // closing
exit(24); // exiting
exit(9); // exiting
};
}
} else {
printf("Error: no such user\n",argv[1]);
exit(21);
exit(3);
};
return EXIT_SUCCESS;