Merge changes from upstream & more

This commit is contained in:
ZonD Eighty 2013-01-10 22:14:34 +04:00
commit a2ac36b676
22 changed files with 5760 additions and 4261 deletions

View file

@ -1,3 +1,4 @@
<<<<<<< HEAD
#!/bin/bash
# info: add dns domain or dns record based on web domain alias restart
# options: USER DOMAIN
@ -78,3 +79,92 @@ fi
# No Logging
exit
=======
#!/bin/bash
# info: add dns domain or dns record based on web domain alias restart
# options: USER DOMAIN
#
# The function adds dns domain or dns record based on web domain alias.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain_idn=$(idn -t --quiet -a "$domain")
dom_alias=$(idn -t --quiet -u "$3" )
dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g')
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
restart="$4"
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN ALIAS'
validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM"
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Parsing domain values
get_domain_values 'web'
# Check if it a simple domain
if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then
if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then
$BIN/v-add-dns-domain \
$user $dom_alias $IP '' '' '' '' '' $restart > /dev/null
fi
else
# Check subdomain
sub=$(echo "$dom_alias" | cut -f1 -d . -s)
dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" )
if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
$BIN/v-add-dns-domain \
$user $dom $IP '' '' '' '' '' $restart > /dev/null
if [ $? -eq 0 ]; then
$BIN/v-add-dns-domain-record \
$user $dom "$sub" A $IP '' '' $restart
fi
else
if [ "$sub" == '*' ]; then
rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf)
else
rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
fi
if [ -z "$rec" ]; then
$BIN/v-add-dns-domain-record \
$user $dom "$sub" A $IP '' '' $restart > /dev/null
fi
fi
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# No Logging
exit
>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d

View file

@ -1,3 +1,4 @@
<<<<<<< HEAD
#!/bin/bash
# info: add ftp account for web domain.
# options: USER DOMAIN FTP_USER FTP_PASSWORD
@ -69,3 +70,82 @@ log_history "added ftp account $ftp_user for $domain"
log_event "$OK" "$EVENT"
exit
=======
#!/bin/bash
# info: add ftp account for web domain.
# options: USER DOMAIN FTP_USER FTP_PASSWORD
#
# The function creates addutional ftp account for web domain.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
ftp_user=${1}_${3}
ftp_password=$4
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
# Hiding password
A4='******'
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD'
validate_format 'user' 'domain' 'ftp_user' 'ftp_password'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
get_domain_values 'web'
check_ftp_user=$(grep "^$ftp_user:" /etc/passwd)
if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then
echo "Error: ftp user $ftp_user already exists"
log_event "$E_EXISTS $EVENT"
exit $E_EXISTS
fi
if [ ! -z "$FTP_USER" ]; then
/usr/sbin/userdel $FTP_USER
fi
# Adding user
/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \
-d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1
echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null
ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)"
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Update config
update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user"
update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5"
# Logging
log_history "added ftp account $ftp_user for $domain"
log_event "$OK" "$EVENT"
exit
>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d

View file

