Skip to content

Commit 61288a2

Browse files
committed
unlimitted hosting packages
1 parent fd96461 commit 61288a2

File tree

6 files changed

+108
-41
lines changed

6 files changed

+108
-41
lines changed

bin/v-add-user-package

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,39 @@ is_package_new() {
2929

3030
is_package_consistent() {
3131
source $pkg_dir/$package.pkg
32-
validate_format_int $WEB_DOMAINS 'WEB_DOMAINS'
33-
validate_format_int $WEB_ALIASES 'WEB_ALIASES'
34-
validate_format_int $DNS_DOMAINS 'DNS_DOMAINS'
35-
validate_format_int $DNS_RECORDS 'DNS_RECORDS'
36-
validate_format_int $MAIL_DOMAINS 'MAIL_DOMAINS'
37-
validate_format_int $MAIL_ACCOUNTS 'MAIL_ACCOUNTS'
38-
validate_format_int $DATABASES 'DATABASES'
39-
validate_format_int $CRON_JOBS 'CRON_JOBS'
40-
validate_format_int $DISK_QUOTA 'DISK_QUOTA'
41-
validate_format_int $BACKUPS 'BACKUPS'
32+
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
33+
validate_format_int $WEB_DOMAINS 'WEB_DOMAINS'
34+
fi
35+
if [ "$WEB_ALIASES" != 'unlimited' ]; then
36+
validate_format_int $WEB_ALIASES 'WEB_ALIASES'
37+
fi
38+
if [ "$DNS_DOMAINS" != 'unlimited' ]; then
39+
validate_format_int $DNS_DOMAINS 'DNS_DOMAINS'
40+
fi
41+
if [ "$DNS_RECORDS" != 'unlimited' ]; then
42+
validate_format_int $DNS_RECORDS 'DNS_RECORDS'
43+
fi
44+
if [ "$MAIL_DOMAINS" != 'unlimited' ]; then
45+
validate_format_int $MAIL_DOMAINS 'MAIL_DOMAINS'
46+
fi
47+
if [ "$MAIL_ACCOUNTS" != 'unlimited' ]; then
48+
validate_format_int $MAIL_ACCOUNTS 'MAIL_ACCOUNTS'
49+
fi
50+
if [ "$DATABASES" != 'unlimited' ]; then
51+
validate_format_int $DATABASES 'DATABASES'
52+
fi
53+
if [ "$CRON_JOBS" != 'unlimited' ]; then
54+
validate_format_int $CRON_JOBS 'CRON_JOBS'
55+
fi
56+
if [ "$DISK_QUOTA" != 'unlimited' ]; then
57+
validate_format_int $DISK_QUOTA 'DISK_QUOTA'
58+
fi
59+
if [ "$BANDWIDTH" != 'unlimited' ]; then
60+
validate_format_int $BANDWIDTH 'BANDWIDTH'
61+
fi
62+
if [ "$BACKUPS" != 'unlimited' ]; then
63+
validate_format_int $BACKUPS 'BACKUPS'
64+
fi
4265
validate_format_shell $SHELL
4366
}
4467

bin/v-change-user-package

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ source $VESTA/func/main.sh
1919
source $VESTA/conf/vesta.conf
2020

2121
is_package_avalable() {
22-
# Parsing user data
22+
2323
usr_data=$(cat $USER_DATA/user.conf)
2424
IFS=$'\n'
2525
for key in $usr_data; do
@@ -37,17 +37,55 @@ is_package_avalable() {
3737
grep -v DATE)
3838
eval $pkg_data
3939

40-
# Comparing user data with package
41-
if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\
42-
[[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\
43-
[[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\
44-
[[ "$DATABASES" -lt "$U_DATABASES" ]] ||\
45-
[[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\
46-
[[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\
47-
[[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then
48-
echo "Error: Package not cover current usage"
49-
log_event "$E_LIMIT" "$EVENT"
50-
exit $E_LIMIT
40+
# Checking usage agains package limits
41+
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
42+
if [ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]; then
43+
echo "Error: Package doesn't cover WEB_DOMAIN usage"
44+
log_event "$E_LIMIT" "$EVENT"
45+
exit $E_LIMIT
46+
fi
47+
fi
48+
if [ "$DNS_DOMAINS" ! = 'unlimited' ]; then
49+
if [ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]; then
50+
echo "Error: Package doesn't cover DNS_DOMAIN usage"
51+
log_event "$E_LIMIT" "$EVENT"
52+
exit $E_LIMIT
53+
fi
54+
fi
55+
if [ "$MAIL_DOMAINS" != 'unlimited' ]; then
56+
if [ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]; then
57+
echo "Error: Package doesn't cover MAIL_DOMAIN usage"
58+
log_event "$E_LIMIT" "$EVENT"
59+
exit $E_LIMIT
60+
fi
61+
fi
62+
if [ "$DATABASES" != 'unlimited' ]; then
63+
if [ "$DATABASES" -lt "$U_DATABASES" ]; then
64+
echo "Error: Package doesn't cover DATABASE usage"
65+
log_event "$E_LIMIT" "$EVENT"
66+
exit $E_LIMIT
67+
fi
68+
fi
69+
if [ "$CRON_JOBS" != 'unlimited' ]; then
70+
if [ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]; then
71+
echo "Error: Package doesn't cover CRON usage"
72+
log_event "$E_LIMIT" "$EVENT"
73+
exit $E_LIMIT
74+
fi
75+
fi
76+
if [ "$DISK_QUOTA" != 'unlimited' ]; then
77+
if [ "$DISK_QUOTA" -lt "$U_DISK" ]; then
78+
echo "Error: Package doesn't cover DISK usage"
79+
log_event "$E_LIMIT" "$EVENT"
80+
exit $E_LIMIT
81+
fi
82+
fi
83+
if [ "$BANDWIDTH" != 'unlimited' ]; then
84+
if [ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]; then
85+
echo "Error: Package doesn't cover BANDWIDTH usage"
86+
log_event "$E_LIMIT" "$EVENT"
87+
exit $E_LIMIT
88+
fi
5189
fi
5290
}
5391

@@ -145,6 +183,12 @@ if [ -x "$VESTA/data/packages/$package.sh" ]; then
145183
$VESTA/data/packages/$package.sh "$user" "$CONTACT" "$FNAME" "$LNAME"
146184
fi
147185

186+
# Update disk quota
187+
source $VESTA/conf/vesta.conf
188+
if [ "$DISK_QUOTA" = 'yes' ]; then
189+
$BIN/v-update-user-quota $user
190+
fi
191+
148192

149193
#----------------------------------------------------------#
150194
# Vesta #

bin/v-list-user-packages

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ source $VESTA/func/main.sh
1919
json_list_pkgs() {
2020
echo '{'
2121
fileds_count=$(echo "$fields" | wc -w)
22-
for package in $(ls -t $VESTA/data/packages); do
22+
for package in $(ls -t $VESTA/data/packages |grep .pkg); do
2323
PACKAGE=${package/.pkg/}
2424
pkg_data=$(cat $VESTA/data/packages/$package)
2525
eval $pkg_data
@@ -51,7 +51,7 @@ json_list_pkgs() {
5151

5252
# Shell fnction
5353
shell_list_pkgs() {
54-
for package in $(ls -t $VESTA/data/packages); do
54+
for package in $(ls -t $VESTA/data/packages |grep .pkg); do
5555
PACKAGE=${package/.pkg/}
5656
pkg_descr=$(cat $VESTA/data/packages/$package)
5757
eval $pkg_descr

func/main.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ is_package_full() {
113113
CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );;
114114
esac
115115
limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' )
116-
if [ "$used" -ge "$limit" ]; then
117-
echo "Error: Limit reached / Upgrade package"
116+
if [ "$limit" != 'unlimited' ] && [ "$used" -ge "$limit" ]; then
117+
echo "Error: Limit is reached, please upgrade hosting package"
118118
log_event "$E_LIMIT" "$EVENT"
119119
exit $E_LIMIT
120120
fi

web/js/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,8 @@ var App = {
710710
Core: {},
711711
// CONSTANT VALUES
712712
Constants: {
713-
UNLIM_VALUE: 'Unlim',
714-
UNLIM_TRANSLATED_VALUE: 'Unlim'
713+
UNLIM_VALUE: 'unlimited',
714+
UNLIM_TRANSLATED_VALUE: 'unlimited'
715715
},
716716
// Actions. More widly used funcs
717717
Actions: {

web/templates/admin/list_packages.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,62 +69,62 @@
6969
<table>
7070
<tr>
7171
<td class="counter-name"><?php print __('Web Template');?>:</td>
72-
<td class="counter-value"><?php echo $data[$key]['WEB_TEMPLATE'] ?> </td>
72+
<td class="counter-value"><?php print __($data[$key]['WEB_TEMPLATE'])?></td>
7373
</tr>
7474
<tr>
7575
<td class="counter-name"><?php print __('Proxy Template');?>:</td>
76-
<td class="counter-value"><?php echo $data[$key]['PROXY_TEMPLATE'] ?> </td>
76+
<td class="counter-value"><?php print __($data[$key]['PROXY_TEMPLATE']);?></td>
7777
</tr>
7878
<tr>
7979
<td class="counter-name"><?php print __('DNS Template');?>:</td>
80-
<td class="counter-value"><?php echo $data[$key]['DNS_TEMPLATE'] ?> </td>
80+
<td class="counter-value"><?php print __($data[$key]['DNS_TEMPLATE']);?></td>
8181
</tr>
8282
</tr>
8383
<td class="counter-name"><?php print __('SSH Access');?>:</td>
84-
<td class="counter-value"><?php echo $data[$key]['SHELL'] ?></td>
84+
<td class="counter-value"><?php print __($data[$key]['SHELL']);?></td>
8585
</tr>
8686
<tr>
8787
<td class="counter-name"><?php print __('Web Domains');?>:</td>
88-
<td class="counter-value"><?php echo $data[$key]['WEB_DOMAINS'] ?> </td>
88+
<td class="counter-value"><?php print __($data[$key]['WEB_DOMAINS']);?></td>
8989
</tr>
9090
<tr>
9191
<td class="counter-name"><?php print __('Web Aliases');?>:</td>
92-
<td class="counter-value"><?php echo $data[$key]['WEB_ALIASES'] ?> <?php print __('per domain');?> </td>
92+
<td class="counter-value"><?php print __($data[$key]['WEB_ALIASES']);?></td>
9393
</tr>
9494
</table>
9595
</td>
9696
<td style="vertical-align:top;" width="238px">
9797
<table>
9898
<tr>
9999
<td class="counter-name"><?php print __('DNS domains');?>:</td>
100-
<td class="counter-value"><?php echo $data[$key]['DNS_DOMAINS'] ?> </td>
100+
<td class="counter-value"><?php print __($data[$key]['DNS_DOMAINS']);?></td>
101101
</tr>
102102
<tr>
103103
<td class="counter-name"><?php print __('DNS records');?>:</td>
104-
<td class="counter-value"><?php echo $data[$key]['DNS_RECORDS'] ?> <?php print __('per domain');?> </td>
104+
<td class="counter-value"><?php print __($data[$key]['DNS_RECORDS']);?></td>
105105
</tr>
106106
<tr>
107107
<td class="counter-name"><?php print __('Mail Domains');?>:</td>
108-
<td class="counter-value"><?php echo $data[$key]['MAIL_DOMAINS'] ?> </td>
108+
<td class="counter-value"><?php print __($data[$key]['MAIL_DOMAINS']);?></td>
109109
</tr>
110110
<tr>
111111
<td class="counter-name"><?php print __('Mail Accounts');?>:</td>
112-
<td class="counter-value"><?php echo $data[$key]['MAIL_ACCOUNTS'] ?> <?php print __('per domain');?> </td>
112+
<td class="counter-value"><?php print __($data[$key]['MAIL_ACCOUNTS']);?></td>
113113
</tr>
114114
<tr>
115115
<td class="counter-name"><?php print __('Databases');?>:</td>
116-
<td class="counter-value"><?php echo $data[$key]['DATABASES'] ?> </td>
116+
<td class="counter-value"><?php print __($data[$key]['DATABASES']);?></td>
117117
</tr>
118118
<tr>
119119
<td class="counter-name"><?php print __('Cron Jobs');?>:</td>
120-
<td class="counter-value"><?php echo $data[$key]['CRON_JOBS'] ?> </td>
120+
<td class="counter-value"><?php print __($data[$key]['CRON_JOBS']);?></td>
121121
<tr>
122122
</table>
123123
</td>
124124
<td style="vertical-align:top;">
125125
<table>
126126
<td class="counter-name"><?php print __('Backups');?>:</td>
127-
<td class="counter-value"><?php echo $data[$key]['BACKUPS'] ?></td>
127+
<td class="counter-value"><?php print __($data[$key]['BACKUPS']);?></td>
128128
</tr>
129129
<tr>
130130
<td class="counter-name"><?php print __('Bandwidth');?>:</td>

0 commit comments

Comments
 (0)