Skip to content

Commit 641ed97

Browse files
committed
export from svn
0 parents  commit 641ed97

File tree

340 files changed

+32404
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

340 files changed

+32404
-0
lines changed

bin/v_add_db_base

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# info: adding data base
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
user="$1"
10+
database="$user"_"$2"
11+
db_user="$user"_"$3"
12+
db_password="$4"
13+
type="$5"
14+
host=$6
15+
16+
# Importing variables
17+
source $VESTA/conf/vars.conf
18+
source $V_FUNC/shared_func.sh
19+
source $V_FUNC/db_func.sh
20+
21+
22+
#----------------------------------------------------------#
23+
# Verifications #
24+
#----------------------------------------------------------#
25+
26+
# Checking arg number
27+
check_args '5' "$#" 'user db db_user db_password type [host]'
28+
29+
# Checking argument format
30+
format_validation 'user' 'database' 'db_user' 'db_password'
31+
32+
# Checking db system is enabled
33+
is_system_enabled 'db'
34+
35+
# Checking db type
36+
is_type_valid 'db' "$type"
37+
38+
# Checking user
39+
is_user_valid
40+
41+
# Checking user is active
42+
is_user_suspended
43+
44+
# Checking db existance
45+
is_db_new
46+
47+
# Checking db host
48+
if [ -z "$host" ]; then
49+
host=$(get_next_db_host)
50+
fi
51+
is_db_host_valid
52+
53+
# Checking package
54+
is_package_full 'db_base'
55+
56+
57+
#----------------------------------------------------------#
58+
# Action #
59+
#----------------------------------------------------------#
60+
61+
# Switching on db type
62+
case $type in
63+
mysql) create_db_mysql ;;
64+
pgsql) create_db_pgsql ;;
65+
esac
66+
67+
68+
#----------------------------------------------------------#
69+
# Vesta #
70+
#----------------------------------------------------------#
71+
72+
# Increasing db value
73+
increase_db_value
74+
75+
# Increasing domain value
76+
increase_user_value "$user" '$U_DATABASES'
77+
78+
# Adding db to db conf
79+
v_str="DB='$database' USER='$db_user' HOST='$host' TYPE='$type'"
80+
v_str="$v_str U_DISK='0' SUSPEND='no' DATE='$V_DATE'"
81+
echo "$v_str">>$V_USERS/$user/db.conf
82+
83+
# Hiding password
84+
V_EVENT=$(echo $V_EVENT | sed -e "s/$db_password/xxxxxx/g")
85+
86+
# Logging
87+
log_history "$V_EVENT" "v_del_db_base $user $database"
88+
log_event 'system' "$V_EVENT"
89+
90+
exit $OK

bin/v_add_db_host

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
# info: adding data base server
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
type="$1"
10+
host="$2"
11+
port="$3"
12+
db_user="$4"
13+
db_password="$5"
14+
max_usr="${6-300}"
15+
max_db="${7-300}"
16+
template="${8-template1}"
17+
18+
19+
# Importing variables
20+
source $VESTA/conf/vars.conf
21+
source $V_FUNC/shared_func.sh
22+
source $V_FUNC/db_func.sh
23+
24+
25+
#----------------------------------------------------------#
26+
# Verifications #
27+
#----------------------------------------------------------#
28+
29+
# Checking arg number
30+
args_usage='type host port db_user db_password [max_usr] [max_db] [tpl]'
31+
check_args '5' "$#" "$args_usage"
32+
33+
# Checking argument format
34+
format_validation 'host' 'port' 'db_user' 'db_password' 'max_usr' 'max_db'
35+
format_validation 'template'
36+
37+
# Checking db system is enabled
38+
is_system_enabled 'db'
39+
40+
# Checking db type
41+
is_type_valid 'db' "$type"
42+
43+
# Checking host existance
44+
is_db_host_new
45+
46+
# Checking host connection
47+
case $type in
48+
mysql) is_mysql_host_alive ;;
49+
pgsql) is_pgsql_host_alive ;;
50+
esac
51+
52+
#----------------------------------------------------------#
53+
# Action #
54+
#----------------------------------------------------------#
55+
56+
# Concatentating db host string
57+
case $type in
58+
mysql) new_str="HOST='$host' USER='$db_user' PASSWORD='$db_password'";
59+
new_str="$new_str PORT='$port' MAX_USERS='$max_usr'";
60+
new_str="$new_str MAX_DB='$max_db' U_SYS_USERS=''";
61+
new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE'";;
62+
pgsql) new_str="HOST='$host' USER='$db_user' PASSWORD='$db_password'";
63+
new_str="$new_str PORT='$port' TPL='$tpl'";
64+
new_str="$new_str MAX_USERS='$max_usr' MAX_DB='$max_db'";
65+
new_str="$new_str U_SYS_USERS=''";
66+
new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE'";;
67+
esac
68+
69+
# Adding host to conf
70+
echo "$new_str" >> $V_DB/$type.conf
71+
72+
73+
#----------------------------------------------------------#
74+
# Vesta #
75+
#----------------------------------------------------------#
76+
77+
# Hidding db pass
78+
V_EVENT=$(echo $V_EVENT | sed -e "s/$db_password/xxxxxx/g")
79+
80+
# Logging
81+
log_event 'system' "$V_EVENT"
82+
83+
exit $OK