@ -1,3 +1,4 @@
<<<<<<< HEAD
#!/bin/bash
# info: rebuild dns domains
# options: USER [RESTART]
@ -310,3 +311,317 @@ fi
log_event "$OK" "$EVENT"
exit
=======
#!/bin/bash
# info: rebuild dns domains
# options: USER [RESTART]
#
# The function rebuilds BIND configuration files for all dns domains.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
restart=$2
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'USER [RESTART]'
validate_format 'user'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
user_domains=0
user_ssl=0
user_aliases=0
suspended_web=0
# Clean up old config
rm -f $HOMEDIR/$user/conf/tmp_*.conf
# Defining config
conf=$USER_DATA/web.conf
fields='$DOMAIN'
nohead=1
# Starting loop
for domain in $(shell_list) ; do
# Rebuilding directories
mkdir -p $HOMEDIR/$user/web/$domain \
$HOMEDIR/$user/web/$domain/public_html \
$HOMEDIR/$user/web/$domain/public_shtml \
$HOMEDIR/$user/web/$domain/document_errors \
$HOMEDIR/$user/web/$domain/cgi-bin \
$HOMEDIR/$user/web/$domain/private \
$HOMEDIR/$user/web/$domain/stats \
$HOMEDIR/$user/web/$domain/logs
if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.log" ]; then
ln -s /var/log/httpd/domains/$domain.error.log \
$HOMEDIR/$user/web/$domain/logs/$domain.log
fi
if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.error.log" ]; then
ln -s /var/log/httpd/domains/$domain.error.log \
$HOMEDIR/$user/web/$domain/logs/$domain.error.log
fi
if [ -e "$WEBTPL/skel/document_errors/" ]; then
cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/
fi
touch /var/log/httpd/domains/$domain.bytes \
/var/log/httpd/domains/$domain.log \
/var/log/httpd/domains/$domain.error.log
chmod 551 $HOMEDIR/$user/web/$domain
chmod 771 $HOMEDIR/$user/web/$domain/private
chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin
chmod 771 $HOMEDIR/$user/web/$domain/public_html
chmod 771 $HOMEDIR/$user/web/$domain/public_shtml
chmod 771 $HOMEDIR/$user/web/$domain/document_errors
chmod 551 $HOMEDIR/$user/web/$domain/stats
chmod 551 $HOMEDIR/$user/web/$domain/logs
chmod 640 /var/log/httpd/domains/$domain.*
chown $user:$user $HOMEDIR/$user/web/$domain
chown $user:$user $HOMEDIR/$user/web/$domain/private
chown $user:$user $HOMEDIR/$user/web/$domain/cgi-bin
chown $user:$user $HOMEDIR/$user/web/$domain/public_html
chown $user:$user $HOMEDIR/$user/web/$domain/public_shtml
chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors
chown root:$user /var/log/httpd/domains/$domain.*
chown root:apache $conf
# Parsing domain values
domain_idn=$(idn -t --quiet -a "$domain")
get_domain_values 'web'
# Preparing domain values for the template substitution
upd_web_domain_values
# Adding domain to the tmp_httpd.conf
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
add_web_config
chown root:apache $conf
chmod 640 $conf
# Running template trigger
if [ -x $WEBTPL/apache_$TPL.sh ]; then
$WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot
fi
# Checking aliases
if [ ! -z "$ALIAS" ]; then
aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l)
user_aliases=$((user_aliases + aliases))
fi
# Checking stats
if [ ! -z "$STATS" ]; then
cat $WEBTPL/$STATS.tpl |\
sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
-e "s/%proxy_port%/$PROXY_PORT/g" \
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
-e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \
-e "s/%user%/$user/g" \
-e "s/%home%/${HOMEDIR////\/}/g" \
-e "s/%alias%/${aliases//,/ }/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
> $HOMEDIR/$user/conf/web/$STATS.$domain.conf
if [ "$STATS" == 'awstats' ]; then
if [ ! -e "/etc/awstats/$STATS.$domain.conf" ]; then
ln -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf /etc/awstats/
fi
fi
webstats="$BIN/v-update-web-domain-stat $user $domain"
check_webstats=$(grep "$webstats" $VESTA/data/queue/webstats.pipe)
if [ -z "$check_webstats" ]; then
echo "$webstats" >> $VESTA/data/queue/webstats.pipe
fi
if [ ! -z "$STATS_USER" ]; then
# Definining statistic dir
stats_dir="$HOMEDIR/$user/web/$domain/stats"
# Adding htaccess file
echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess
echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess
echo "AuthType Basic" >> $stats_dir/.htaccess
echo "Require valid-user" >> $stats_dir/.htaccess
# Generating htaccess user and password
echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd
fi
fi
# Checking ssl
if [ "$SSL" = 'yes' ]; then
# Adding domain to the shttpd.conf
conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
add_web_config
chown root:apache $conf
chmod 640 $conf
cp -f $USER_DATA/ssl/$domain.crt \
$HOMEDIR/$user/conf/web/ssl.$domain.crt
cp -f $USER_DATA/ssl/$domain.key \
$HOMEDIR/$user/conf/web/ssl.$domain.key
cp -f $USER_DATA/ssl/$domain.pem \
$HOMEDIR/$user/conf/web/ssl.$domain.pem
if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
cp -f $USER_DATA/ssl/$domain.ca \
$HOMEDIR/$user/conf/web/ssl.$domain.ca
fi
# Running template trigger
if [ -x $WEBTPL/apache_$TPL.sh ]; then
$WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot
fi
user_ssl=$((user_ssl + 1))
ssl_change='yes'
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
add_web_config
chown root:nginx $conf
chmod 640 $conf
if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
add_web_config
chown root:nginx $conf
chmod 640 $conf
fi
ngix_change='yes'
fi
if [ "$SUSPENDED" = 'yes' ]; then
suspended_web=$((suspended_web + 1))
fi
user_domains=$((user_domains + 1))
# Checking ftp
if [ ! -z "$FTP_USER" ]; then
if [ -z "$(grep ^$FTP_USER: /etc/passwd)" ]; then
/usr/sbin/adduser $FTP_USER -g $user -s /sbin/nologin -M \
-d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1
shadow='/etc/shadow'
shdw=$(grep "^$FTP_USER:" $shadow)
shdw3=$(echo "$shdw" | cut -f3 -d :)
shdw4=$(echo "$shdw" | cut -f4 -d :)
shdw5=$(echo "$shdw" | cut -f5 -d :)
shdw6=$(echo "$shdw" | cut -f6 -d :)
shdw7=$(echo "$shdw" | cut -f7 -d :)
shdw8=$(echo "$shdw" | cut -f8 -d :)
shdw9=$(echo "$shdw" | cut -f9 -d :)
chmod u+w $shadow
sed -i "/^$FTP_USER:*/d" $shadow
shdw_str="$FTP_USER:$FTP_MD5:$shdw3:$shdw4:$shdw5:$shdw6"
shdw_str="$shdw_str:$shdw7:$shdw8:$shdw9"
echo "$shdw_str" >> $shadow
chmod u-w $shadow
fi
fi
done
# Renaming tmp config
tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
if [ -e "$tmp_conf" ]; then
mv $tmp_conf $conf
fi
# Checking include in main httpd.conf
main_conf='/etc/httpd/conf.d/vesta.conf'
main_conf_check=$(grep "$conf" $main_conf )
if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then
echo "Include $conf" >>$main_conf
fi
# Checking ssl
if [ "$ssl_change" = 'yes' ]; then
tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
mv $tmp_conf $conf
# Checking include in main httpd.conf
main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then
echo "Include $conf" >>$main_conf
fi
fi
# Checking nginx
if [ "$ngix_change" = 'yes' ]; then
nginx_conf='/etc/nginx/conf.d/vesta_users.conf'
tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
mv $tmp_conf $conf
nginx_conf_check=$(grep "$conf" $nginx_conf )
if [ -z "$nginx_conf_check" ]; then
echo "include $conf;" >>$nginx_conf
fi
# Checking ssl for nginx
if [ "$ssl_change" = 'yes' ]; then
tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
mv $tmp_conf $conf
nginx_conf_check=$(grep "$conf" $nginx_conf )
if [ -z "$nginx_conf_check" ]; then
echo "include $conf;" >>$nginx_conf
fi
fi
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Updating counters
update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web"
update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains"
update_user_value "$user" '$U_WEB_SSL' "$user_ssl"
update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases"
# Restart web server
if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT"
fi
# Logging
log_event "$OK" "$EVENT"
exit
>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d

View file

@ -1,3 +1,4 @@
<<<<<<< HEAD
#!/bin/bash
# info: update user statistics
# options: USER
@ -167,3 +168,174 @@ fi
log_event "$OK" "$EVENT"
exit
=======
#!/bin/bash
# info: update user statistics
# options: USER
#
# Function logs user parameters into statistics database.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
# Importing system enviroment as we run this script
# mostly by cron wich not read it by itself
source /etc/profile
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '0' "$#" 'USER'
if [ ! -z "$user" ]; then
validate_format 'user'
is_object_valid 'user' 'USER' "$user"
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Creating user_list
if [ -z "$user" ]; then
user_list=$(ls $VESTA/data/users)
else
user_list="$user"
fi
# Reset overal statistics
TOTAL_IP_OWNED=0
TOTAL_U_DISK=0
TOTAL_U_DISK_DIRS=0
TOTAL_U_DISK_WEB=0
TOTAL_U_DISK_MAIL=0
TOTAL_U_DISK_DB=0
TOTAL_U_BANDWIDTH=0
TOTAL_U_WEB_DOMAINS=0
TOTAL_U_WEB_SSL=0
TOTAL_U_WEB_ALIASES=0
TOTAL_U_DNS_DOMAINS=0
TOTAL_U_DNS_RECORDS=0
TOTAL_U_MAIL_DOMAINS=0
TOTAL_U_MAIL_DKIM=0
TOTAL_U_MAIL_ACCOUNTS=0
TOTAL_U_DATABASES=0
TOTAL_U_CRON_JOBS=0
TOTAL_U_BACKUPS=0
# Updating user stats
for user in $user_list; do
USER_DATA=$VESTA/data/users/$user
source $USER_DATA/user.conf
next_month=$(date +'%m/01/%y' -d '+ 1 month')
DATE=$(date -d "$next_month -1day" +%F)
# Compiling report string
s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'"
s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'"
s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'"
s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'"
s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'"
s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'"
s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'"
s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'"
s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'"
s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'"
# Updating user stats log
stats="$USER_DATA/stats.log"
if [ -e "$stats" ]; then
# Checking dublicates
check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :)
if [ -z "$check_month" ]; then
# Updating as there no dublicates
echo "$s" >> $stats
chmod 660 $stats
else
# Replacing string with new data
sed -i "$check_month s/.*/$s/" $stats
fi
else
# Creating stats log
echo "$s" >$stats
chmod 660 $stats
fi
# Increase overall counters
TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED))
TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK))
TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS))
TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB))
TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL))
TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB))
TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH))
TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS))
TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL))
TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES))
TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS))
TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS))
TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS))
TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM))
TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS))
TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES))
TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS))
TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS))
done
# Updating overall stats
stats="$VESTA/data/users/admin/overall_stats.log"
s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'"
s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'"
s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'"
s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'"
s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'"
s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'"
s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'"
s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'"
s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS' U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'"
s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'"
s="$s U_DATABASES='$TOTAL_U_DATABASES'"
s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'"
if [ -e "$stats" ]; then
# Checking dublicates
check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :)
if [ -z "$check_month" ]; then
# Updating as there no dublicates
echo "$s" >> $stats
chmod 660 $stats
else
# Replacing string with new data
sed -i "$check_month s/.*/$s/" $stats
fi
else
# Creating stats log
echo "$s" >$stats
chmod 660 $stats
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$EVENT"
exit
>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d

