forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomain.func
More file actions
765 lines (629 loc) · 19.8 KB
/
domain.func
File metadata and controls
765 lines (629 loc) · 19.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
# Checking domain existance
is_domain_new() {
output_mode="$1"
search_dom=${2-$domain}
# Parsing domain values
check_domain=$(grep -F "DOMAIN='$search_dom'" $V_USERS/*/*.conf| \
grep -v cron.conf)
# Parsing alias values
check_alias=$(grep -F 'ALIAS=' $V_USERS/*/*.conf | \
grep -v cron.conf | \
awk -F "ALIAS=" '{print $2}' | \
cut -f 2 -d \' | \
sed -e "s/,/\n/g" | \
grep "^$search_dom$" )
# Checking result
if [ ! -z "$check_domain" ] || [ ! -z "$check_alias" ]; then
if [ "$output_mode" != 'quiet' ]; then
echo "Error: domain exist"
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
return $E_EXISTS
fi
}
is_domain_owner() {
search_dom=${1-$domain}
# Parsing domain values
check_domain=$(grep "DOMAIN='$search_dom'" $V_USERS/$user/*.conf)
# Parsing alias values
check_alias=$(grep 'ALIAS=' $V_USERS/$user/*.conf | \
awk -F "ALIAS=" '{print $2}' | \
cut -f 2 -d \' | \
sed -e "s/,/\n/g" | \
grep "^$search_dom$" )
# Checking result
if [ -z "$check_domain" ] && [ -z "$check_alias" ]; then
echo "Error: domain not owned"
log_event 'debug' "$E_FORBIDEN $V_EVENT"
exit $E_FORBIDEN
fi
}
is_dns_domain_free() {
# Parsing domain values
check_domain=$(grep -F "DOMAIN='$domain'" $V_USERS/$user/dns.conf)
# Checking result
if [ ! -z "$check_domain" ]; then
echo "Error: domain exist"
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
is_web_domain_free() {
search_dom=${1-$domain}
# Parsing domain values
check_domain=$(grep -F "DOMAIN='$search_dom'" $V_USERS/$user/web.conf)
# Parsing alias values
check_alias=$(grep -F 'ALIAS=' $V_USERS/$user/web.conf | \
awk -F "ALIAS=" '{print $2}' | \
cut -f 2 -d \' | \
sed -e "s/,/\n/g" | \
grep "^$search_dom$" )
# Checking result
if [ ! -z "$check_domain" ] || [ ! -z "$check_alias" ]; then
echo "Error: domain exist"
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
is_dns_domain_valid() {
# Parsing domain values
check_domain=$(grep -F "DOMAIN='$domain'" $V_USERS/$user/dns.conf)
# Checking result
if [ -z "$check_domain" ]; then
echo "Error: domain not exist"
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
is_web_domain_valid() {
# Parsing domain values
check_domain=$(grep -F "DOMAIN='$domain'" $V_USERS/$user/web.conf)
# Checking result
if [ -z "$check_domain" ]; then
echo "Error: domain not exist"
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
is_domain_suspended() {
config_type="$1"
# Parsing domain values
check_domain=$(grep "DOMAIN='$domain'" $V_USERS/$user/$config_type.conf|\
grep "SUSPEND='yes'")
# Checking result
if [ ! -z "$check_domain" ]; then
echo "Error: domain suspended"
log_event 'debug' "$E_SUSPENDED $V_EVENT"
exit $E_SUSPENDED
fi
}
is_domain_unsuspended() {
config_type="$1"
# Parsing domain values
check_domain=$(grep "DOMAIN='$domain'" $V_USERS/$user/$config_type.conf|\
grep "SUSPEND='no'")
# Checking result
if [ ! -z "$check_domain" ]; then
echo "Error: domain unsuspended"
log_event 'debug' "$E_UNSUSPENDED $V_EVENT"
exit $E_UNSUSPENDED
fi
}
update_domain_zone() {
# Definigng variables
line=$(grep "DOMAIN='$domain'" $V_USERS/$user/dns.conf)
fields='$RECORD\t$TTL\tIN\t$TYPE\t$VALUE'
conf="/etc/namedb/$domain.db"
# Checking serial
if [ -e $conf ]; then
zn_serial=$(head $conf|grep 'SOA' -A1|tail -n 1|sed -e "s/ //g")
s_date=$(echo ${zn_serial:0:8})
c_date=$(date +'%Y%m%d')
if [ "$s_date" == "$c_date" ]; then
cur_value=$(echo ${zn_serial:8} )
new_value=$(expr $cur_value + 1 )
len_value=$(expr length $new_value)
if [ 1 -eq "$len_value" ]; then
new_value='0'$new_value
fi
serial="$c_date""$new_value"
else
serial="$(date +'%Y%m%d01')"
fi
else
serial="$(date +'%Y%m%d01')"
fi
# Parsing dns domains conf
eval $line
# Converting SOA to ascii
SOA=$(idn --quiet -a -t "$SOA")
# Adding zone header
echo "\$TTL $TTL
@ IN SOA $SOA. root.$domain_idn. (
$serial
7200
3600
1209600
180 )
" > $conf
# Adding zone records
while read line ; do
# Defining new delimeter
IFS=$'\n'
# Parsing key=value
for key in $(echo $line|sed -e "s/' /'\n/g"); do
eval ${key%%=*}="${key#*=}"
done
# Converting utf records to ascii
RECORD=$(idn --quiet -a -t "$RECORD")
VALUE=$(idn --quiet -a -t "$VALUE")
eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
done < $V_USERS/$user/dns/$domain
}
get_next_dns_record() {
# Parsing config
curr_str=$(grep "ID=" $V_USERS/$user/dns/$domain|cut -f 2 -d \'|\
sort -n|tail -n1)
# Print result
echo "$((curr_str +1))"
}
is_dns_record_free() {
# Checking record id
check_id=$(grep "ID='$id'" $V_USERS/$user/dns/$domain)
if [ ! -z "$check_id" ]; then
echo "Error: ID exist"
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
sort_dns_records() {
# Defining conf
conf="$V_USERS/$user/dns/$domain"
cat $conf |sort -n -k 2 -t \' >$conf.tmp
mv -f $conf.tmp $conf
}
add_web_config() {
# Adding template to config
cat $tpl_file | \
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_string%/${proxy_string////\/}/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/%group%/$group/g" \
-e "s/%home%/${V_HOME////\/}/g" \
-e "s/%docroot%/${docroot////\/}/g" \
-e "s/%docroot_string%/${docroot_string////\/}/g" \
-e "s/%email%/$email/g" \
-e "s/%alias_string%/$alias_string/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
-e "s/%alias%/${aliases//,/ }/g" \
-e "s/%ssl_crt%/${ssl_crt////\/}/g" \
-e "s/%ssl_key%/${ssl_key////\/}/g" \
-e "s/%ssl_pem%/${ssl_pem////\/}/g" \
-e "s/%ssl_ca_str%/${ssl_ca_str////\/}/g" \
-e "s/%nginx_extentions%/${NGINX_EXT//,/|}/g" \
-e "s/%elog%/$elog/g" \
-e "s/%cgi%/$cgi/g" \
-e "s/%cgi_option%/$cgi_option/g" \
>> $conf
}
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_PARSING $V_EVENT"
return $E_PARSING
fi
# Template lines
last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
bfr_line=$((serv_line - 1))
aftr_line=$((last_line - serv_line - 1))
# Config lines
str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :)
top_line=$((str - serv_line + 1))
bottom_line=$((top_line + last_line -1))
# Check for multialias (8k alias issue)
multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
if [ "$multi" -ge 2 ]; then
bottom_line=$((bottom_line + multi -1))
fi
}
change_web_config() {
# Get config borders
get_web_config_brds || exit $?
# Parsing config
vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf)
str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
# Parsing string position and content
str_numb=$(echo "$str" | sed -e "s/-/=/" | cut -f 1 -d '=')
str_cont=$(echo "$str" | sed -e "s/-/=/" | cut -f 2 -d '=')
# Escaping chars
str_repl=$(echo "$str_repl" | sed \
-e 's/\\/\\\\/g' \
-e 's/&/\\&/g' \
-e 's/\//\\\//g')
# Changing config
if [ ! -z "$str" ]; then
sed -i "$str_numb s/.*/$str_repl/" $conf
fi
}
replace_web_config() {
# Get config borders
get_web_config_brds || exit $?
# Escaping chars
clean_new=$(echo "$new" | sed \
-e 's/\\/\\\\/g' \
-e 's/&/\\&/g' \
-e 's/\//\\\//g')
clean_old=$(echo "$old" | sed \
-e 's/\\/\\\\/g' \
-e 's/&/\\&/g' \
-e 's/\//\\\//g')
# Replacing string in config
sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
}
get_web_domain_value() {
key="$1"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web.conf )
# Parsing key=value
eval $string
# Self reference
eval value="$key"
# Print value
echo "$value"
}
get_web_domain_values() {
# Defining domain parameters
for line in $(grep "DOMAIN='$domain'" $V_USERS/$user/web.conf); do
# Assing key=value
eval $line
done
}
get_dns_domain_value() {
key="$1"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/dns.conf )
# Parsing key=value
eval $string
# Self reference
eval value="$key"
# Print value
echo "$value"
}
update_web_domain_value() {
key="$1"
value="$2"
# Defining conf
conf="$V_USERS/$user/web.conf"
# Parsing conf
domain_str=$(grep -n "DOMAIN='$domain'" $conf)
str_number=$(echo $domain_str | cut -f 1 -d ':')
str=$(echo $domain_str | cut -f 2 -d ':')
# Reading key=values
eval $str
# Defining clean key
c_key=$(echo "${key//$/}")
eval old="${key}"
# Escaping slashes
old=$(echo "$old" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
new=$(echo "$value" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
# Updating conf
sed -i "$str_number s/$c_key='${old//\*/\\*}'/$c_key='${new//\*/\\*}'/g"\
$conf
}
update_dns_domain_value() {
key="$1"
value="$2"
# Defining conf
conf="$V_USERS/$user/dns.conf"
# Parsing conf
domain_str=$(grep -n "DOMAIN='$domain'" $conf)
str_number=$(echo $domain_str | cut -f 1 -d ':')
str=$(echo $domain_str | cut -f 2 -d ':')
# Reading key=values
eval $str
# Defining clean key
c_key=$(echo "${key//$/}")
eval old="${key}"
# Escaping slashes
old=$(echo "$old" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
new=$(echo "$value" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
# Updating conf
sed -i "$str_number s/$c_key='${old//\*/\\*}'/$c_key='${new//\*/\\*}'/g"\
$conf
}
is_web_domain_key_empty() {
key="$1"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web.conf )
# Parsing key=value
eval $string
# Self reference
eval value="$key"
# Checkng key
if [ ! -z "$value" ] && [ "$value" != 'no' ]; then
echo "Error: value is not empty = $value"
log_event 'debug' "$E_EXISTS $V_EVENT"
exit $E_EXISTS
fi
}
is_web_domain_cert_valid() {
# Checking file existance
if [ ! -e "$ssl_dir/$domain.crt" ] || [ ! -e "$ssl_dir/$domain.key" ]; then
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: 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: 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: ssl certificate invalid"
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
fi
# Checking server
openssl s_server -quiet \
-cert $ssl_dir/$domain.crt -key $ssl_dir/$domain.key &
pid=$!
sleep 1
disown > /dev/null 2>&1
kill $pid > /dev/null 2>&1
result=$?
if [ "$result" -ne '0' ]; then
echo "Error: ssl certificate key pair invalid"
log_event 'debug' "$E_INVALID $V_EVENT"
exit $E_INVALID
fi
}
is_dns_record_valid() {
# Checking record id
check_id=$(grep "^ID='$id'" $V_USERS/$user/dns/$domain)
if [ -z "$check_id" ]; then
echo "Error: ID not exist"
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
is_web_domain_value_exist() {
key="$1"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web.conf )
# Parsing key=value
eval $string
# Self reference
eval value="$key"
# Checking result
if [ -z "$value" ] || [ "$value" = 'no' ]; then
echo "Error: ${key//$/} is empty"
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_NOTEXIST
fi
}
is_dns_domain_value_exist() {
key="$1"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/dns.conf )
# Parsing key=value
eval $string
# Self reference
eval value="$key"
# Checking result
if [ -z "$value" ] || [ "$value" = 'no' ]; then
echo "Error: ${key//$/} is empty"
log_event 'debug' "$E_NOTEXIST $V_EVENT"
exit $E_EXISTS
fi
}
del_web_config() {
# Get config borders
get_web_config_brds || exit $?
# Deleting lines from config
sed -i "$top_line,$bottom_line d" $conf
}
del_dns_domain() {
conf="$V_USERS/$user/dns.conf"
# Parsing domains
string=$( grep -n "DOMAIN='$domain'" $conf | cut -f 1 -d : )
if [ -z "$string" ]; then
echo "Error: 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
}
del_web_domain() {
conf="$V_USERS/$user/web.conf"
# Parsing domains
string=$( grep -n "DOMAIN='$domain'" $conf | cut -f 1 -d : )
if [ -z "$string" ]; then
echo "Error: parse error"
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
sed -i "$string d" $conf
}
dom_clear_search(){
# Defining delimeter
IFS=$'\n'
# Reading file line by line
for line in $(grep $search_string $conf); do
# Parsing key=val
eval $line
# Print result line
eval echo "$field"
done
}
dom_clear_list() {
# Reading file line by line
while read line ; do
# Parsing key=value
eval $line
# Print result line
eval echo "$field"
done < $conf
}
namehost_ip_support() {
# Checking httpd config for NameHost string number
if [ "$WEB_SYSTEM" = 'apache' ]; then
conf_line=$(grep -n "NameVirtual" $conf|tail -n 1|cut -f 1 -d ':')
if [ ! -z "$conf_line" ]; then
conf_ins=$((conf_line + 1))
else
conf_ins='1'
fi
# Checking ssl support
if [ "$WEB_SSL" = 'mod_ssl' ]; then
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $conf
sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $conf
fi
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $conf
sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf
# Checking proxy support
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
cat $V_WEBTPL/ngingx_ip.tpl | sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_SSL_PORT/g" \
-e "s/%proxy_port%/$PROXY_PORT/g" >>$nconf
# Adding to rpaf ip pool as well
ips=$(grep 'RPAFproxy_ips' $rconf)
sed -i "s/$ips/$ips $ip/g" $rconf
fi
# Scheduling restart
web_restart='yes'
fi
}
namehost_ip_disable() {
#Checking web system
if [ "$WEB_SYSTEM" = 'apache' ]; then
sed -i "/NameVirtualHost $ip:/d" $conf
sed -i "/Listen $ip:/d" $conf
# Checking proxy support
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
tpl_ln=$(wc -l $V_WEBTPL/ngingx_ip.tpl | cut -f 1 -d ' ')
ip_line=$(grep -n "%ip%" $V_WEBTPL/ngingx_ip.tpl |head -n1 |\
cut -f 1 -d :)
conf_line=$(grep -n -w $ip $nconf|head -n1|cut -f 1 -d :)
# Checking parsed lines
if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ]
then
echo "Error: nginx config paring error"
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
up_line=$((ip_line - 1))
first_line=$((conf_line - up_line))
last_line=$((conf_line - ip_line + tpl_ln))
# Checking parsed lines
if [ -z "$first_line" ] || [ -z "$last_line" ]; then
echo "Error: nginx config paring error"
log_event 'debug' "$E_PARSING $V_EVENT"
exit $E_PARSING
fi
sed -i "$first_line,$last_line d" $nconf
# Deleting from rpaf ip pool as well
ips=$(grep 'RPAFproxy_ips' $rconf)
new_ips=$(echo "$ips"|sed -e "s/$ip//")
sed -i "s/$ips/$new_ips/g" $rconf
fi
# Scheduling restart
web_restart='yes'
fi
}
upd_web_domain_values() {
ip=$IP
group="$user"
email="$user@$domain"
docroot="$V_HOME/$user/web/$domain/public_html"
docroot_string="DocumentRoot $docroot"
proxy_string="proxy_pass http://$ip:$WEB_PORT;"
# Parsing domain aliases
i=1
j=1
OLD_IFS="$IFS"
IFS=','
server_alias=''
alias_string=''
for dalias in $ALIAS; do
dalias=$(idn -t --quiet -a $dalias)
# Spliting ServerAlias lines
check_8k="$server_alias $dalias"
if [ "${#check_8k}" -ge '8100' ]; then
if [ "$j" -eq 1 ]; then
alias_string="ServerAlias $server_alias"
else
alias_string="$alias_string\n ServerAlias $server_alias"
fi
j=2
server_alias=''
fi
if [ "$i" -eq 1 ]; then
aliases_idn="$dalias"
server_alias="$dalias"
alias_string="ServerAlias $server_alias"
else
aliases_idn="$aliases_idn,$dalias"
server_alias="$server_alias $dalias"
fi
i=2
done
if [ $j -gt 1 ]; then
alias_string="$alias_string\n ServerAlias $server_alias"
else
alias_string="ServerAlias $server_alias"
fi
IFS=$OLD_IFS
# Checking error log status
if [ "$ELOG" = 'no' ]; then
elog='#'
else
elog=''
fi
# Checking cgi
if [ "$CGI" != 'yes' ]; then
cgi='#'
cgi_option='-ExecCGI'
else
cgi=''
cgi_option='+ExecCGI'
fi
# Checking suspend
if [ "$SUSPEND" = 'yes' ]; then
docroot_string="Redirect / http://$url"
proxy_string="rewrite ^(.*)\$ http://$url;"
fi
# Defining SSL vars
ssl_crt="$V_HOME/$user/conf/ssl.$domain.crt"
ssl_key="$V_HOME/$user/conf/ssl.$domain.key"
ssl_pem="$V_HOME/$user/conf/ssl.$domain.pem"
ssl_ca="$V_HOME/$user/conf/ssl.$domain.ca"
if [ ! -e "$V_USERS/$user/ssl/$domain.ca" ]; then
ssl_ca_str='#'
fi
case $SSL_HOME in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
same) docroot="$V_HOME/$user/web/$domain/public_html" ;;
esac
}