unlimitted hosting packages

This commit is contained in:
Serghey Rodin 2015-02-17 18:25:50 +02:00
commit 61288a2355
6 changed files with 108 additions and 41 deletions

View file

@ -29,16 +29,39 @@ is_package_new() {
is_package_consistent() { is_package_consistent() {
source $pkg_dir/$package.pkg source $pkg_dir/$package.pkg
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
validate_format_int $WEB_DOMAINS 'WEB_DOMAINS' validate_format_int $WEB_DOMAINS 'WEB_DOMAINS'
fi
if [ "$WEB_ALIASES" != 'unlimited' ]; then
validate_format_int $WEB_ALIASES 'WEB_ALIASES' validate_format_int $WEB_ALIASES 'WEB_ALIASES'
fi
if [ "$DNS_DOMAINS" != 'unlimited' ]; then
validate_format_int $DNS_DOMAINS 'DNS_DOMAINS' validate_format_int $DNS_DOMAINS 'DNS_DOMAINS'
fi
if [ "$DNS_RECORDS" != 'unlimited' ]; then
validate_format_int $DNS_RECORDS 'DNS_RECORDS' validate_format_int $DNS_RECORDS 'DNS_RECORDS'
fi
if [ "$MAIL_DOMAINS" != 'unlimited' ]; then
validate_format_int $MAIL_DOMAINS 'MAIL_DOMAINS' validate_format_int $MAIL_DOMAINS 'MAIL_DOMAINS'
fi
if [ "$MAIL_ACCOUNTS" != 'unlimited' ]; then
validate_format_int $MAIL_ACCOUNTS 'MAIL_ACCOUNTS' validate_format_int $MAIL_ACCOUNTS 'MAIL_ACCOUNTS'
fi
if [ "$DATABASES" != 'unlimited' ]; then
validate_format_int $DATABASES 'DATABASES' validate_format_int $DATABASES 'DATABASES'
fi
if [ "$CRON_JOBS" != 'unlimited' ]; then
validate_format_int $CRON_JOBS 'CRON_JOBS' validate_format_int $CRON_JOBS 'CRON_JOBS'
fi
if [ "$DISK_QUOTA" != 'unlimited' ]; then
validate_format_int $DISK_QUOTA 'DISK_QUOTA' validate_format_int $DISK_QUOTA 'DISK_QUOTA'
fi
if [ "$BANDWIDTH" != 'unlimited' ]; then
validate_format_int $BANDWIDTH 'BANDWIDTH'
fi
if [ "$BACKUPS" != 'unlimited' ]; then
validate_format_int $BACKUPS 'BACKUPS' validate_format_int $BACKUPS 'BACKUPS'
fi
validate_format_shell $SHELL validate_format_shell $SHELL
} }

View file

@ -19,7 +19,7 @@ source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
is_package_avalable() { is_package_avalable() {
# Parsing user data
usr_data=$(cat $USER_DATA/user.conf) usr_data=$(cat $USER_DATA/user.conf)
IFS=$'\n' IFS=$'\n'
for key in $usr_data; do for key in $usr_data; do
@ -37,18 +37,56 @@ is_package_avalable() {
grep -v DATE) grep -v DATE)
eval $pkg_data eval $pkg_data
# Comparing user data with package # Checking usage agains package limits
if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\ if [ "$WEB_DOMAINS" != 'unlimited' ]; then
[[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\ if [ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]; then
[[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\ echo "Error: Package doesn't cover WEB_DOMAIN usage"
[[ "$DATABASES" -lt "$U_DATABASES" ]] ||\
[[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\
[[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\
[[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then
echo "Error: Package not cover current usage"
log_event "$E_LIMIT" "$EVENT" log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT exit $E_LIMIT
fi fi
fi
if [ "$DNS_DOMAINS" ! = 'unlimited' ]; then
if [ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]; then
echo "Error: Package doesn't cover DNS_DOMAIN usage"
log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT
fi
fi
if [ "$MAIL_DOMAINS" != 'unlimited' ]; then
if [ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]; then
echo "Error: Package doesn't cover MAIL_DOMAIN usage"
log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT
fi
fi
if [ "$DATABASES" != 'unlimited' ]; then
if [ "$DATABASES" -lt "$U_DATABASES" ]; then
echo "Error: Package doesn't cover DATABASE usage"
log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT
fi
fi
if [ "$CRON_JOBS" != 'unlimited' ]; then
if [ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]; then
echo "Error: Package doesn't cover CRON usage"
log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT
fi
fi
if [ "$DISK_QUOTA" != 'unlimited' ]; then
if [ "$DISK_QUOTA" -lt "$U_DISK" ]; then
echo "Error: Package doesn't cover DISK usage"
log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT
fi
fi
if [ "$BANDWIDTH" != 'unlimited' ]; then
if [ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]; then
echo "Error: Package doesn't cover BANDWIDTH usage"
log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT
fi
fi
} }
change_user_package() { change_user_package() {
@ -145,6 +183,12 @@ if [ -x "$VESTA/data/packages/$package.sh" ]; then
$VESTA/data/packages/$package.sh "$user" "$CONTACT" "$FNAME" "$LNAME" $VESTA/data/packages/$package.sh "$user" "$CONTACT" "$FNAME" "$LNAME"
fi fi
# Update disk quota
source $VESTA/conf/vesta.conf
if [ "$DISK_QUOTA" = 'yes' ]; then
$BIN/v-update-user-quota $user
fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #

View file

@ -19,7 +19,7 @@ source $VESTA/func/main.sh
json_list_pkgs() { json_list_pkgs() {
echo '{' echo '{'
fileds_count=$(echo "$fields" | wc -w) fileds_count=$(echo "$fields" | wc -w)
for package in $(ls -t $VESTA/data/packages); do for package in $(ls -t $VESTA/data/packages |grep .pkg); do
PACKAGE=${package/.pkg/} PACKAGE=${package/.pkg/}
pkg_data=$(cat $VESTA/data/packages/$package) pkg_data=$(cat $VESTA/data/packages/$package)
eval $pkg_data eval $pkg_data
@ -51,7 +51,7 @@ json_list_pkgs() {
# Shell fnction # Shell fnction
shell_list_pkgs() { shell_list_pkgs() {
for package in $(ls -t $VESTA/data/packages); do for package in $(ls -t $VESTA/data/packages |grep .pkg); do
PACKAGE=${package/.pkg/} PACKAGE=${package/.pkg/}
pkg_descr=$(cat $VESTA/data/packages/$package) pkg_descr=$(cat $VESTA/data/packages/$package)
eval $pkg_descr eval $pkg_descr

View file

@ -113,8 +113,8 @@ is_package_full() {
CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );; CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );;
esac esac
limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' ) limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' )
if [ "$used" -ge "$limit" ]; then if [ "$limit" != 'unlimited' ] && [ "$used" -ge "$limit" ]; then
echo "Error: Limit reached / Upgrade package" echo "Error: Limit is reached, please upgrade hosting package"
log_event "$E_LIMIT" "$EVENT" log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT exit $E_LIMIT
fi fi

View file

@ -710,8 +710,8 @@ var App = {
Core: {}, Core: {},
// CONSTANT VALUES // CONSTANT VALUES
Constants: { Constants: {
UNLIM_VALUE: 'Unlim', UNLIM_VALUE: 'unlimited',
UNLIM_TRANSLATED_VALUE: 'Unlim' UNLIM_TRANSLATED_VALUE: 'unlimited'
}, },
// Actions. More widly used funcs // Actions. More widly used funcs
Actions: { Actions: {

View file

@ -69,27 +69,27 @@
<table> <table>
<tr> <tr>
<td class="counter-name"><?php print __('Web Template');?>:</td> <td class="counter-name"><?php print __('Web Template');?>:</td>
<td class="counter-value"><?php echo $data[$key]['WEB_TEMPLATE'] ?> </td> <td class="counter-value"><?php print __($data[$key]['WEB_TEMPLATE'])?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('Proxy Template');?>:</td> <td class="counter-name"><?php print __('Proxy Template');?>:</td>
<td class="counter-value"><?php echo $data[$key]['PROXY_TEMPLATE'] ?> </td> <td class="counter-value"><?php print __($data[$key]['PROXY_TEMPLATE']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('DNS Template');?>:</td> <td class="counter-name"><?php print __('DNS Template');?>:</td>
<td class="counter-value"><?php echo $data[$key]['DNS_TEMPLATE'] ?> </td> <td class="counter-value"><?php print __($data[$key]['DNS_TEMPLATE']);?></td>
</tr> </tr>
</tr> </tr>
<td class="counter-name"><?php print __('SSH Access');?>:</td> <td class="counter-name"><?php print __('SSH Access');?>:</td>
<td class="counter-value"><?php echo $data[$key]['SHELL'] ?></td> <td class="counter-value"><?php print __($data[$key]['SHELL']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('Web Domains');?>:</td> <td class="counter-name"><?php print __('Web Domains');?>:</td>
<td class="counter-value"><?php echo $data[$key]['WEB_DOMAINS'] ?> </td> <td class="counter-value"><?php print __($data[$key]['WEB_DOMAINS']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('Web Aliases');?>:</td> <td class="counter-name"><?php print __('Web Aliases');?>:</td>
<td class="counter-value"><?php echo $data[$key]['WEB_ALIASES'] ?> <?php print __('per domain');?> </td> <td class="counter-value"><?php print __($data[$key]['WEB_ALIASES']);?></td>
</tr> </tr>
</table> </table>
</td> </td>
@ -97,34 +97,34 @@
<table> <table>
<tr> <tr>
<td class="counter-name"><?php print __('DNS domains');?>:</td> <td class="counter-name"><?php print __('DNS domains');?>:</td>
<td class="counter-value"><?php echo $data[$key]['DNS_DOMAINS'] ?> </td> <td class="counter-value"><?php print __($data[$key]['DNS_DOMAINS']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('DNS records');?>:</td> <td class="counter-name"><?php print __('DNS records');?>:</td>
<td class="counter-value"><?php echo $data[$key]['DNS_RECORDS'] ?> <?php print __('per domain');?> </td> <td class="counter-value"><?php print __($data[$key]['DNS_RECORDS']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('Mail Domains');?>:</td> <td class="counter-name"><?php print __('Mail Domains');?>:</td>
<td class="counter-value"><?php echo $data[$key]['MAIL_DOMAINS'] ?> </td> <td class="counter-value"><?php print __($data[$key]['MAIL_DOMAINS']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('Mail Accounts');?>:</td> <td class="counter-name"><?php print __('Mail Accounts');?>:</td>
<td class="counter-value"><?php echo $data[$key]['MAIL_ACCOUNTS'] ?> <?php print __('per domain');?> </td> <td class="counter-value"><?php print __($data[$key]['MAIL_ACCOUNTS']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('Databases');?>:</td> <td class="counter-name"><?php print __('Databases');?>:</td>
<td class="counter-value"><?php echo $data[$key]['DATABASES'] ?> </td> <td class="counter-value"><?php print __($data[$key]['DATABASES']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('Cron Jobs');?>:</td> <td class="counter-name"><?php print __('Cron Jobs');?>:</td>
<td class="counter-value"><?php echo $data[$key]['CRON_JOBS'] ?> </td> <td class="counter-value"><?php print __($data[$key]['CRON_JOBS']);?></td>
<tr> <tr>
</table> </table>
</td> </td>
<td style="vertical-align:top;"> <td style="vertical-align:top;">
<table> <table>
<td class="counter-name"><?php print __('Backups');?>:</td> <td class="counter-name"><?php print __('Backups');?>:</td>
<td class="counter-value"><?php echo $data[$key]['BACKUPS'] ?></td> <td class="counter-value"><?php print __($data[$key]['BACKUPS']);?></td>
</tr> </tr>
<tr> <tr>
<td class="counter-name"><?php print __('Bandwidth');?>:</td> <td class="counter-name"><?php print __('Bandwidth');?>:</td>