View file

@ -48,24 +48,102 @@ is_dns_template_valid() {
is_domain_new() {
type="$1"
dom=${2-$domain}
web="$(grep -w $dom $VESTA/data/users/*/web.conf)"
dns="$(grep DOMAIN='$dom' $VESTA/data/users/*/dns.conf)"
mail="$(grep DOMAIN='$dom' $VESTA/data/users/*/mail.conf)"
if [ -n "$web" ] || [ -n "$dns" ] || [ -n "$mail" ]; then
if [ ! -z "$(grep -w $dom $USER_DATA/*.conf)" ]; then
c1=$(grep "'$dom'" $USER_DATA/$type.conf)
c2=$(grep "'$dom," $USER_DATA/$type.conf)
c3=$(grep ",$dom," $USER_DATA/$type.conf)
c4=$(grep ",$dom'" $USER_DATA/$type.conf)
web=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/web.conf)
dns=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf)
mail=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf)
if [ -n "$c1" ] || [ -n "$c2" ] || [ -n "$c3" ] || [ -n "$c4" ]
then
# Check web domain
if [ ! -z "$web" ] && [ "$type" == 'web' ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
else
if [ ! -z "$web" ]; then
web_user=$(echo "$web" |cut -f 7 -d /)
if [ "$web_user" != "$user" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
fi
# Check dns domain
if [ ! -z "$dns" ] && [ "$type" == 'dns' ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$dns" ]; then
dns_user=$(echo "$dns" |cut -f 7 -d /)
if [ "$dns_user" != "$user" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
fi
# Check mail domain
if [ ! -z "$mail" ] && [ "$type" == 'mail' ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$mail" ]; then
mail_user=$(echo "$mail" |cut -f 7 -d /)
if [ "$mail_user" != "$user" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
fi
# Check web aliases
web_alias=$(grep -w $dom $VESTA/data/users/*/web.conf)
if [ ! -z "$web_alias" ]; then
c1=$(grep "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
c2=$(grep "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
c3=$(grep ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
c4=$(grep ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
if [ ! -z "$c1" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c1" ] && [ "$c1" != "$user" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c2" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c2" ] && [ "$c2" != "$user" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c3" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c3" ] && [ "$c3" != "$user" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c4" ] && [ "$type" == "web" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
if [ ! -z "$c4" ] && [ "$c4" != "$user" ]; then
echo "Error: domain $dom exist"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS

View file

@ -556,7 +556,7 @@ validate_format_email() {
# Username
validate_format_username() {
if ! [[ "$1" =~ ^[a-zA-Z0-9]+([\.|_][a-zA-Z0-9]+)?$ ]]; then
if ! [[ "$1" =~ ^[a-zA-Z0-9]+([\.|_|-][a-zA-Z0-9]+)?$ ]]; then
echo "Error: $2 $1 is not valid"
log_event "$E_INVALID" "$EVENT"
exit $E_INVALID

View file

@ -56,9 +56,9 @@ acl_check_mail:
deny
condition = ${if eq{$sender_helo_name}{}}
message = HELO required before MAIL
drop
condition = ${if isip{$sender_helo_name}}
message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
# drop
# condition = ${if isip{$sender_helo_name}}
# message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
@ -70,11 +70,11 @@ acl_check_mail:
drop
condition = ${if isip{$sender_helo_name}}
message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
drop
condition = ${if match{$sender_helo_name}{\N\.$\N}}
message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
drop message = "REJECTED - Bad HELO - Host impersonating [$sender_helo_name]"
condition = ${if match{$sender_helo_name}{$primary_hostname}}
# drop
# condition = ${if match{$sender_helo_name}{\N\.$\N}}
# message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
# drop message = "REJECTED - Bad HELO - Host impersonating [$sender_helo_name]"
# condition = ${if match{$sender_helo_name}{$primary_hostname}}
drop condition = ${if eq{[$interface_address]}{$sender_helo_name}}
message = $interface_address is _my_ address
accept

View file

@ -1,3 +1,4 @@
<<<<<<< HEAD
<?php
/**
@ -52,3 +53,65 @@ class rcube_vesta_password
}
}
=======
<?php
/**
* Vesta Control Panel Password Driver
*
* @version 1.0
* @author Serghey Rodin <skid@vestacp.com>
*/
class rcube_vesta_password
{
function save($curpass, $passwd)
{
$rcmail = rcmail::get_instance();
$vesta_host = $rcmail->config->get('password_vesta_host');
if (empty($vesta_host))
{
$vesta_host = 'localhost';
}
$vesta_port = $rcmail->config->get('password_vesta_port');
if (empty($vesta_port))
{
$vesta_port = '8083';
}
$postvars = array(
'email' => $_SESSION['username'],
'password' => $curpass,
'new' => $passwd
);
$postdata = http_build_query($postvars);
$send = 'POST /reset/mail/ HTTP/1.1' . PHP_EOL;
$send .= 'Host: ' . $vesta_host . PHP_EOL;
$send .= 'User-Agent: PHP Script' . PHP_EOL;
$send .= 'Content-length: ' . strlen($postdata) . PHP_EOL;
$send .= 'Content-type: application/x-www-form-urlencoded' . PHP_EOL;
$send .= 'Connection: close' . PHP_EOL;
$send .= PHP_EOL;
$send .= $postdata . PHP_EOL . PHP_EOL;
$fp = fsockopen('ssl://' . $vesta_host, $vesta_port);
fputs($fp, $send);
$result = fread($fp, 2048);
fclose($fp);
if(strpos($result, 'ok') && !strpos($html, 'error'))
{
return PASSWORD_SUCCESS;
}
else {
return PASSWORD_ERROR;
}
}
}
>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d

View file

@ -1,3 +1,4 @@
<<<<<<< HEAD
#!/bin/bash
# Vesta installer
@ -636,3 +637,652 @@ cd
bash
# EOF
=======
#!/bin/bash
# Vesta installer
# Define Variables
RHOST='r.vestacp.com'
CHOST='c.vestacp.com'
REPO='cmmnt'
VERSION='0.9.7'
YUM_REPO='/etc/yum.repos.d/vesta.repo'
arch=$(uname -i)
tools="screen mc libpng libjpeg curl libmcrypt mhash zip unzip freetype ntp
openssl flex libxml2 ImageMagick sqlite pcre sudo bc jwhois mailx lsof
tar telnet rsync"
rpms="nginx httpd mod_ssl mod_ruid2 mod_extract_forwarded mod_fcgid ftp
webalizer awstats mysql mysql-server php php-bcmath php-cli php-common
php-gd php-imap php-mbstring php-mcrypt php-mysql php-pdo php-soap php-tidy
php-xml php-xmlrpc phpMyAdmin exim dovecot clamd spamassassin roundcubemail
bind bind-utils bind-libs vsftpd rrdtool GeoIP vesta vesta-nginx vesta-php"
# Am I root?
if [ "x$(id -u)" != 'x0' ]; then
echo 'Error: this script can only be executed by root'
exit 1
fi
# Check supported version
if [ ! -e '/etc/redhat-release' ]; then
echo 'Error: sorry, we currently support RHEL and CentOS only'
exit 1
fi
os=$(cut -f 1 -d ' ' /etc/redhat-release)
if [ $os != 'CentOS' ] && [ $os != 'Red' ]; then
echo 'Error: sorry, we currently support RHEL and CentOS only'
fi
release=$(grep -o "[0-9]" /etc/redhat-release |head -n1)
help() {
echo "usage: $0 [OPTIONS]
-d, --disable-remi Disable remi
-e, --email Define email address
-h, --help Print this help and exit
-f, --force Force installation"
exit 1
}
# Translating argument to --gnu-long-options
for arg; do
delim=""
case "$arg" in
--help) args="${args}-h " ;;
--disable-remi) args="${args}-d " ;;
--force) args="${args}-f " ;;
--email) args="${args}-e " ;;
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
args="${args}${delim}${arg}${delim} ";;
esac
done
eval set -- "$args"
# Getopt
while getopts "dhfe:" Option; do
case $Option in
d) disable_remi='yes' ;; # Disable remi repo
h) help ;; # Help
e) email=$OPTARG ;; # Contact email
f) force=yes ;; # Force install
*) help ;; # Default
esac
done
# Are you sure ?
if [ -z $email ]; then
echo
echo
echo
echo
echo
echo ' ***********************************************************'
echo
echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| '
echo ' _| _| _| _| _| _| _| '
echo ' _| _| _|_|_| _|_| _| _|_|_|_| '
echo ' _| _| _| _| _| _| _| '
echo ' _| _|_|_|_| _|_|_| _| _| _| '
echo
echo
echo
echo
echo
echo
echo
echo
echo ' ***********************************************************'
echo
echo
read -n 1 -p 'Do you want to install Vesta Control Panel? [y/n]): ' answer
if [ "$answer" != 'y' ] && [ "$answer" != 'Y' ]; then
echo 'Goodbye'
exit 1
fi
echo
# Check email
read -p 'Please enter valid email address: ' email
fi
# Validate email
local_part=$(echo $email | cut -s -f1 -d\@)
remote_host=$(echo $email | cut -s -f2 -d\@)
mx_failed=1
if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then
/usr/bin/host -t mx "$remote_host" &> /dev/null
mx_failed="$?"
fi
if [ "$mx_failed" -eq 1 ]; then
echo "Error: email $email is not valid"
exit 1
fi
echo
echo
echo
echo
echo 'Installation will take about 15 minutes ...'
echo
sleep 2
# Check wget
if [ ! -e '/usr/bin/wget' ]; then
yum -y install wget
if [ $? -ne 0 ]; then
echo "Error: can't install wget"
exit 1
fi
fi
# Check repo availability
wget "$RHOST/$REPO/vesta.conf" -O /dev/null
if [ $? -ne 0 ]; then
echo "Error: no access to $REPO repository"
exit 1
fi
# Check installed packages
tmpfile=$(mktemp -p /tmp)
rpm -qa > $tmpfile
for rpm in $rpms; do
if [ ! -z "$(grep ^$rpm. $tmpfile)" ]; then
conflicts="$rpm $conflicts"
fi
done
rm -f $tmpfile
if [ ! -z "$conflicts" ] && [ -z "$force" ]; then
echo
echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
echo
echo 'Following rpm packages aleady installed:'
echo "$conflicts"
echo
echo 'It is highly recommended to remove them before proceeding.'
echo
echo 'If you want to force installation run this script with -f option:'
echo "Example: bash $0 --force"
echo
echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
echo
exit 1
fi
# Password generator
gen_pass() {
MATRIX='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
LENGTH=10
while [ ${n:=1} -le $LENGTH ]; do
PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
let n+=1
done
echo "$PASS"
}
# Update system
yum -y update
if [ $? -ne 0 ]; then
echo 'Error: yum update failed'
exit 1
fi
# Install additional packages
yum -y install $tools
if [ $? -ne 0 ]; then
echo 'Error: yum install failed'
exit 1
fi
# Install EPEL repo
if [ ! -e '/etc/yum.repos.d/epel.repo' ]; then
if [ "$release" -eq '5' ]; then
epel="5/$arch/epel-release-5-4.noarch.rpm"
fi
if [ "$release" -eq '6' ]; then
epel="6/$arch/epel-release-6-8.noarch.rpm"
fi
rpm -ivh http://dl.fedoraproject.org/pub/epel/$epel
if [ $? -ne 0 ]; then
echo "Error: can't install EPEL repository"
exit 1
fi
fi
# Install remi repo
if [ ! -e '/etc/yum.repos.d/remi.repo' ]; then
if [ "$release" -eq '5' ]; then
remi="remi-release-5.rpm"
fi
if [ "$release" -eq '6' ]; then
remi="remi-release-6.rpm"
fi
rpm -ivh http://rpms.famillecollet.com/enterprise/$remi
if [ $? -ne 0 ]; then
echo "Error: can't install remi repository"
exit 1
fi
fi
# Install vesta repo
echo "[vesta]
name=Vesta - $REPO
baseurl=http://$RHOST/$REPO/$release/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA" > $YUM_REPO
wget $CHOST/GPG.txt -O /etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA
# Checking if old MySQL stuff exists
if [ -e '/var/lib/mysql' ]; then
mv -f /var/lib/mysql /var/lib/mysql_old
fi
if [ -e '/etc/my.cnf' ]; then
mv -f /etc/my.cnf /etc/my.cnf_old
fi
if [ -e '/root/.my.cnf' ]; then
mv -f /root/.my.cnf
fi
# Install Vesta packages
if [ -z "$disable_remi" ]; then
yum -y --enablerepo=remi install $rpms
else
yum -y install $rpms
fi
if [ $? -ne 0 ]; then
echo 'Error: yum install failed'
exit 1
fi
# Configuring run levels
chkconfig iptables off
if [ -e /etc/init.d/sendmail ]; then
chkconfig sendmail off
fi
if [ -e /etc/init.d/postfix ]; then
chkconfig postfix off
fi
chkconfig vesta on
chkconfig httpd on
chkconfig nginx on
chkconfig mysqld on
chkconfig vsftpd on
chkconfig named on
chkconfig exim on
chkconfig clamd on
chkconfig spamassassin on
chkconfig dovecot on
# Make dirs more visible
echo 'LS_COLORS="$LS_COLORS:di=00;33"' >> /etc/profile
# Vesta does not support SELINUX for now
if [ -e '/etc/sysconfig/selinux' ]; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
setenforce 0
fi
if [ -e '/etc/selinux/config' ]; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
fi
# Vesta use own webalizer routine
rm -f /etc/cron.daily/00webalizer
# NTP Synchronization
echo '#!/bin/sh' > /etc/cron.daily/ntpdate
echo "$(which ntpdate) -s pool.ntp.org" >> /etc/cron.daily/ntpdate
chmod 775 /etc/cron.daily/ntpdate
ntpdate -s pool.ntp.org
# Vesta Environment
echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
chmod 755 /etc/profile.d/vesta.sh
source /etc/profile.d/vesta.sh
echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
echo 'export PATH' >> /root/.bash_profile
source /root/.bash_profile
mkdir -p $VESTA/conf
mkdir -p $VESTA/log
mkdir -p $VESTA/data
mkdir -p $VESTA/ssl
chmod 770 $VESTA/conf
# Make backup directory
vst_backups="/root/vst_install_backups/$(date +%s)"
mkdir -p $vst_backups
mkdir -p $vst_backups/nginx
mkdir -p $vst_backups/httpd
mkdir -p $vst_backups/mysql
mkdir -p $vst_backups/exim
mkdir -p $vst_backups/dovecot
mkdir -p $vst_backups/clamd
mkdir -p $vst_backups/vsftpd
mkdir -p $vst_backups/named
wget $RHOST/$REPO/vesta.conf -O $VESTA/conf/vesta.conf
if [ -e '/etc/sudoers' ]; then
mv /etc/sudoers $vst_backups/
fi
wget $CHOST/$VERSION/sudoers.conf -O /etc/sudoers
chmod 0440 /etc/sudoers
wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
sed -i "s/umask 022/umask 002/g" /etc/profile
# Create backup directory
adduser backup
ln -s /home/backup /backup
chmod a+x /backup
# Configuring data templates
cd /usr/local/vesta/data
mkdir ips
mkdir queue
mkdir users
touch queue/backup.pipe
touch queue/disk.pipe
touch queue/webstats.pipe
touch queue/restart.pipe
touch queue/traffic.pipe
chmod 750 users
chmod 750 ips
chmod -R 750 queue
wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
tar -xzf packages.tar.gz
rm -f packages.tar.gz
cd /usr/local/vesta/data
wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
tar -xzf templates.tar.gz
rm -f templates.tar.gz
chmod -R 755 /usr/local/vesta/data/templates
cp templates/web/skel/public_html/index.html /var/www/html/
sed -i 's/%domain%/It worked!/g' /var/www/html/index.html
# Configuring ssl keys
cd /usr/local/vesta/ssl
wget $CHOST/$VERSION/certificate.crt -O certificate.crt
wget $CHOST/$VERSION/certificate.key -O certificate.key
# Adding admin user
vpass=$(gen_pass)
$VESTA/bin/v-add-user admin $vpass $email default System Administrator
if [ $? -ne 0 ]; then
echo "Error: can't create admin user"
exit 1
fi
# Set shell
$VESTA/bin/v-change-user-shell admin bash
# Apache
if [ -e '/etc/httpd/conf/httpd.conf' ]; then
mv /etc/httpd/conf/httpd.conf $vst_backups/httpd/
fi
if [ -e '/etc/httpd/conf.d/ssl.conf' ]; then
mv /etc/httpd/conf.d/ssl.conf $vst_backups/httpd/
fi
if [ -e '/etc/httpd/conf.d/proxy_ajp.conf' ]; then
mv /etc/httpd/conf.d/proxy_ajp.conf $vst_backups/httpd/
fi
wget $CHOST/$VERSION/httpd.conf -O /etc/httpd/conf/httpd.conf
wget $CHOST/$VERSION/httpd-status.conf -O /etc/httpd/conf.d/status.conf
wget $CHOST/$VERSION/httpd-ssl.conf -O /etc/httpd/conf.d/ssl.conf
wget $CHOST/$VERSION/httpd.log -O /etc/logrotate.d/httpd
echo "MEFaccept 127.0.0.1" >> /etc/httpd/conf.d/mod_extract_forwarded.conf
echo > /etc/httpd/conf.d/proxy_ajp.conf
echo > /etc/httpd/conf.d/vesta.conf
touch /var/log/httpd/access_log
touch /var/log/httpd/error_log
touch /var/log/httpd/suexec.log
mkdir -p /var/log/httpd/domains
chmod a+x /var/log/httpd
chmod 640 /var/log/httpd/access_log
chmod 640 /var/log/httpd/error_log
chmod 640 /var/log/httpd/suexec.log
chmod 751 /var/log/httpd/domains
# Nginx
if [ -e '/etc/nginx/nginx.conf' ]; then
mv /etc/nginx/nginx.conf $vst_backups/nginx/
fi
if [ -f '/etc/nginx/conf.d/default.conf' ]; then
mv /etc/nginx/conf.d/default.conf $vst_backups/nginx/
fi
if [ -e '/etc/nginx/conf.d/example_ssl.conf' ]; then
mv /etc/nginx/conf.d/example_ssl.conf $vst_backups/nginx/
fi
wget $CHOST/$VERSION/nginx.conf -O /etc/nginx/nginx.conf
wget $CHOST/$VERSION/nginx-status.conf -O /etc/nginx/conf.d/status.conf
touch /etc/nginx/conf.d/vesta_ip.conf
touch /etc/nginx/conf.d/vesta_users.conf
# VsFTP
if [ -e '/etc/vsftpd/vsftpd.conf' ]; then
mv /etc/vsftpd/vsftpd.conf $vst_backups/vsftpd/
fi
wget $CHOST/$VERSION/vsftpd.conf -O /etc/vsftpd/vsftpd.conf
# MySQL
if [ -e '/etc/my.cnf' ]; then
mv /etc/my.cnf $vst_backups/mysql/
fi
if [ -e '/root/.my.cnf' ]; then
mv /root/.my.cnf $vst_backups/mysql/
fi
mpass=$(gen_pass)
server_memory="$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])"
if [ "$server_memory" -gt '1000000' ]; then
wget $CHOST/$VERSION/mysql.cnf -O /etc/my.cnf
else
wget $CHOST/$VERSION/mysql-512.cnf -O /etc/my.cnf
fi
service mysqld start
mysqladmin -u root password $mpass
echo -e "[client]\npassword='$mpass'\n" >/root/.my.cnf
$VESTA/bin/v-add-database-server mysql localhost 3306 root $mpass
$VESTA/bin/v-add-database admin default default $(gen_pass) mysql
# Bind
if [ -e '/etc/named.conf' ]; then
mv /etc/named.conf $vst_backups/named/
fi
wget $CHOST/$VERSION/named.conf -O /etc/named.conf
chown root:named /etc/named.conf
chmod 640 /etc/named.conf
# Exim
if [ -e '/etc/exim/exim.conf' ]; then
mv /etc/exim/exim.conf $vst_backups/exim/
fi
if [ -e '/etc/clamd.conf' ]; then
mv /etc/clamd.conf $vst_backups/clamd/
fi
wget $CHOST/$VERSION/exim.conf -O /etc/exim/exim.conf
wget $CHOST/$VERSION/dnsbl.conf -O /etc/exim/dnsbl.conf
wget $CHOST/$VERSION/spam-blocks.conf -O /etc/exim/spam-blocks.conf
wget $CHOST/$VERSION/clamd.conf -O /etc/clamd.conf
mkdir /etc/exim/domains
chmod 640 /etc/exim/exim.conf
gpasswd -a clam exim
gpasswd -a exim mail
gpasswd -a clam mail
gpasswd -a dovecot mail
/usr/bin/freshclam
# Dovecot config
if [ "$release" -eq '5' ]; then
if -e [ '/etc/dovecot.conf' ]; then
mv /etc/dovecot.conf $vst_backups/dovecot/
fi
wget $CHOST/$VERSION/dovecot.conf -O /etc/dovecot.conf
else
if [ -e '/etc/dovecot' ]; then
mv /etc/dovecot/* $vst_backups/dovecot/
fi
wget $CHOST/$VERSION/dovecot.tar.gz -O /etc/dovecot.tar.gz
cd /etc/
tar -xzf dovecot.tar.gz
rm -f dovecot.tar.gz
fi
# PMA
wget $CHOST/$VERSION/httpd-pma.conf -O /etc/httpd/conf.d/phpMyAdmin.conf
wget $CHOST/$VERSION/pma.conf -O /etc/phpMyAdmin/config.inc.php
sed -i "s/%blowfish_secret%/$(gen_pass)/g" /etc/phpMyAdmin/config.inc.php
# Roundcube setup
wget $CHOST/$VERSION/httpd-webmail.conf -O /etc/httpd/conf.d/roundcubemail.conf
wget $CHOST/$VERSION/roundcube-main.conf -O /etc/roundcubemail/main.inc.php
wget $CHOST/$VERSION/roundcube-db.conf -O /etc/roundcubemail/db.inc.php
wget $CHOST/$VERSION/roundcube-driver.php -O /usr/share/roundcubemail/plugins/password/vesta.php
wget $CHOST/$VERSION/roundcube-pw.conf -O /usr/share/roundcubemail/plugins/password/config.inc.php
r="$(gen_pass)"
mysql -e "CREATE DATABASE roundcube"
mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'"
sed -i "s/%password%/$r/g" /etc/roundcubemail/db.inc.php
mysql roundcube < /usr/share/doc/roundcubemail-*/SQL/mysql.initial.sql
# Configuring ip
$VESTA/bin/v-update-sys-ip
# Get main ip
main_ip=$(ifconfig |grep 'inet addr:' |grep -v 127.0.0.1 |head -n1 |\
cut -f2 -d: | cut -f1 -d ' ')
# Add default web domain on main ip
$VESTA/bin/v-add-web-domain admin default.domain $main_ip
# Add default dns domain on main ip
$VESTA/bin/v-add-dns-domain admin default.domain $main_ip
# Add default mail domain
$VESTA/bin/v-add-mail-domain admin default.domain
# Configuring crond
command='sudo /usr/local/vesta/bin/v-update-sys-queue disk'
$VESTA/bin/v-add-cron-job 'admin' '15' '02' '*' '*' '*' "$command"
command='sudo /usr/local/vesta/bin/v-update-sys-queue traffic'
$VESTA/bin/v-add-cron-job 'admin' '10' '00' '*' '*' '*' "$command"
command='sudo /usr/local/vesta/bin/v-update-sys-queue webstats'
$VESTA/bin/v-add-cron-job 'admin' '30' '03' '*' '*' '*' "$command"
command='sudo /usr/local/vesta/bin/v-update-sys-queue backup'
$VESTA/bin/v-add-cron-job 'admin' '*/30' '*' '*' '*' '*' "$command"
command='sudo /usr/local/vesta/bin/v-backup-users'
$VESTA/bin/v-add-cron-job 'admin' '10' '05' '*' '*' '*' "$command"
command='sudo /usr/local/vesta/bin/v-update-user-stats'
$VESTA/bin/v-add-cron-job 'admin' '20' '00' '01' '*' '*' "$command"
command='sudo /usr/local/vesta/bin/v-update-sys-rrd'
$VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
# Creating symlink
ln -s /usr/local/vesta/log /var/log/vesta
# Stop unused services
services='iptables sendmail postfix'
for srv in $services; do
service $srv status > /dev/null
if [ $? -eq 0 ]; then
service $srv stop
fi
done
# Start system service
services='vesta httpd nginx vsftpd exim dovecot clamd spamassassin named crond'
for srv in $services; do
service $srv status > /dev/null
if [ $? -gt 0 ]; then
service $srv start
else
service $srv restart
fi
done
# Change sendmail client
rm -f /etc/alternatives/mta
ln -s /usr/sbin/sendmail.exim /etc/alternatives/mta
# Build inititall rrd images
$VESTA/bin/v-update-sys-rrd
# Send notification to vestacp.com
wget vestacp.com/notify/?$REPO -O /dev/null
# Get server ip
vst_ip=$(wget vestacp.com/what-is-my-ip/ -O - 2>/dev/null)
if [ ! -z "$vst_ip" ] && [ "$vst_ip" != "$main_ip" ]; then
# Assign passive ip address
echo "pasv_address=$vst_ip" >> /etc/vsftpd/vsftpd.conf
fi
if [ -z "$vst_ip" ]; then
vst_ip=$main_ip
fi
# Send email
echo -e "Congratulations, you have just successfully installed \
the Vesta Control Panel
You can login in Vesta with following credentials:
username: admin
password: $vpass
https://$vst_ip:8083
We hope that you enjoy your installation of Vesta. Please \
feel free to contact us anytime if you have any questions.
Thank you.
--
Sincerely yours
vestacp.com team
" > $tmpfile
cat $tmpfile | mail -s "Vesta Control Panel" $email
rm -f $tmpfile
# Congrats
echo
echo
echo ' ***********************************************************'
echo
echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| '
echo ' _| _| _| _| _| _| _| '
echo ' _| _| _|_|_| _|_| _| _|_|_|_| '
echo ' _| _| _| _| _| _| _| '
echo ' _| _|_|_|_| _|_|_| _| _| _| '
echo
echo ' Congratulations, you have just successfully installed'
echo ' the Vesta Control Panel!'
echo
echo ' Now you can login in Vesta with following credentials:'
echo ' username: admin'
echo " password: $vpass"
echo " https://$vst_ip:8083/"
echo
echo
echo ' Thank you for using our product.'
echo
echo ' ***********************************************************'
echo
echo
# Tricky way to get new PATH variable
cd
bash
# EOF
>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d