bin/v_add_dns_domain

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/bin/bash
2+
# info: adding dns domain
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
user="$1"
10+
domain=$(idn -t --quiet -u "$2" )
11+
domain_idn=$(idn -t --quiet -a "$domain")
12+
ip="$3"
13+
template="${4-default}"
14+
next_year=$(date +%d-%m-%y -d "+ 1 year")
15+
exp="${5-$next_year}"
16+
soa="$6"
17+
ttl="${7-14400}"
18+
19+
# Importing variables
20+
source $VESTA/conf/vars.conf
21+
source $V_FUNC/shared_func.sh
22+
source $V_FUNC/domain_func.sh
23+
24+
25+
#----------------------------------------------------------#
26+
# Verifications #
27+
#----------------------------------------------------------#
28+
29+
# Checking arg number
30+
check_args '3' "$#" 'user domain ip [template] [exp] [soa] [ttl]'
31+
32+
# Checking argument format
33+
format_validation 'user' 'domain' 'ip' 'template' 'exp' 'ttl'
34+
35+
# Checking dns system is enabled
36+
is_system_enabled 'dns'
37+
38+
# Checking user
39+
is_user_valid
40+
41+
# Checking user is active
42+
is_user_suspended
43+
44+
# Checking domain
45+
is_domain_new 'quiet'
46+
if [ $? -ne $OK ]; then
47+
48+
# Checking domain owner
49+
is_domain_owner
50+
51+
# Checking domain service
52+
is_dns_domain_free
53+
fi
54+
55+
# Checking package
56+
is_package_full 'dns'
57+
58+
# Checking template
59+
is_template_valid 'dns'
60+
61+
62+
#----------------------------------------------------------#
63+
# Action #
64+
#----------------------------------------------------------#
65+
66+
# Defining variables
67+
ns1=$(get_user_value '$NS1')
68+
ns2=$(get_user_value '$NS2')
69+
if [ -z "$soa" ]; then
70+
soa="$ns1"
71+
fi
72+
73+
# Adding zone to zones dir
74+
cat $V_DNSTPL/$template.tpl |\
75+
sed -e "s/%ip%/$ip/g" \
76+
-e "s/%domain_idn%/$domain_idn/g" \
77+
-e "s/%domain%/$domain/g" \
78+
-e "s/%ns1%/$ns1/g" \
79+
-e "s/%ns2%/$ns2/g" \
80+
-e "s/%date%/$V_DATE/g" > $V_USERS/$user/zones/$domain
81+
82+
# Adding dns.conf record
83+
dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
84+
dns_rec="$dns_rec SOA='$soa' SUSPEND='no' DATE='$V_DATE'"
85+
echo "$dns_rec" >> $V_USERS/$user/dns.conf
86+
87+
# Adding zone in named.conf
88+
named="zone \"$domain_idn\" {type master; file \"/etc/namedb/$domain.db\";};"
89+
echo "$named" >> /etc/named.conf
90+
91+
# Updating domain dns zone
92+
update_domain_zone
93+
94+
95+
#----------------------------------------------------------#
96+
# Vesta #
97+
#----------------------------------------------------------#
98+
99+
# Increasing domain value
100+
increase_user_value "$user" '$U_DNS_DOMAINS'
101+
102+
# Adding task to the vesta pipe
103+
restart_schedule 'dns'
104+
105+
# Logging
106+
log_history "$V_EVENT" "v_del_dns_domain $user $domain"
107+
log_event 'system' "$V_EVENT"
108+
109+
exit $OK

bin/v_add_dns_domain_record

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# info: adding dns domain record
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
user="$1"
10+
domain=$(idn -t --quiet -u "$2" )
11+
domain_idn=$(idn -t --quiet -a "$domain")
12+
record=$(idn -t --quiet -u "$3" )
13+
rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')
14+
value=$(idn -t --quiet -u "$5" )
15+
id="$6"
16+
17+
# Importing variables
18+
source $VESTA/conf/vars.conf
19+
source $V_FUNC/shared_func.sh
20+
source $V_FUNC/domain_func.sh
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
# Checking arg number
28+
check_args '5' "$#" 'user domain record type value [id]'
29+
30+
# Checking argument format
31+
format_validation 'user' 'domain' 'record' 'rtype'
32+
33+
# Checking web system is enabled
34+
is_system_enabled 'dns'
35+
36+
# Checking user
37+
is_user_valid
38+
39+
# Checking user is active
40+
is_user_suspended
41+
42+
# Checking domain exist
43+
is_dns_domain_valid
44+
45+
# Checking domain is active
46+
is_domain_suspended 'dns'
47+
48+
# Defining if emtpy
49+
if [ -z "$id"] ; then
50+
id=$(get_next_dns_record)
51+
fi
52+
53+
# Checking id format
54+
format_validation 'id'
55+
56+
# Checking id
57+
is_dns_record_free
58+
59+
60+
#----------------------------------------------------------#
61+
# Action #
62+
#----------------------------------------------------------#
63+
64+
# Defining zone path
65+
zone="$V_USERS/$user/zones/$domain"
66+
67+
# Adding record
68+
dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' VALUE='$value'"
69+
dns_rec="$dns_rec SUSPEND='no' DATE='$V_DATE'"
70+
echo "$dns_rec" >> $zone
71+
72+
# Sorting records
73+
sort_dns_records
74+
75+
# Updating zone
76+
update_domain_zone
77+
78+
79+
#----------------------------------------------------------#
80+
# Vesta #
81+
#----------------------------------------------------------#
82+
83+
# Adding task to the vesta pipe
84+
restart_schedule 'dns'
85+
86+
# Logging
87+
log_history "$V_EVENT" "v_del_dns_domain_record $user $domain $id"
88+
log_event 'system' "$V_EVENT"
89+
90+
exit $OK

0 commit comments

Comments
 (0)