Skip to content

Commit 89c1f64

Browse files
committed
Improved domain validation plus added SERIAL support
1 parent 941e01e commit 89c1f64

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

func/domain.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ is_domain_new() {
146146
web_alias=$(grep -w $dom $VESTA/data/users/*/web.conf)
147147
fi
148148
if [ ! -z "$web_alias" ]; then
149-
c1=$(grep -H "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
150-
c2=$(grep -H "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
151-
c3=$(grep -H ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
152-
c4=$(grep -H ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
149+
c1=$(grep -HF "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
150+
c2=$(grep -HF "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
151+
c3=$(grep -HF ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
152+
c4=$(grep -HF ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
153153
if [ ! -z "$c1" ] && [ "$type" == "web" ]; then
154154
echo "Error: $object $dom exist"
155155
log_event "$E_EXISTS" "$EVENT"
@@ -215,19 +215,22 @@ is_mail_new() {
215215

216216
# Update domain zone
217217
update_domain_zone() {
218-
conf="$HOMEDIR/$user/conf/dns/$domain.db"
219218
domain_param=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
220-
fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
221219
eval $domain_param
222220
SOA=$(idn --quiet -a -t "$SOA")
221+
if [ -z "$SERIAL" ]; then
222+
SERIAL=$(date +'%Y%m%d01')
223+
fi
224+
zn_conf="$HOMEDIR/$user/conf/dns/$domain.db"
223225
echo "\$TTL $TTL
224226
@ IN SOA $SOA. root.$domain_idn. (
225227
$SERIAL
226228
7200
227229
3600
228230
1209600
229231
180 )
230-
" > $conf
232+
" > $zn_conf
233+
fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
231234
while read line ; do
232235
IFS=$'\n'
233236
for key in $(echo $line|sed "s/' /'\n/g"); do
@@ -240,7 +243,7 @@ update_domain_zone() {
240243
fi
241244

242245
if [ "$SUSPENDED" != 'yes' ]; then
243-
eval echo -e "\"$fields\""|sed "s/%quote%/'/g" >> $conf
246+
eval echo -e "\"$fields\""|sed "s/%quote%/'/g" >> $zn_conf
244247
fi
245248
done < $USER_DATA/dns/$domain.conf
246249
}
@@ -320,6 +323,7 @@ add_web_config() {
320323

321324
# Get config top and bottom line numbers
322325
get_web_config_brds() {
326+
323327
serv_line=$(egrep -ni "Name %domain_idn%($| )" $tpl_file |cut -f 1 -d :)
324328
if [ -z "$serv_line" ]; then
325329
log_event "$E_PARSING" "$EVENT"
@@ -330,15 +334,14 @@ get_web_config_brds() {
330334
bfr_line=$((serv_line - 1))
331335
aftr_line=$((last_line - serv_line - 1))
332336

333-
str=$(egrep -ni "Name $domain_idn($| )" $conf | cut -f 1 -d :)
337+
str=$(grep -niF "Name $domain_idn" $conf |egrep "$domain_idn$|$domain_idn ")
338+
str=$(echo "$str" |cut -f 1 -d :)
334339
top_line=$((str - serv_line + 1))
335340
bottom_line=$((top_line + last_line -1))
336-
337341
multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
338342
if [ "$multi" -ge 2 ]; then
339343
bottom_line=$((bottom_line + multi -1))
340344
fi
341-
342345
}
343346

344347
# Replace web config

0 commit comments

Comments
 (0)