View file

@ -29,6 +29,8 @@ top_panel($user,$TAB);
$v_type = $_POST['v_type'];
$v_charset = $_POST['v_charset'];
if (empty($_POST['v_notify'])) $v_notify = 'off';
// Check for errors
if (!empty($errors[0])) {
foreach ($errors as $i => $error) {
@ -53,6 +55,21 @@ top_panel($user,$TAB);
unset($v_password);
unset($output);
} else {
if (empty($v_notify)) {
list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]);
if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/";
if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/";
$to = $panel[$user]['CONTACT'];
$subject = _("Database Credentials");
$hostname = exec('hostname');
$from = _('MAIL_FROM',$hostname);
$mailtext = _('DATABASE_READY',$panel[$user]['FNAME'],$panel[$user]['LNAME'],$_POST['v_type'],$user,$_POST['v_database'],$user,$_POST['v_dbuser'],$_POST['v_password']);
$mailtext .= $db_admin_link."\n\n";
$mailtext .= "--\n"._('Vesta Control Panel')."\n";
send_email($to, $subject, $mailtext, $from);
}
$_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']);
unset($v_database);
unset($v_dbuser);

View file

@ -505,7 +505,7 @@ top_panel($user,$TAB);
$_SESSION['error_msg'] = $error;
}
unset($output);
$v_ftp_user = $user."_".$_POST['v_ftp_user'];
$v_ftp_user = $_POST['v_ftp_user'];
$v_ftp_password = "••••••••";
}
}
@ -538,7 +538,7 @@ top_panel($user,$TAB);
$subject = _("FTP login credentials");
$hostname = exec('hostname');
$from = _('MAIL_FROM',$hostname);
$mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user,$_POST['v_ftp_user'],$_POST['v_ftp_password']);
$mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user."_".$_POST['v_ftp_user'],$_POST['v_ftp_password']);
send_email($to, $subject, $mailtext, $from);
unset($v_ftp_email);
}

View file

@ -147,5 +147,8 @@ $LANG = array(
'Reset Code'=>'Код сброса',
'disk'=>'Место',
'traffic'=>'Трафик',
'Database Credentials'=>'Данные для доступа к БД',
'DATABASE_READY'=>"Здравствуйте %s %s,\nВаша %s база данных создана успешно.\n\nИмя БД: %s_%s\nПользователь: %s_%s\nПароль: %s\n\n",
'Send credentials to'=>'Отправить данные для доступа к '
);

View file

@ -1,4 +1,3 @@
<?php
$back = $_SESSION['back'];
if (empty($back)) {
@ -118,7 +117,7 @@
</tr>
<tr>
<td class="vst-text" style="padding: 10 0 0 2px;">
<?php print _('Кодировка');?>
<?php print _('Charset');?>
</td>
</tr>
<tr>
@ -162,6 +161,15 @@
<option value=eucjpms <?php if ((!empty($v_charset)) && ( $v_charset == 'eucjpms')) echo 'selected';?> >eucjpms</option>
</select>
</td>
<tr>
<td class="vst-text" style="padding: 10px 0 0 2px;">
<?php print _('Send credentials to'); echo $panel[$user]['CONTACT'] ?>
</td>
</tr>
<tr>
<td>
<input type="checkbox" size="20" class="vst-checkbox" name="v_notify" <?php if (empty($v_notify)) echo "checked=yes"; ?>>
</td>
</tr>
<tr>
<td style="padding: 24px 0 0 0;">

View file

@ -54,7 +54,7 @@
<table width="830px">
<tr>
<td></td>
<td class="data-controls" width="96px"><a href="/list/dns/?domain=<?php echo $key ?>"><img src="/images/more.png" width="8px" height="8px"> list records</a></td>
<td class="data-controls" width="108px"><a href="/list/dns/?domain=<?php echo $key ?>"><img src="/images/more.png" width="8px" height="8px"> list <?php echo $data[$key]['RECORDS'] ?> records</a></td>
<td class="data-controls" width="92px"><a href="/add/dns/?domain=<?php echo $key ?>"><img src="/images/add.png" width="8px" height="8px"> add record</a></td>
<td class="data-controls" width="50px"><a href="/edit/dns/?domain=<?php echo $key ?>"><img src="/images/edit.png" width="8px" height="8px"> edit</a></td>
<td class="data-controls do_<?php echo $spnd_action ?>" width="80px">
@ -144,4 +144,3 @@
</tr>
</table>
</div>

View file

@ -1,4 +1,3 @@
<table class="sub-menu" style="background: white;">
<tr>
<td style="padding: 12px 0 8px 6px">
@ -30,6 +29,15 @@
</table>
<div id="vstobjects">
<div style="height:10px; font-size:0;"></div>
<table class="data" style="background: #ebe9dc;">
<tr>
<td style="padding: 8px 2px 8px 0;">
<a class="name" style="color: #555; font-size: 10pt;"><b>Listing <?php echo $_GET['domain'] ?></b></a>
</td>
</tr>
</table>
<div style="height:10px; font-size:0;"></div>
<table class="data">
<?php
foreach ($data as $key => $value) {

View file

@ -58,7 +58,7 @@
<table width="830px">
<tr>
<td></td>
<td class="data-controls" width="100px"><a href="?domain=<?php echo $key ?>"><img src="/images/more.png" width="8px" height="8px"> list accounts</a></td>
<td class="data-controls" width="112px"><a href="?domain=<?php echo $key ?>"><img src="/images/more.png" width="8px" height="8px"> list <?php echo $data[$key]['ACCOUNTS'] ?> accounts</a></td>
<td class="data-controls" width="98px"><a href="/add/mail/?domain=<?php echo $key ?>"><img src="/images/add.png" width="8px" height="8px"> add account</a></td>
<td class="data-controls" width="104px"><a href="<?php echo "http://".$http_host."/webmail/"; ?>" target="_blank"><img src="/images/new_window.png" width="8px" height="8px"> open webmail</a></td>
<td class="data-controls" width="50px"><a href="/edit/mail/?domain=<?php echo $key ?>"><img src="/images/edit.png" width="8px" height="8px"> edit</a></td>

View file

@ -1,4 +1,3 @@
<table class="sub-menu" style="background: white;">
<tr>
<td style="padding: 12px 0 8px 6px">
@ -30,6 +29,15 @@
</table>
<div id="vstobjects">
<div style="height:10px; font-size:0;"></div>
<table class="data" style="background: #ebe9dc;">
<tr>
<td style="padding: 8px 2px 8px 0;">
<a class="name" style="color: #555; font-size: 10pt;"><b>Listing <?php echo $_GET['domain'] ?></b></a>
</td>
</tr>
</table>
<div style="height:10px; font-size:0;"></div>
<table class="data">
<?php
foreach ($data as $key => $value) {
@ -152,4 +160,3 @@
</tr>
</table>
</div>

View file

@ -34,7 +34,7 @@
.top {
background: #555;
background: #444;
color: #cce4f0;
padding: 0;
margin-left: auto;
@ -85,14 +85,10 @@
.nav-lnk {
text-decoration: none;
color: #555;
color: #444;
float:left;
}
.nav-lnk:hover {
color: #333;
}
.nav-lnk:active {
color: #ccc;
}
@ -372,24 +368,24 @@
}
.username {
color: #555555;
color: #555;
font-size: 16pt;
line-height: 1.2em;
}
.domain {
color: #555555;
color: #555;
font-size: 16pt;
line-height: 0.8em;
}
.cron {
color: #555555;
color: #555;
font-size: 18px;
}
.log {
color: #555555;
color: #555;
font-size: 12pt;
}
@ -477,6 +473,7 @@
}
.vst-text {
color: #333;
font-size: 12pt;
}
@ -484,7 +481,7 @@
background-color: #FFFFFF;
border: 1px solid #999999;
border-radius: 3px 3px 3px 3px;
color: #555555;
color: #555;
font-size: 18px;
padding: 6px;
width: 360px;
@ -503,7 +500,7 @@
background-color: #FFFFFF;
border: 1px solid #999999;
border-radius: 3px 3px 3px 3px;
color: #555555;
color: #555;
font-size: 14pt;
padding: 6px;
width: 360px;

View file

@ -52,7 +52,7 @@
<table width="830px">
<tr>
<td></td>
<td class="data-controls" width="96px"><a href="/list/dns/?domain=<?php echo $key ?>"><img src="/images/more.png" width="8px" height="8px"> list records</a></td>
<td class="data-controls" width="108px"><a href="/list/dns/?domain=<?php echo $key ?>"><img src="/images/more.png" width="8px" height="8px"> list <?php echo $data[$key]['RECORDS'] ?> records</a></td>
<td class="data-controls" width="92px"><a href="/add/dns/?domain=<?php echo $key ?>"><img src="/images/add.png" width="8px" height="8px"> add record</a></td>
<td class="data-controls" width="50px"><a href="/edit/dns/?domain=<?php echo $key ?>"><img src="/images/edit.png" width="8px" height="8px"> edit</a></td>
<td class="data-controls do_delete" width="70px">
@ -134,4 +134,3 @@
</tr>
</table>
</div>

View file

@ -1,4 +1,3 @@
<table class="sub-menu" style="background: white;">
<tr>
<td style="padding: 12px 0 8px 6px">
@ -28,6 +27,15 @@
</table>
<div id="vstobjects">
<div style="height:10px; font-size:0;"></div>
<table class="data" style="background: #ebe9dc;">
<tr>
<td style="padding: 8px 2px 8px 0;">
<a class="name" style="color: #555; font-size: 10pt;"><b>Listing <?php echo $_GET['domain'] ?></b></a>
</td>
</tr>
</table>
<div style="height:10px; font-size:0;"></div>
<table class="data">
<?php
foreach ($data as $key => $value) {
@ -95,4 +103,3 @@
</tr>
</table>
</div>

View file

@ -56,7 +56,7 @@
<table width="830px">
<tr>
<td></td>
<td class="data-controls" width="100px"><a href="?domain=<?php echo $key ?>"><img src="/images/more.png" width="8px" height="8px"> list accounts</a></td>
<td class="data-controls" width="112px"><a href="?domain=<?php echo $key ?>"><img src="/images/more.png" width="8px" height="8px"> list <?php echo $data[$key]['ACCOUNTS'] ?> accounts</a></td>
<td class="data-controls" width="98px"><a href="/add/mail/?domain=<?php echo $key ?>"><img src="/images/add.png" width="8px" height="8px"> add account</a></td>
<td class="data-controls" width="104px"><a href="<?php echo "http://".$http_host."/webmail/"; ?>" target="_blank"><img src="/images/new_window.png" width="8px" height="8px"> open webmail</a></td>
<td class="data-controls" width="50px"><a href="/edit/mail/?domain=<?php echo $key ?>"><img src="/images/edit.png" width="8px" height="8px"> edit</a></td>
@ -161,4 +161,3 @@
</tr>
</table>
</div>

View file

@ -1,4 +1,3 @@
<table class="sub-menu" style="background: white;">
<tr>
<td style="padding: 12px 0 8px 6px">
@ -28,6 +27,15 @@
</table>
<div id="vstobjects">
<div style="height:10px; font-size:0;"></div>
<table class="data" style="background: #ebe9dc;">
<tr>
<td style="padding: 8px 2px 8px 0;">
<a class="name" style="color: #555; font-size: 10pt;"><b>Listing <?php echo $_GET['domain'] ?></b></a>
</td>
</tr>
</table>
<div style="height:10px; font-size:0;"></div>
<table class="data">
<?php
foreach ($data as $key => $value) {
@ -142,4 +150,3 @@
</tr>
</table>
</div>