mirror of
https://github.com/myvesta/vesta
synced 2025-07-16 10:03:23 -07:00
Merge remote-tracking branch 'serghey-rodin/master'
# Conflicts: # web/inc/i18n/tw.php
This commit is contained in:
commit
8b90f99d03
2171 changed files with 85582 additions and 10541 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
*.tar
|
||||
*.zip
|
||||
*.gzip
|
||||
*.gz
|
14
README.md
14
README.md
|
@ -13,17 +13,23 @@ Connect to your server as root via SSH
|
|||
ssh root@your.server
|
||||
```
|
||||
|
||||
Download the installation script
|
||||
Download the installation script, and run it:
|
||||
```bash
|
||||
curl http://vestacp.com/pub/vst-install.sh | bash
|
||||
```
|
||||
|
||||
If the above example does not work, try this 2 step method:
|
||||
|
||||
Download the installation script:
|
||||
```bash
|
||||
curl -O http://vestacp.com/pub/vst-install.sh
|
||||
```
|
||||
|
||||
Run it
|
||||
Then run it:
|
||||
```bash
|
||||
bash vst-install.sh
|
||||
```
|
||||
|
||||
License
|
||||
----------------------------
|
||||
Vesta is licensed under [GPL v3 ](https://github.com/serghey-rodin/vesta/blob/master/LICENSE.txt) license
|
||||
Vesta is licensed under [GPL v3 ](https://github.com/serghey-rodin/vesta/blob/master/LICENSE) license
|
||||
|
||||
|
|
66
bin/v-acknowledge-user-notification
Executable file
66
bin/v-acknowledge-user-notification
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash
|
||||
# info: update user notification
|
||||
# options: USER NOTIFICATION
|
||||
#
|
||||
# The function updates user notification.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
user=$1
|
||||
nid=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER NOTIFICATION'
|
||||
validate_format 'user' 'nid'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating notification
|
||||
update_object_value 'notifications' 'NID' "$nid" '$ACK' 'yes' 2>/dev/null
|
||||
|
||||
# Checking last notification
|
||||
if [ -e "$USER_DATA/notifications.conf" ]; then
|
||||
if [ -z "$(grep NID= $USER_DATA/notifications.conf)" ]; then
|
||||
notice='no'
|
||||
fi
|
||||
if [ -z "$(grep "ACK='no'" $USER_DATA/notifications.conf)" ]; then
|
||||
notice='no'
|
||||
fi
|
||||
else
|
||||
notice='no'
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating notification counter
|
||||
if [ "$notice" = 'no' ]; then
|
||||
if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then
|
||||
sed -i "s/^TIME/NOTIFICATIONS='no'\nTIME/g" $USER_DATA/user.conf
|
||||
else
|
||||
update_user_value "$user" '$NOTIFICATIONS' "no"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
67
bin/v-activate-vesta-license
Executable file
67
bin/v-activate-vesta-license
Executable file
|
@ -0,0 +1,67 @@
|
|||
#!/bin/bash
|
||||
# info: activate vesta license
|
||||
# options: MODULE LICENSE
|
||||
#
|
||||
# The function activates and registers the vesta license
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
module=$(echo $1 | tr '[:lower:]' '[:upper:]')
|
||||
license=$2
|
||||
|
||||
# Importing system environment
|
||||
source /etc/profile
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Checking arg number
|
||||
check_args '2' "$#" 'MODULE LICENSE'
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Activating license
|
||||
v_host='https://vestacp.com/checkout'
|
||||
answer=$(curl -s $v_host/activate.php?licence_key=$license&module=$module)
|
||||
check_result $? "cant' connect to vestacp.com " $E_CONNECT
|
||||
|
||||
# Checking server answer
|
||||
if [[ "$answer" != '0' ]]; then
|
||||
echo "Error: $module license $license is invalid"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating vesta.conf
|
||||
if [ -z "$(grep "${module}_KEY" $VESTA/conf/vesta.conf)" ]; then
|
||||
echo "${module}_KEY='$license'" >> $VESTA/conf/vesta.conf
|
||||
else
|
||||
sed -i "s/${module}_KEY=.*/${module}_KEY='$license'/g" $VESTA/conf/vesta.conf
|
||||
fi
|
||||
|
||||
# Activating sftpjail
|
||||
if [ "$module" = 'SFTPJAIL' ]; then
|
||||
setsid $BIN/v-add-sys-sftp-jail 2>/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -2,18 +2,18 @@
|
|||
# info: add backup host
|
||||
# options: TYPE HOST USERNAME PASSWORD [PATH] [PORT]
|
||||
#
|
||||
# The function adds backup host
|
||||
# This function adds a backup host
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
type=$1
|
||||
host=$2
|
||||
user=$3
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
path=${5-/backup}
|
||||
port=$6
|
||||
|
||||
|
@ -21,10 +21,6 @@ port=$6
|
|||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
# Defining ftp command function
|
||||
ftpc() {
|
||||
ftp -p -n $host $port <<EOF
|
||||
|
@ -102,11 +98,7 @@ if [ "$type" != 'local' ];then
|
|||
is_password_valid
|
||||
if [ "$type" = 'sftp' ]; then
|
||||
which expect >/dev/null 2>&1
|
||||
if [ $? -ne 0 ];then
|
||||
echo "Error: expect utility not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
check_result $? "expect command not found" $E_NOTEXIST
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
min=$2
|
||||
hour=$3
|
||||
|
@ -25,7 +25,7 @@ restart=$9
|
|||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Assing new value
|
||||
# Assigning new value
|
||||
A7="$command"
|
||||
|
||||
|
||||
|
@ -72,11 +72,9 @@ sync_cron_jobs
|
|||
# Increasing cron value
|
||||
increase_user_value $user '$U_CRON_JOBS'
|
||||
|
||||
# Restart crond
|
||||
# Restarting crond
|
||||
$BIN/v-restart-cron
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Cron restart failed" >/dev/null
|
||||
|
||||
# Logging
|
||||
log_history "added cron job $job"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: add cron reports
|
||||
# opions: user
|
||||
# options: user
|
||||
#
|
||||
# The script for enabling reports on cron tasks and administrative
|
||||
# notifications.
|
||||
|
@ -10,7 +10,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
|
||||
# Includes
|
||||
|
@ -46,9 +46,7 @@ sync_cron_jobs
|
|||
|
||||
# Restart crond
|
||||
$BIN/v-restart-cron
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Cron restart failed" >/dev/null
|
||||
|
||||
# Logging
|
||||
log_history "enabled cron reporting"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: add cron reports
|
||||
# opions: NONE
|
||||
# options: NONE
|
||||
#
|
||||
# The script for enabling restart cron tasks
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=admin
|
||||
|
||||
# Includes
|
||||
|
@ -34,7 +34,7 @@ fi
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Define time somewhere at nigth
|
||||
# Define time somewhere at night
|
||||
min=$(gen_password '012345' '2')
|
||||
hour=$(gen_password '1234567' '1')
|
||||
day='*'
|
||||
|
@ -66,11 +66,9 @@ sync_cron_jobs
|
|||
# Increasing cron value
|
||||
increase_user_value $user '$U_CRON_JOBS'
|
||||
|
||||
# Restart crond
|
||||
# Restarting crond
|
||||
$BIN/v-restart-cron
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Cron restart failed" >/dev/null
|
||||
|
||||
# Logging
|
||||
log_history "added cron job $job"
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
database="$user"_"$2"
|
||||
dbuser="$user"_"$3"
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
type=${5-mysql}
|
||||
host=$6
|
||||
charset=${7-UTF8}
|
||||
|
@ -30,10 +30,6 @@ source $VESTA/func/main.sh
|
|||
source $VESTA/func/db.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
type=$1
|
||||
host=$2
|
||||
dbuser=$3
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
max_db=${6-500}
|
||||
charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8}
|
||||
template=${8-template1}
|
||||
|
@ -27,10 +27,6 @@ source $VESTA/func/main.sh
|
|||
source $VESTA/func/db.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
is_mysql_host_alive() {
|
||||
mycnf=$(mktemp)
|
||||
echo "[client]">$mycnf
|
||||
|
@ -80,7 +76,7 @@ esac
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Concatentating db host string
|
||||
# Concatenating db host string
|
||||
case $type in
|
||||
mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass'";
|
||||
str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: add dns domain
|
||||
# options: USER DOMAIN IP [NS1] [NS2] [NS3] [NS4] [RESTART]
|
||||
# options: USER DOMAIN IP [NS1] [NS2] [NS3] [..] [NS8] [RESTART]
|
||||
#
|
||||
# The function adds DNS zone with records defined in the template. If the exp
|
||||
# argument isn't stated, the expiration date value will be set to next year.
|
||||
|
@ -13,7 +13,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
|
@ -24,7 +24,11 @@ ns1=$4
|
|||
ns2=$5
|
||||
ns3=$6
|
||||
ns4=$7
|
||||
restart=$8
|
||||
ns5=$8
|
||||
ns6=$9
|
||||
ns7=${10}
|
||||
ns8=${11}
|
||||
restart=${12}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -36,14 +40,13 @@ source $VESTA/conf/vesta.conf
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN IP [NS1] [NS2] [NS3] [NS4]'
|
||||
check_args '3' "$#" 'USER DOMAIN IP [NS1] [NS2] [NS3] [..] [NS8] [RESTART]'
|
||||
validate_format 'user' 'domain' 'ip'
|
||||
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_domain_new 'dns'
|
||||
is_package_full 'DNS_DOMAINS'
|
||||
|
||||
template=$(get_user_value '$DNS_TEMPLATE')
|
||||
is_dns_template_valid
|
||||
|
||||
|
@ -64,6 +67,23 @@ if [ ! -z "$ns4" ]; then
|
|||
ns4=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns4'
|
||||
fi
|
||||
if [ ! -z "$ns5" ]; then
|
||||
ns5=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns5'
|
||||
fi
|
||||
if [ ! -z "$ns6" ]; then
|
||||
ns6=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns6'
|
||||
fi
|
||||
if [ ! -z "$ns7" ]; then
|
||||
ns7=$(echo ${10} | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns7'
|
||||
fi
|
||||
|
||||
if [ ! -z "$ns8" ]; then
|
||||
ns8=$(echo ${11} | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns8'
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -81,6 +101,7 @@ if [ -z $ns2 ]; then
|
|||
fi
|
||||
soa="$ns1"
|
||||
exp=$(date +%F -d "+ 1 year")
|
||||
serial=$(date +'%Y%m%d01')
|
||||
ttl=14400
|
||||
|
||||
# Reading template
|
||||
|
@ -93,8 +114,20 @@ fi
|
|||
if [ -z "$ns4" ]; then
|
||||
template_data=$(echo "$template_data" |grep -v %ns4%)
|
||||
fi
|
||||
if [ -z "$ns5" ]; then
|
||||
template_data=$(echo "$template_data" |grep -v %ns5%)
|
||||
fi
|
||||
if [ -z "$ns6" ]; then
|
||||
template_data=$(echo "$template_data" |grep -v %ns6%)
|
||||
fi
|
||||
if [ -z "$ns7" ]; then
|
||||
template_data=$(echo "$template_data" |grep -v %ns7%)
|
||||
fi
|
||||
if [ -z "$ns8" ]; then
|
||||
template_data=$(echo "$template_data" |grep -v %ns8%)
|
||||
fi
|
||||
|
||||
# Add dns zone to the user config
|
||||
# Adding dns zone to the user config
|
||||
echo "$template_data" |\
|
||||
sed -e "s/%ip%/$ip/g" \
|
||||
-e "s/%domain_idn%/$domain_idn/g" \
|
||||
|
@ -103,6 +136,10 @@ echo "$template_data" |\
|
|||
-e "s/%ns2%/$ns2/g" \
|
||||
-e "s/%ns3%/$ns3/g" \
|
||||
-e "s/%ns4%/$ns4/g" \
|
||||
-e "s/%ns5%/$ns5/g" \
|
||||
-e "s/%ns6%/$ns6/g" \
|
||||
-e "s/%ns7%/$ns7/g" \
|
||||
-e "s/%ns8%/$ns8/g" \
|
||||
-e "s/%time%/$TIME/g" \
|
||||
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
|
||||
|
||||
|
@ -111,13 +148,13 @@ records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')"
|
|||
|
||||
# Adding dns.conf record
|
||||
dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
|
||||
dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'"
|
||||
dns_rec="$dns_rec DATE='$DATE'"
|
||||
dns_rec="$dns_rec SOA='$soa' SERIAL='$serial' SRC='' RECORDS='$records'"
|
||||
dns_rec="$dns_rec SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
|
||||
|
||||
echo "$dns_rec" >> $USER_DATA/dns.conf
|
||||
chmod 660 $USER_DATA/dns.conf
|
||||
|
||||
# Create system configs
|
||||
# Creating system configs
|
||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||
if [ -e '/etc/named.conf' ]; then
|
||||
dns_conf='/etc/named.conf'
|
||||
|
@ -135,14 +172,14 @@ if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
|||
# Updating domain dns zone
|
||||
update_domain_zone
|
||||
|
||||
# Set permissions
|
||||
chmod 640 $conf
|
||||
chown root:$dns_group $conf
|
||||
# Changing permissions
|
||||
chmod 640 $HOMEDIR/$user/conf/dns/$domain.db
|
||||
chown root:$dns_group $HOMEDIR/$user/conf/dns/$domain.db
|
||||
fi
|
||||
|
||||
# Updating dns-cluster queue
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="$BIN/v-add-remote-dns-domain $user $domain no"
|
||||
cmd="$BIN/v-add-remote-dns-domain $user $domain yes"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
@ -158,9 +195,7 @@ increase_user_value "$user" '$U_DNS_RECORDS' "$records"
|
|||
# Restart named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "DNS restart failed"
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: add dns domain or dns record based on web domain alias restart
|
||||
# options: USER DOMAIN
|
||||
# info: add dns domain or dns record after web domain alias
|
||||
# options: USER ALIAS IP [RESTART]
|
||||
#
|
||||
# The function adds dns domain or dns record based on web domain alias.
|
||||
|
||||
|
@ -9,15 +9,11 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
dom_alias=$(idn -t --quiet -u "$3" )
|
||||
dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
|
||||
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
|
||||
restart="$4"
|
||||
alias=$2
|
||||
ip=$3
|
||||
restart=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -29,58 +25,54 @@ source $VESTA/conf/vesta.conf
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN ALIAS'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
check_args '3' "$#" 'USER ALIAS IP [RESTART]'
|
||||
validate_format 'user' 'alias' 'ip'
|
||||
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||
if [ -e "$USER_DATA/dns/$alias.conf" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
# Check if it a simple domain
|
||||
if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then
|
||||
if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then
|
||||
# Define additional vars
|
||||
sub_domain=$(echo "$alias" |awk -F '.' '{print $1}')
|
||||
top_domain=$(echo "$alias" |sed -e "s/^$sub_domain.//")
|
||||
domain_lvl=$(echo "$alias" |grep -o "\." |wc -l)
|
||||
|
||||
# Adding second level domain
|
||||
if [ "$domain_lvl" -eq 1 ] || [ "${#top_domain}" -le '6' ]; then
|
||||
$BIN/v-add-dns-domain \
|
||||
$user $dom_alias $IP '' '' '' '' '' $restart > /dev/null
|
||||
fi
|
||||
else
|
||||
# Check subdomain
|
||||
sub=$(echo "$dom_alias" | cut -f1 -d . -s)
|
||||
dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" )
|
||||
|
||||
# Ignore short domains like co.uk, com.au and so on
|
||||
if [ "${#dom}" -le '6' ]; then
|
||||
$user $alias $ip '' '' '' '' '' $restart >> /dev/null
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
|
||||
$BIN/v-add-dns-domain \
|
||||
$user $dom $IP '' '' '' '' $restart > /dev/null
|
||||
# Adding top-level domain and then its sub
|
||||
$BIN/v-add-dns-domain $user $top_domain $ip '' '' '' '' $restart >> /dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
$BIN/v-add-dns-record \
|
||||
$user $dom "$sub" A $IP '' '' $restart
|
||||
# Checking top-level domain
|
||||
if [ ! -e "$USER_DATA/dns/$top_domain.conf" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Checking subdomain record
|
||||
if [ "$sub_domain" == '*' ]; then
|
||||
check_record=$(grep -w "RECORD='\*'" $USER_DATA/dns/$top_domain.conf)
|
||||
else
|
||||
if [ "$sub" == '*' ]; then
|
||||
rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf)
|
||||
else
|
||||
rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
|
||||
check_record=$(grep -w "RECORD='$sub_domain'" $USER_DATA/dns/$top_domain.conf)
|
||||
fi
|
||||
if [ -z "$rec" ]; then
|
||||
|
||||
# Adding subdomain record
|
||||
if [ -z "$check_record" ]; then
|
||||
$BIN/v-add-dns-record \
|
||||
$user $dom "$sub" A $IP '' '' $restart > /dev/null
|
||||
fi
|
||||
fi
|
||||
$user $top_domain "$sub_domain" A $ip '' '' $restart >> /dev/null
|
||||
fi
|
||||
|
||||
|
||||
|
@ -88,6 +80,6 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# No Logging
|
||||
# No logging
|
||||
|
||||
exit
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
@ -82,6 +82,7 @@ sort_dns_records
|
|||
|
||||
# Updating zone
|
||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||
update_domain_serial
|
||||
update_domain_zone
|
||||
fi
|
||||
|
||||
|
@ -100,7 +101,7 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Upddate counters
|
||||
# Update counters
|
||||
records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
|
||||
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
|
||||
increase_user_value "$user" '$U_DNS_RECORDS'
|
||||
|
@ -108,9 +109,7 @@ increase_user_value "$user" '$U_DNS_RECORDS'
|
|||
# Restart named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? $E_RESTART 'dns failed to restart'
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -47,37 +47,34 @@ if [ -z "$ip" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Web domain
|
||||
# Working on web domain
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
$BIN/v-add-web-domain $user $domain $ip 'no'
|
||||
return_code=$?
|
||||
check_result $? "can't add web domain" >/dev/null
|
||||
fi
|
||||
|
||||
# Proxy support
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
||||
extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls"
|
||||
extentions="$extentions,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav"
|
||||
extentions="$extentions,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
|
||||
$BIN/v-add-web-domain-proxy $user $domain 'default' "$extentions" 'no'
|
||||
# Working on DNS domain
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
$BIN/v-add-dns-domain $user $domain $ip "" "" "" "" "" 'no'
|
||||
check_result $? "can't add dns domain" >/dev/null
|
||||
fi
|
||||
|
||||
# DNS domain
|
||||
if [ ! -z "$DNS_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
||||
$BIN/v-add-dns-domain $user $domain $ip 'no'
|
||||
return_code=$?
|
||||
fi
|
||||
|
||||
# Mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
||||
# Working on mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
$BIN/v-add-mail-domain $user $domain
|
||||
return_code=$?
|
||||
check_result $? "can't add mail domain" >/dev/null
|
||||
fi
|
||||
|
||||
# Restart services
|
||||
if [ "$restart" != 'no' ] && [ "$return_code" -eq 0 ]; then
|
||||
# Restarting services
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
check_result $? "can't restart web" > /dev/null
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "can't restart proxy" > /dev/null
|
||||
fi
|
||||
$BIN/v-restart-dns
|
||||
check_result $? "can't restart dns" > /dev/null
|
||||
fi
|
||||
|
||||
|
||||
|
@ -85,4 +82,4 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit $return_code
|
||||
exit
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# Importing system variables
|
||||
source /etc/profile
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
ip=$1
|
||||
chain=$(echo $2|tr '[:lower:]' '[:upper:]')
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# Importing system variables
|
||||
source /etc/profile
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
chain=$(echo $1 | tr '[:lower:]' '[:upper:]')
|
||||
port=$2
|
||||
protocol=${4-TCP}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# Importing system variables
|
||||
source /etc/profile
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
action=$(echo $1|tr '[:lower:]' '[:upper:]')
|
||||
ip=$2
|
||||
port_ext=$3
|
||||
|
|
56
bin/v-add-fs-archive
Executable file
56
bin/v-add-fs-archive
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/bin/bash
|
||||
# info: archive directory
|
||||
# options: USER ARCHIVE SOURCE
|
||||
#
|
||||
# The function creates tar archive
|
||||
|
||||
user=$1
|
||||
archive=$2
|
||||
src=$3
|
||||
|
||||
# Checking arguments
|
||||
if [ -z "$src" ]; then
|
||||
echo "Usage: USER ARCHIVE SOURCE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking vesta user
|
||||
if [ ! -e "$VESTA/data/users/$user" ]; then
|
||||
echo "Error: vesta user $user doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Checking user homedir
|
||||
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
||||
if [ -z $homedir ]; then
|
||||
echo "Error: user home directory doesn't exist"
|
||||
exit 12
|
||||
fi
|
||||
|
||||
# Checking archive
|
||||
if [ -e "$archive.tar.gz" ]; then
|
||||
echo "Error: archive already exist $archive.tar.gz"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking source path
|
||||
rpath=$(readlink -f "$src")
|
||||
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||
echo "Error: invalid source path $src"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Parsing current directory
|
||||
d=$(dirname "$src")
|
||||
|
||||
# Removing leading file path
|
||||
f=$(echo "$src" |sed -e "s|$d/||")
|
||||
|
||||
# Creating tar.gz archive
|
||||
sudo -u $user tar -czf "$archive.tar.gz" -C $d $f >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo "Error: archive $archive.tar.gz was not created"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
exit
|
44
bin/v-add-fs-directory
Executable file
44
bin/v-add-fs-directory
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
# info: add directory
|
||||
# options: USER DIRECTORY
|
||||
#
|
||||
# The function creates new directory on the file system
|
||||
|
||||
user=$1
|
||||
dst_dir=$2
|
||||
|
||||
# Checking arguments
|
||||
if [ -z "$dst_dir" ]; then
|
||||
echo "Usage: USER DIRECTORY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking vesta user
|
||||
if [ ! -e "$VESTA/data/users/$user" ]; then
|
||||
echo "Error: vesta user $user doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Checking user homedir
|
||||
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
||||
if [ -z $homedir ]; then
|
||||
echo "Error: user home directory doesn't exist"
|
||||
exit 12
|
||||
fi
|
||||
|
||||
# Checking destination path
|
||||
rpath=$(readlink -f "$dst_dir")
|
||||
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||
echo "Error: invalid destination path $dst_dir"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Adding directory
|
||||
sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: directory $dst_dir was not created"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Extiging
|
||||
exit
|
44
bin/v-add-fs-file
Executable file
44
bin/v-add-fs-file
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
# info: add file
|
||||
# options: USER FILE
|
||||
#
|
||||
# The function creates new files on file system
|
||||
|
||||
user=$1
|
||||
dst_file=$2
|
||||
|
||||
# Checking arguments
|
||||
if [ -z "$dst_file" ]; then
|
||||
echo "Usage: USER FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking vesta user
|
||||
if [ ! -e "$VESTA/data/users/$user" ]; then
|
||||
echo "Error: vesta user $user doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Checking user homedir
|
||||
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
||||
if [ -z $homedir ]; then
|
||||
echo "Error: user home directory doesn't exist"
|
||||
exit 12
|
||||
fi
|
||||
|
||||
# Checking destination path
|
||||
rpath=$(readlink -f "$dst_file")
|
||||
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||
echo "Error: invalid destination path $dst_dir"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Creating file
|
||||
sudo -u $user touch "$dst_file" >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: file $dst_file was not created"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Exiting
|
||||
exit
|
|
@ -9,13 +9,13 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
account=$(echo $3 | tr '[:upper:]' '[:lower:]')
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
quota=${5-unlimited}
|
||||
|
||||
# Includes
|
||||
|
@ -23,10 +23,6 @@ source $VESTA/func/main.sh
|
|||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
# info: add mail domain antispam support
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function enables spamassasin for incomming emails.
|
||||
# The function enables spamassasin for incoming emails.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
# info: add mail domain antivirus support
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function enables clamav scan for incomming emails.
|
||||
# The function enables clamav scan for incoming emails.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
# info: add mail domain catchall account
|
||||
# options: USER DOMAIN EMAIL
|
||||
#
|
||||
# The function enables catchall account for incomming emails.
|
||||
# The function enables catchall account for incoming emails.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$2
|
||||
flush=$3
|
||||
|
@ -27,101 +27,64 @@ source $VESTA/conf/vesta.conf
|
|||
check_args '2' "$#" 'USER DOMAIN [FLUSH]'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||
check_result $E_EXISTS "another sync process already running"
|
||||
fi
|
||||
remote_dns_health_check
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Check domain existance
|
||||
check_local_domain=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf 2>/dev/null)
|
||||
if [ -z "$check_local_domain" ]; then
|
||||
# Parsing domain record
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf 2>/dev/null)
|
||||
if [ -z "$str" ]; then
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
queue_str=$(grep -n "$SCRIPT $1 $2 " $pipe |cut -f1 -d: |head -n1)
|
||||
if [ ! -z "$queue_str" ]; then
|
||||
sed -i "$queue_str d" $pipe
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Check remote dns nodes
|
||||
remote_dns_health_check
|
||||
# Parsing remote dns host parameters
|
||||
eval $cluster
|
||||
|
||||
search_str=$(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf)
|
||||
for cluster_str in $search_str; do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Check flush parameters
|
||||
|
||||
# Sync domain
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
# Parsing domain parameters
|
||||
eval $str
|
||||
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME "$flush" 'no'
|
||||
if [ $? -eq 0 ]; then
|
||||
# Sync records
|
||||
if [ "$TYPE" = 'ssh' ]; then
|
||||
tmp=$(mktemp -u)
|
||||
scp_cmd $USER_DATA/dns/$DOMAIN.conf $tmp
|
||||
$send_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp 'no'
|
||||
else
|
||||
for str in $(cat $USER_DATA/dns/$DOMAIN.conf); do
|
||||
str=$(echo "$str" | sed 's/"/\\"/g')
|
||||
$send_cmd v-insert-dns-record $DNS_USER $DOMAIN "$str"
|
||||
done
|
||||
fi
|
||||
# Syncing domain data
|
||||
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME $flush 'no'
|
||||
check_result $? "$HOST connection failed" $E_CONNECT
|
||||
|
||||
# Rebuild dns zone
|
||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
fi
|
||||
# Syncing domain records
|
||||
tmp_file="/tmp/vst-sync.$DOMAIN"
|
||||
cluster_file $USER_DATA/dns/$DOMAIN.conf $tmp_file
|
||||
check_result $? "$HOST connection failed" $E_CONNECT
|
||||
|
||||
# Inserting synced records
|
||||
cluster_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp_file 'no'
|
||||
check_result $? "$HOST connection failed" $E_CONNECT
|
||||
|
||||
# Rebuilding dns zone
|
||||
cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
|
||||
check_result $? "$HOST connection failed" $E_CONNECT
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating pipe
|
||||
rm -f $tmpfile
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 " $pipe | cut -f1 -d: | head -n1)
|
||||
|
@ -129,8 +92,4 @@ if [ ! -z "$str" ]; then
|
|||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
||||
|
|
|
@ -9,12 +9,17 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
host=$1
|
||||
HOST=$host
|
||||
port=$2
|
||||
PORT=$port
|
||||
user=$3
|
||||
password=$4
|
||||
USER=$user
|
||||
password=$4; HIDE=4
|
||||
PASSWORD=$password
|
||||
type=${5-api}
|
||||
TYPE="$type"
|
||||
dns_user=${6-dns-cluster}
|
||||
DNS_USER=$dns_user
|
||||
|
||||
|
@ -23,10 +28,6 @@ source $VESTA/func/main.sh
|
|||
source $VESTA/func/remote.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding passwords
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -61,36 +62,26 @@ else
|
|||
sed -i "s/DNS_CLUSTER=.*/DNS_CLUSTER='yes'/g" $VESTA/conf/vesta.conf
|
||||
fi
|
||||
|
||||
# Enabling restart queue
|
||||
HOST=$host
|
||||
PORT=$port
|
||||
USER=$user
|
||||
PASSWORD=$password
|
||||
case $type in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
$send_cmd v-add-cron-restart-job
|
||||
# Enabling remote dns-cluster queue
|
||||
cluster_cmd v-add-cron-restart-job
|
||||
check_result $? "$HOST connection failed" $E_CONNECT
|
||||
|
||||
# Sync current zones
|
||||
# Syncing all domains
|
||||
$BIN/v-sync-dns-cluster $host
|
||||
return_code=$?
|
||||
if [ "$return_code" -ne 0 ]; then
|
||||
exit $return_code
|
||||
fi
|
||||
|
||||
# Add dns-cluster cron job
|
||||
cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster"
|
||||
check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null)
|
||||
if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then
|
||||
$BIN/v-add-cron-job admin '*/5' '*' '*' '*' '*' "$cmd"
|
||||
fi
|
||||
check_result $? "$HOST sync failed" $E_CONNECT
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Adding local dns-cluster cron job
|
||||
cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster"
|
||||
check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null)
|
||||
if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then
|
||||
$BIN/v-add-cron-job admin '*/5' '*' '*' '*' '*' "$cmd"
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$2
|
||||
id=$3
|
||||
|
@ -29,83 +29,62 @@ validate_format 'user' 'domain' 'id'
|
|||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
is_object_valid "dns/$domain" 'ID' "$id"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||
check_result $E_EXISTS "another sync process already running"
|
||||
fi
|
||||
remote_dns_health_check
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Check remote dns nodes
|
||||
remote_dns_health_check
|
||||
|
||||
for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync record
|
||||
# Parsing record
|
||||
str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
|
||||
str=$(echo "$str" | sed 's/"/\\"/g')
|
||||
$send_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no'
|
||||
if [ $? -eq 0 ]; then
|
||||
# Rebuild dns zone
|
||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
if [ -z "$str" ]; then
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
queue_str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$queue_str" ]; then
|
||||
sed -i "$queue_str d" $pipe
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
IFS=$'\n'
|
||||
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Parsing remote host parameters
|
||||
eval $cluster
|
||||
|
||||
# Syncing serial
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
|
||||
check_result $? "$HOST connection failed (soa sync)" $E_CONNECT
|
||||
|
||||
# Syncing record
|
||||
str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf | sed 's/"/\\"/g')
|
||||
cluster_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no'
|
||||
check_result $? "$HOST connection failed (record sync)" $E_CONNECT
|
||||
|
||||
# Rebuilding dns zone
|
||||
cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
|
||||
check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
exit
|
||||
|
|
57
bin/v-add-sys-firewall
Executable file
57
bin/v-add-sys-firewall
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
# info: add system firewall
|
||||
# options: NONE
|
||||
#
|
||||
# The script enables firewall
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
if [ "$FIREWALL_SYSTEM" = 'iptables' ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Adding firewall directory
|
||||
mkdir -p $VESTA/data/firewall/
|
||||
|
||||
# Adding default ruleset
|
||||
if [ ! -e "$VESTA/data/firewall/rules.conf" ]; then
|
||||
cp $VESTA/install/rhel/7/* $VESTA/data/firewall/
|
||||
fi
|
||||
|
||||
# Updating FIREWAL_SYSTEM value
|
||||
if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then
|
||||
echo "FIREWALL_SYSTEM='iptables'" >> $VESTA/conf/vesta.conf
|
||||
else
|
||||
sed -i "s/FIREWALL_SYSTEM.*/FIREWALL_SYSTEM='iptables'/g" \
|
||||
$VESTA/conf/vesta.conf
|
||||
fi
|
||||
|
||||
# Updating firewall rules
|
||||
$BIN/v-update-firewall
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -5,7 +5,7 @@
|
|||
# The function adds ip address into a system. It also creates rc scripts. You
|
||||
# can specify ip name which will be used as root domain for temporary aliases.
|
||||
# For example, if you set a1.myhosting.com as name, each new domain created on
|
||||
# this ip will automaticaly receive alias $domain.a1.myhosting.com. Of course
|
||||
# this ip will automatically receive alias $domain.a1.myhosting.com. Of course
|
||||
# you must have wildcard record *.a1.myhosting.com pointed to ip. This feature
|
||||
# is very handy when customer wants to test domain before dns migration.
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
ip=${1// /}
|
||||
netmask=$2
|
||||
interface="${3-eth0}"
|
||||
|
@ -161,16 +161,12 @@ fi
|
|||
|
||||
# Restarting web server
|
||||
$BIN/v-restart-web
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
# Restarting proxy server
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Restarting firewall
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
# info: add system quota
|
||||
# opions: NONE
|
||||
# options: NONE
|
||||
#
|
||||
# The script enables filesystem quota on /home patition
|
||||
# The script enables filesystem quota on /home partition
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -19,21 +19,15 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking quota package
|
||||
if [ ! -e "/usr/sbin/setquota" ]; then
|
||||
quota=$(which --skip-alias --skip-functions quota 2>/dev/null)
|
||||
if [ $? -ne 0 ]; then
|
||||
if [ -e "/etc/redhat-release" ]; then
|
||||
yum -y install quota >/dev/null 2>&1
|
||||
result=$?
|
||||
check_result $? "quota package installation failed" $E_UPDATE
|
||||
else
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get -y install quota >/dev/null 2>&1
|
||||
result=$?
|
||||
fi
|
||||
|
||||
# Checking installation status
|
||||
if [ "$result" -ne 0 ]; then
|
||||
echo "Error: quota package wasn't successfully installed"
|
||||
log_event "$E_UPDATE" "$EVENT"
|
||||
exit $E_UPDATE
|
||||
check_result $? "quota package installation failed" $E_UPDATE
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -42,38 +36,40 @@ fi
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Adding usrquota option on /home partition
|
||||
# Adding group and user quota on /home partition
|
||||
mnt=$(df -P /home | awk '{print $6}' | tail -n1)
|
||||
lnr=$(cat -n /etc/fstab | awk '{print $1,$3}' | grep "$mnt$" | cut -f 1 -d ' ')
|
||||
options=$(sed -n ${lnr}p /etc/fstab |awk '{print $4}')
|
||||
if [ -z "$(echo $options |grep usrquota)" ]; then
|
||||
sed -i "$lnr s/$options/$options,usrquota/" /etc/fstab
|
||||
opt=$(sed -n ${lnr}p /etc/fstab | awk '{print $4}')
|
||||
fnd='usrquota\|grpquota\|usrjquota=aquota.user\|grpjquota=aquota.group\|jqfmt=vfsv0'
|
||||
if [ $(echo $opt | tr ',' '\n' | grep -x $fnd | wc -l) -ne 5 ]; then
|
||||
old=$(echo $(echo $opt | tr ',' '\n' | grep -v 'usrquota\|grpquota\|usrjquota=\|grpjquota=\|jqfmt=') | tr ' ' ',')
|
||||
new='usrquota,grpquota,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0'
|
||||
sed -i "$lnr s/$opt/$old,$new/" /etc/fstab
|
||||
mount -o remount $mnt
|
||||
fi
|
||||
|
||||
# Adding aquota.user file
|
||||
if [ ! -e "$mnt/aquota.user" ]; then
|
||||
quotacheck -cu $mnt >/dev/null 2>&1
|
||||
# Adding v2 group and user quota index
|
||||
if [ ! -e "$mnt/aquota.user" ] || [ ! -e "$mnt/aquota.group" ]; then
|
||||
quotaoff $mnt
|
||||
quotacheck -cug $mnt >/dev/null 2>&1
|
||||
quotacheck -aug >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Building fs quota index
|
||||
quotacheck -um $mnt
|
||||
# Adding quotacheck on reboot
|
||||
touch /forcequotacheck
|
||||
|
||||
# Adding weekly cron job
|
||||
echo "quotacheck -um $mnt" > /etc/cron.daily/quotacheck
|
||||
# Adding cron job
|
||||
echo '#!/bin/bash' > /etc/cron.daily/quotacheck
|
||||
echo 'touch /forcequotacheck' >> /etc/cron.daily/quotacheck
|
||||
chmod a+x /etc/cron.daily/quotacheck
|
||||
|
||||
# Enabling fs quota
|
||||
if [ ! -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
|
||||
# Enabling group and user quota
|
||||
if [ ! -z "$(quotaon -pa | grep " $mnt " | grep 'user\|group' | grep 'is off')" ]; then
|
||||
quotaon $mnt
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: quota can't be enabled on $mnt partition"
|
||||
log_event "$E_DISK" "$EVENT"
|
||||
exit $E_DISK
|
||||
fi
|
||||
check_result $? "quota can't be enabled in $mnt" $E_DISK
|
||||
fi
|
||||
|
||||
# Updating DISK_QUOTA value
|
||||
# Updating vesta.conf value
|
||||
if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then
|
||||
echo "DISK_QUOTA='yes'" >> $VESTA/conf/vesta.conf
|
||||
else
|
||||
|
|
106
bin/v-add-sys-sftp-jail
Executable file
106
bin/v-add-sys-sftp-jail
Executable file
|
@ -0,0 +1,106 @@
|
|||
#!/bin/bash
|
||||
# info: add system sftp jail
|
||||
# options: NONE
|
||||
#
|
||||
# The script enables sftp jailed environment
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Importing system environment as we run this script
|
||||
# mostly by cron which do not read it by itself
|
||||
source /etc/profile
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
if [ -z "$SFTPJAIL_KEY" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Checking sshd directives
|
||||
config='/etc/ssh/sshd_config'
|
||||
sftp_n=$(grep -n "Subsystem.*sftp" $config |grep -v internal |grep -v ":#")
|
||||
sftp_i=$(grep -n "Subsystem.*sftp" $config |grep internal |grep -v ":#")
|
||||
|
||||
# Disabling normal sftp
|
||||
if [ ! -z "$sftp_n" ]; then
|
||||
fline=$(echo $sftp_n |cut -f 1 -d :)
|
||||
sed -i "${fline}s/Subsystem.*sftp/#Subsystem sftp/" $config
|
||||
restart='yes'
|
||||
fi
|
||||
|
||||
# Enabling jailed sftp
|
||||
if [ -z "$sftp_i" ]; then
|
||||
echo "Subsystem sftp internal-sftp" >> $config
|
||||
echo "Match Group sftp-only" >> $config
|
||||
echo "ChrootDirectory /chroot/%u" >> $config
|
||||
echo " AllowTCPForwarding no" >> $config
|
||||
echo " X11Forwarding no" >> $config
|
||||
echo " ForceCommand internal-sftp" >> $config
|
||||
restart='yes'
|
||||
fi
|
||||
|
||||
# Validating opensshd config
|
||||
if [ "$restart" = 'yes' ]; then
|
||||
subj="OpenSSH restart failed"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
/usr/sbin/sshd -t >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
mail_text="OpenSSH can not be restarted. Please check config:
|
||||
\n\n$(/usr/sbin/sshd -t)"
|
||||
echo -e "$mail_text" | $send_mail -s "$subj" $email
|
||||
else
|
||||
service ssh restart >/dev/null 2>&1
|
||||
service sshd restart >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Adding sftp group
|
||||
groupadd sftp-only 2>/dev/null
|
||||
|
||||
# Checking users
|
||||
shells="rssh|nologin"
|
||||
for user in $(grep "$HOMEDIR" /etc/passwd |egrep "$shells" |cut -f 1 -d:); do
|
||||
$BIN/v-add-user-sftp-jail $user
|
||||
done
|
||||
|
||||
# Adding v-add-sys-sftp-jail to startup
|
||||
if [ -e "/etc/rc.local" ]; then
|
||||
check_sftp=$(grep $0 /etc/rc.local)
|
||||
check_exit=$(grep ^exit /etc/rc.local)
|
||||
if [ -z "$check_sftp" ]; then
|
||||
if [ -z "$check_exit" ]; then
|
||||
echo "$BIN/v-add-sys-sftp-jail" >> /etc/rc.local
|
||||
else
|
||||
sed -i "s|^exit|$BIN/v-add-sys-sftp-jail\nexit|" /etc/rc.local
|
||||
fi
|
||||
fi
|
||||
chmod +x /etc/rc.local
|
||||
else
|
||||
echo "$BIN/v-add-sys-sftp-jail" > /etc/rc.local
|
||||
chmod +x /etc/rc.local
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -9,9 +9,9 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
password=$2
|
||||
password=$2; HIDE=2
|
||||
email=$3
|
||||
package=${4-default}
|
||||
fname=$5
|
||||
|
@ -21,10 +21,6 @@ lname=$6
|
|||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A2='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
is_user_free() {
|
||||
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
|
||||
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
|
||||
|
@ -62,11 +58,7 @@ shell=$(grep -w "$shell_conf" /etc/shells |head -n1)
|
|||
|
||||
# Adding user
|
||||
/usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: user creation failed"
|
||||
log_event "$E_INVALID" "$EVENT"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
check_result $? "user creation failed" $E_INVALID
|
||||
|
||||
# Adding password
|
||||
echo "$user:$password" | /usr/sbin/chpasswd
|
||||
|
@ -75,21 +67,15 @@ echo "$user:$password" | /usr/sbin/chpasswd
|
|||
mkdir $HOMEDIR/$user/conf
|
||||
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
mkdir $HOMEDIR/$user/conf/web
|
||||
mkdir $HOMEDIR/$user/web
|
||||
mkdir $HOMEDIR/$user/tmp
|
||||
chmod 751 $HOMEDIR/$user/conf/web
|
||||
chmod 751 $HOMEDIR/$user/web
|
||||
mkdir $HOMEDIR/$user/conf/web $HOMEDIR/$user/web $HOMEDIR/$user/tmp
|
||||
chmod 751 $HOMEDIR/$user/conf/web $HOMEDIR/$user/web
|
||||
chmod 771 $HOMEDIR/$user/tmp
|
||||
chown $user:$user $HOMEDIR/$user/web
|
||||
chown $user:$user $HOMEDIR/$user/tmp
|
||||
chown $user:$user $HOMEDIR/$user/web $HOMEDIR/$user/tmp
|
||||
fi
|
||||
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
mkdir $HOMEDIR/$user/conf/mail
|
||||
mkdir $HOMEDIR/$user/mail
|
||||
chmod 751 $HOMEDIR/$user/mail
|
||||
chmod 751 $HOMEDIR/$user/conf/mail
|
||||
mkdir $HOMEDIR/$user/conf/mail $HOMEDIR/$user/mail
|
||||
chmod 751 $HOMEDIR/$user/mail $HOMEDIR/$user/conf/mail
|
||||
fi
|
||||
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
|
@ -107,54 +93,47 @@ chattr +i $HOMEDIR/$user/conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Adding user dir
|
||||
mkdir $USER_DATA
|
||||
chmod 770 $USER_DATA
|
||||
mkdir -p $USER_DATA/ssl $USER_DATA/dns $USER_DATA/mail
|
||||
|
||||
# Creating configuration files and pipes
|
||||
touch $USER_DATA/backup.conf
|
||||
chmod 660 $USER_DATA/backup.conf
|
||||
touch $USER_DATA/history.log
|
||||
chmod 660 $USER_DATA/history.log
|
||||
touch $USER_DATA/stats.log
|
||||
chmod 660 $USER_DATA/stats.log
|
||||
touch $USER_DATA/backup.conf \
|
||||
$USER_DATA/history.log \
|
||||
$USER_DATA/stats.log \
|
||||
$USER_DATA/web.conf \
|
||||
$USER_DATA/dns.conf \
|
||||
$USER_DATA/mail.conf \
|
||||
$USER_DATA/db.conf \
|
||||
$USER_DATA/cron.conf
|
||||
|
||||
chmod 770 $USER_DATA \
|
||||
$USER_DATA/ssl \
|
||||
$USER_DATA/dns \
|
||||
$USER_DATA/mail
|
||||
|
||||
chmod 660 $USER_DATA/backup.conf \
|
||||
$USER_DATA/history.log \
|
||||
$USER_DATA/stats.log \
|
||||
$USER_DATA/web.conf \
|
||||
$USER_DATA/dns.conf \
|
||||
$USER_DATA/mail.conf \
|
||||
$USER_DATA/db.conf \
|
||||
$USER_DATA/cron.conf
|
||||
|
||||
# Updating queue pipes
|
||||
echo "$BIN/v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe
|
||||
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
mkdir $USER_DATA/ssl
|
||||
chmod 770 $USER_DATA/ssl
|
||||
touch $USER_DATA/web.conf
|
||||
chmod 660 $USER_DATA/web.conf
|
||||
echo "$BIN/v-update-web-domains-traff $user" \
|
||||
>> $VESTA/data/queue/traffic.pipe
|
||||
echo "$BIN/v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe
|
||||
fi
|
||||
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
mkdir $USER_DATA/dns
|
||||
chmod 770 $USER_DATA/dns
|
||||
touch $USER_DATA/dns.conf
|
||||
chmod 660 $USER_DATA/dns.conf
|
||||
fi
|
||||
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
mkdir $USER_DATA/mail
|
||||
chmod 770 $USER_DATA/mail
|
||||
touch $USER_DATA/mail.conf
|
||||
chmod 660 $USER_DATA/mail.conf
|
||||
echo "$BIN/v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe
|
||||
fi
|
||||
|
||||
if [ ! -z "$DB_SYSTEM" ]; then
|
||||
touch $USER_DATA/db.conf
|
||||
chmod 660 $USER_DATA/db.conf
|
||||
echo "$BIN/v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe
|
||||
fi
|
||||
|
||||
if [ ! -z "$CRON_SYSTEM" ]; then
|
||||
touch $USER_DATA/cron.conf
|
||||
chmod 660 $USER_DATA/cron.conf
|
||||
fi
|
||||
|
||||
# Filling user config
|
||||
if [ "$user" != 'admin' ]; then
|
||||
|
@ -201,6 +180,7 @@ U_DATABASES='0'
|
|||
U_CRON_JOBS='0'
|
||||
U_BACKUPS='0'
|
||||
LANGUAGE=''
|
||||
NOTIFICATIONS='no'
|
||||
TIME='$TIME'
|
||||
DATE='$DATE'" > $USER_DATA/user.conf
|
||||
chmod 660 $USER_DATA/user.conf
|
||||
|
@ -220,6 +200,11 @@ if [ -x "$VESTA/data/packages/$package.sh" ]; then
|
|||
$VESTA/data/packages/$package.sh "$user" "$email" "$fname" "$lname"
|
||||
fi
|
||||
|
||||
# Adding jailed sftp env
|
||||
if [ ! -z "$SFTPJAIL_KEY" ]; then
|
||||
$BIN/v-add-user-sftp-jail $user
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_history "added system user $user" '' 'admin'
|
||||
log_event "$OK" "$EVENT"
|
||||
|
|
125
bin/v-add-user-favourites
Executable file
125
bin/v-add-user-favourites
Executable file
|
@ -0,0 +1,125 @@
|
|||
#!/bin/bash
|
||||
# info: adding user favourites
|
||||
# options: USER SYSTEM OBJECT
|
||||
#
|
||||
# The function adds object to users favourites
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
user=$1
|
||||
system=$(echo "$2" |tr '[:lower:]' '[:upper:]')
|
||||
object=$3
|
||||
email=$3
|
||||
id=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER SYSTEM OBJECT'
|
||||
validate_format 'user' 'system'
|
||||
case $system in
|
||||
MAIL_ACC) validate_format 'email' ;;
|
||||
CRON) validate_format 'id' ;;
|
||||
DNS_REC) validate_format 'id' ;;
|
||||
*) validate_format 'object'
|
||||
esac
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
||||
# Checking system
|
||||
case $system in
|
||||
USER) check='ok' ;;
|
||||
WEB) check='ok' ;;
|
||||
DNS) check='ok' ;;
|
||||
DNS_REC) check='ok' ;;
|
||||
MAIL) check='ok' ;;
|
||||
MAIL_ACC) check='ok' ;;
|
||||
DB) check='ok' ;;
|
||||
CRON) check='ok' ;;
|
||||
BACKUP) check='ok' ;;
|
||||
IP) check='ok' ;;
|
||||
PACKAGE) check='ok' ;;
|
||||
FIREWALL) check='ok' ;;
|
||||
*) check_args '2' '0' 'USER SYSTEM OBJECT'
|
||||
esac
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Flushing vars
|
||||
USER=''
|
||||
WEB=''
|
||||
DNS=''
|
||||
DNS_REC=''
|
||||
MAIL=''
|
||||
MAIL_ACC=''
|
||||
DB=''
|
||||
CRON=''
|
||||
BACKUP=''
|
||||
IP=''
|
||||
PACKAGE=''
|
||||
FIREWALL=''
|
||||
|
||||
# Creating config just in case
|
||||
touch $USER_DATA/favourites.conf
|
||||
|
||||
# Reading current values
|
||||
source $USER_DATA/favourites.conf
|
||||
|
||||
# Assigning current system value
|
||||
eval value=\$$system
|
||||
|
||||
# Checking if object is new
|
||||
check_fav=$(echo "$value" |tr ',' '\n'| grep "^$object$")
|
||||
if [ ! -z "$check_fav" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Adding object to favorites
|
||||
if [ -z "$value" ]; then
|
||||
value="$object"
|
||||
else
|
||||
value="$value,$object"
|
||||
fi
|
||||
|
||||
# Updating sytem
|
||||
eval $system=$value
|
||||
|
||||
# Updating user favorites
|
||||
echo "USER='$USER'
|
||||
WEB='$WEB'
|
||||
DNS='$DNS'
|
||||
DNS_REC='$DNS_REC'
|
||||
MAIL='$MAIL'
|
||||
MAIL_ACC='$MAIL_ACC'
|
||||
DB='$DB'
|
||||
CRON='$CRON'
|
||||
BACKUP='$BACKUP'
|
||||
IP='$IP'
|
||||
PACKAGE='$PACKAGE'
|
||||
FIREWALL='$FIREWALL'" > $USER_DATA/favourites.conf
|
||||
|
||||
# Changing file permission
|
||||
chmod 640 $USER_DATA/favourites.conf
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_history "added starred $object in $system listing"
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
71
bin/v-add-user-notification
Executable file
71
bin/v-add-user-notification
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/bin/bash
|
||||
# info: add user notification
|
||||
# options: USER TOPIC NOTICE [TYPE]
|
||||
#
|
||||
# The function adds user notification.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
user=$1
|
||||
topic=$(echo $2 |sed "s/'/%quote%/g")
|
||||
notice=$(echo $3 |sed "s/'/%quote%/g")
|
||||
type=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER TOPIC NOTICE [TYPE]'
|
||||
validate_format 'user' 'topic' 'notice'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining notification id
|
||||
if [ -e "$USER_DATA/notifications.conf" ]; then
|
||||
nid=$(grep "NID=" $USER_DATA/notifications.conf |cut -f 2 -d \')
|
||||
nid=$(echo "$nid" |sort -n |tail -n1)
|
||||
if [ ! -z "$nid" ]; then
|
||||
nid="$((nid +1))"
|
||||
else
|
||||
nid=1
|
||||
fi
|
||||
else
|
||||
nid=1
|
||||
fi
|
||||
|
||||
# Concatenating string
|
||||
str="NID='$nid' TOPIC='$topic' NOTICE='$notice' TYPE='$type'"
|
||||
str="$str ACK='no' TIME='$TIME' DATE='$DATE'"
|
||||
|
||||
# Adding to config
|
||||
echo "$str" >> $USER_DATA/notifications.conf
|
||||
|
||||
# Changing permissions
|
||||
chmod 660 $USER_DATA/notifications.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating notification counter
|
||||
if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then
|
||||
sed -i "s/^TIME/NOTIFICATIONS='yes'\nTIME/g" $USER_DATA/user.conf
|
||||
else
|
||||
update_user_value "$user" '$NOTIFICATIONS' "yes"
|
||||
fi
|
||||
|
||||
exit
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
pkg_dir=$1
|
||||
package=$2
|
||||
rewrite=$3
|
||||
|
|
66
bin/v-add-user-sftp-jail
Executable file
66
bin/v-add-user-sftp-jail
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash
|
||||
# info: add user sftp jail
|
||||
# options: USER
|
||||
#
|
||||
# The script enables sftp jailed environment
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
user=$1
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'USER'
|
||||
validate_format 'user'
|
||||
if [ -z "$SFTPJAIL_KEY" ]; then
|
||||
exit
|
||||
fi
|
||||
user_str=$(grep "^$user:" /etc/passwd |egrep "rssh|nologin")
|
||||
if [ -z "$user_str" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining user homedir
|
||||
home="$(echo $user_str |cut -f 6 -d :)"
|
||||
|
||||
# Adding chroot directory
|
||||
if [ ! -d "/chroot/$user/$home" ]; then
|
||||
mkdir -p /chroot/$user/$home
|
||||
chmod 750 /chroot/$user
|
||||
chmod 775 /chroot/$user/$home
|
||||
chown root:sftp-only /chroot/$user
|
||||
chown $user:sftp-only /chroot/$user/$home
|
||||
fi
|
||||
|
||||
# Adding user to sftp group
|
||||
usermod -a -G sftp-only $user
|
||||
|
||||
# Mouting home directory
|
||||
if [ -z "$(mount |grep $home)" ]; then
|
||||
mount -o bind $home /chroot/$user/$home/
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
#log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
# info: add web domain
|
||||
# options: USER DOMAIN IP [RESTART]
|
||||
# options: USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]
|
||||
#
|
||||
# The function adds virtual host to a server. In cases when a template is
|
||||
# undefined in the script, the template "default" will be used. The alias of
|
||||
# www.domain.tld type will be automatically assigned to the domain. If ip have
|
||||
# assocated dns name, this domain will also get the alias domain-tpl.$ipname.
|
||||
# associated dns name, this domain will also get the alias domain-tpl.$ipname.
|
||||
# An alias with the ip name is useful during the site testing while dns isn't
|
||||
# moved to a server yet.
|
||||
|
||||
|
@ -14,14 +14,18 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
ip=$3
|
||||
ip=$3; IP=$3
|
||||
restart=$4
|
||||
aliases=$5
|
||||
default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
|
||||
exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
|
||||
extentions=${6-$default_extentions}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -34,7 +38,7 @@ source $VESTA/conf/vesta.conf
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN IP [RESTART]'
|
||||
check_args '3' "$#" 'USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]'
|
||||
validate_format 'user' 'domain' 'ip'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
@ -45,41 +49,23 @@ is_ip_avalable
|
|||
is_package_full 'WEB_DOMAINS'
|
||||
template=$(get_user_value '$WEB_TEMPLATE')
|
||||
is_web_template_valid
|
||||
if [ ! -z "$aliases" ]; then
|
||||
for domain_alias in $(echo "${aliases//,/ }"); do
|
||||
is_domain_new 'web' "$domain_alias" 'alias'
|
||||
done
|
||||
fi
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
validate_format 'extentions'
|
||||
proxy=$(get_user_value '$PROXY_TEMPLATE')
|
||||
is_proxy_template_valid $proxy
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Define real ip in case of NAT
|
||||
IP=$ip
|
||||
ip=$(get_real_ip $ip)
|
||||
|
||||
# Defining domain aliases
|
||||
ip_name=$(get_ip_name)
|
||||
ip_name_idn=$(idn -t --quiet -a "$ip_name")
|
||||
domain_alias="www.$domain"
|
||||
domain_alias_idn="www.$domain_idn"
|
||||
if [ ! -z "$ip_name" ]; then
|
||||
domain_alias_dash="${domain//./-}.$ip_name"
|
||||
domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn"
|
||||
aliases="$domain_alias,$domain_alias_dash"
|
||||
aliases_idn="$domain_alias_idn,$domain_alias_dash_idn"
|
||||
alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn"
|
||||
else
|
||||
aliases="$domain_alias"
|
||||
aliases_idn="$domain_alias_idn"
|
||||
alias_string="ServerAlias $domain_alias_idn"
|
||||
fi
|
||||
|
||||
# Defining vars for add_config function
|
||||
group="$user"
|
||||
email="info@$domain"
|
||||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
|
||||
# Checking backend
|
||||
# Checking domain backend in case PHP-FPM is configured
|
||||
if [ ! -z "$WEB_BACKEND" ]; then
|
||||
is_web_backend_pool_valid
|
||||
$BIN/v-add-web-domain-backend $user $domain
|
||||
|
@ -88,7 +74,35 @@ if [ ! -z "$WEB_BACKEND" ]; then
|
|||
exit $rc
|
||||
fi
|
||||
get_domain_backend_values
|
||||
backend=$(get_user_value '$BACKEND_TEMPLATE')
|
||||
if [ -z "$backend" ]; then
|
||||
backend='default'
|
||||
fi
|
||||
fi
|
||||
|
||||
# Defining variables for add_config function
|
||||
ip=$(get_real_ip $ip)
|
||||
group="$user"
|
||||
email="info@$domain"
|
||||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
|
||||
# Defining domain aliases
|
||||
ip_name=$(get_ip_name)
|
||||
if [ -z "$aliases" ]; then
|
||||
if [ -z "$ip_name" ]; then
|
||||
aliases="www.$domain"
|
||||
else
|
||||
aliases="www.$domain,${domain//./-}.$ip_name"
|
||||
fi
|
||||
else
|
||||
if [ ! -z "$ip_name" ]; then
|
||||
aliases="$aliases,${domain//./-}.$ip_name"
|
||||
fi
|
||||
fi
|
||||
aliases_idn=$(idn -t --quiet -a $aliases)
|
||||
alias_string="ServerAlias ${aliases_idn//,/ }"
|
||||
|
||||
# Adding web config
|
||||
add_web_config
|
||||
|
@ -133,23 +147,21 @@ done
|
|||
|
||||
# Changing file owner
|
||||
chown -R $user:$user $HOMEDIR/$user/web/$domain
|
||||
chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.*
|
||||
chown root:$user $conf
|
||||
chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.* $conf
|
||||
|
||||
# Changing file permissions
|
||||
chmod 640 $conf
|
||||
chmod 640 $conf /var/log/$WEB_SYSTEM/domains/$domain.*
|
||||
chmod 551 $HOMEDIR/$user/web/$domain
|
||||
chmod 751 $HOMEDIR/$user/web/$domain/private
|
||||
chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin
|
||||
chmod 751 $HOMEDIR/$user/web/$domain/public_html
|
||||
chmod 751 $HOMEDIR/$user/web/$domain/public_shtml
|
||||
chmod 751 $HOMEDIR/$user/web/$domain/document_errors
|
||||
chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/*
|
||||
chmod -f -R 665 $HOMEDIR/$user/web/$domain/public_html/*
|
||||
chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/*
|
||||
chmod 551 $HOMEDIR/$user/web/$domain/stats
|
||||
chmod 551 $HOMEDIR/$user/web/$domain/logs
|
||||
chmod 640 /var/log/$WEB_SYSTEM/domains/$domain.*
|
||||
chmod 751 $HOMEDIR/$user/web/$domain/private \
|
||||
$HOMEDIR/$user/web/$domain/cgi-bin \
|
||||
$HOMEDIR/$user/web/$domain/public_html \
|
||||
$HOMEDIR/$user/web/$domain/public_shtml \
|
||||
$HOMEDIR/$user/web/$domain/document_errors
|
||||
chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/* \
|
||||
$HOMEDIR/$user/web/$domain/public_html/* \
|
||||
$HOMEDIR/$user/web/$domain/document_errors/* \
|
||||
chmod 551 $HOMEDIR/$user/web/$domain/stats \
|
||||
$HOMEDIR/$user/web/$domain/logs
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||
|
@ -167,6 +179,23 @@ if [ -z "$web_include" ] && [ "$WEB_SYSTEM" = 'nginx' ]; then
|
|||
echo "include $conf;" >> $web_conf
|
||||
fi
|
||||
|
||||
# Checking proxy system
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
PROXY_EXT="$extentions"
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$proxy.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
add_web_config
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
if [ -z "$(grep "$conf" $proxy_conf)" ]; then
|
||||
echo "include $conf;" >> $proxy_conf
|
||||
fi
|
||||
if [ -x $WEBTPL/$PROXY_SYSTEM/$proxy.sh ]; then
|
||||
$WEBTPL/$PROXY_SYSTEM/$proxy.sh $user $domain $ip $HOMEDIR $docroot
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
@ -178,22 +207,23 @@ increase_user_value "$user" '$U_WEB_DOMAINS'
|
|||
increase_user_value "$user" '$U_WEB_ALIASES'
|
||||
|
||||
# Defining domain variables
|
||||
BACKEND_TPL=$(grep BACKEND_TEMPLATE $USER_DATA/user.conf |cut -f 2 -d \')
|
||||
str="DOMAIN='$domain' IP='$IP' IP6='' ALIAS='$aliases' TPL='$template'"
|
||||
str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5=''"
|
||||
str="$str BACKEND='$BACKEND_TPL' PROXY='' PROXY_EXT='' STATS='' STATS_USER=''"
|
||||
str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5='' BACKEND='$backend'"
|
||||
str="$str PROXY='$proxy' PROXY_EXT='$extentions' STATS='' STATS_USER=''"
|
||||
str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
|
||||
str="$str TIME='$TIME' DATE='$DATE'"
|
||||
|
||||
# Registering domain
|
||||
echo "$str" >> $USER_DATA/web.conf
|
||||
chmod 660 $USER_DATA/web.conf
|
||||
|
||||
# Restart web server
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
@ -39,7 +39,7 @@ is_object_valid 'user' 'USER' "$user"
|
|||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||
is_domain_new 'web' "$dom_alias"
|
||||
is_domain_new 'web' "$dom_alias" 'alias'
|
||||
is_package_full 'WEB_ALIASES'
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ if [ "$SSL" = 'yes' ]; then
|
|||
fi
|
||||
|
||||
# Checking proxy
|
||||
if [ ! -z "$PROXY" ]; then
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
|
@ -100,16 +100,14 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
|
|||
# Update counters
|
||||
increase_user_value "$user" '$U_WEB_ALIASES'
|
||||
|
||||
# Adding task to the vesta pipe
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$2
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
template=$3
|
||||
template=${3-default}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -67,9 +67,7 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
|
|||
# Restart backend server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web-backend
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Web backend restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
ftp_user=${1}_${3}
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
ftp_path=$5
|
||||
|
||||
# Includes
|
||||
|
@ -22,10 +22,6 @@ source $VESTA/func/main.sh
|
|||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -94,6 +90,11 @@ fi
|
|||
echo "$ftp_user:$password" | /usr/sbin/chpasswd
|
||||
ftp_md5=$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)
|
||||
|
||||
# Adding jailed sftp env
|
||||
if [ ! -z "$SFTPJAIL_KEY" ]; then
|
||||
$BIN/v-add-user-sftp-jail $ftp_user
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
|
105
bin/v-add-web-domain-httpauth
Executable file
105
bin/v-add-web-domain-httpauth
Executable file
|
@ -0,0 +1,105 @@
|
|||
#!/bin/bash
|
||||
# info: add password protection for web domain
|
||||
# options: USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART]
|
||||
#
|
||||
# The call is used for securing web domain with http auth
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$2
|
||||
auth_user=$3
|
||||
password=$4; HIDE=4
|
||||
restart=${5-yes}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Defining htpasswd file
|
||||
htaccess="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess"
|
||||
htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd"
|
||||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '4' "$#" 'USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART]'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||
is_password_valid
|
||||
get_domain_values 'web'
|
||||
if [ ! -z "$(echo "$AUTH_USER" |tr : '\n' |grep ^$auth_user$)" ]; then
|
||||
echo "Error: auth user $auth_user already exists"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Adding htaccess password protection
|
||||
if [ ! -e "$htaccess" ]; then
|
||||
if [ "$WEB_SYSTEM" != 'nginx' ]; then
|
||||
echo "<Directory $docroot>" > $htaccess
|
||||
echo " AuthUserFile $htpasswd" >> $htaccess
|
||||
echo " AuthName \"$domain access\"" >> $htaccess
|
||||
echo " AuthType Basic" >> $htaccess
|
||||
echo " Require valid-user" >> $htaccess
|
||||
echo "</Directory>" >> $htaccess
|
||||
else
|
||||
echo "auth_basic \"$domain password access\";" > $htaccess
|
||||
echo "auth_basic_user_file $htpasswd;" >> $htaccess
|
||||
fi
|
||||
restart_required='yes'
|
||||
fi
|
||||
|
||||
# Adding httpasswd user
|
||||
auth_hash=$($BIN/v-generate-password-hash htpasswd htpasswd $password)
|
||||
touch $htpasswd
|
||||
chmod 640 $htpasswd $htaccess
|
||||
sed -i "/^$auth_user:/d" $htpasswd
|
||||
echo "$auth_user:$auth_hash" >> $htpasswd
|
||||
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ] && [ "$restart_required" = 'yes' ]; then
|
||||
$BIN/v-restart-web
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Preparing web.conf keys
|
||||
if [ ! -z "$AUTH_USER" ]; then
|
||||
auth_user="$AUTH_USER:$auth_user"
|
||||
auth_hash="$AUTH_HASH:$auth_hash"
|
||||
else
|
||||
# Adding new key into web.conf
|
||||
add_object_key "web" 'DOMAIN' "$domain" 'AUTH_USER' 'U_DISK'
|
||||
add_object_key "web" 'DOMAIN' "$domain" 'AUTH_HASH' 'U_DISK'
|
||||
fi
|
||||
|
||||
# Updating config
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_USER' "$auth_user"
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_HASH' "$auth_hash"
|
||||
|
||||
# Logging
|
||||
log_history "added http auth user $httpauth_user on $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -10,7 +10,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -42,7 +42,7 @@ is_object_value_empty 'web' 'DOMAIN' "$domain" '$PROXY'
|
|||
if [ -z $template ]; then
|
||||
template=$(get_user_value '$PROXY_TEMPLATE')
|
||||
fi
|
||||
is_proxy_template_valid
|
||||
is_proxy_template_valid $template
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -100,12 +100,10 @@ fi
|
|||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
|
||||
|
||||
# Restart web server
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-proxy
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
log_history "enabled proxy support for $domain"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -97,7 +97,7 @@ if [ -z "$(grep "$conf" $web_conf)" ]; then
|
|||
fi
|
||||
|
||||
# Checking proxy
|
||||
if [ ! -z "$PROXY" ]; then
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
add_web_config
|
||||
|
@ -124,16 +124,14 @@ increase_user_value "$user" '$U_WEB_SSL'
|
|||
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
|
||||
|
||||
# Restart web server
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
|
|
@ -9,21 +9,17 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
stats_user=$3
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -43,7 +39,7 @@ is_password_valid
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Definining statistic dir
|
||||
# Defining statistic dir
|
||||
stats_dir="$HOMEDIR/$user/web/$domain/stats"
|
||||
|
||||
# Adding htaccess file
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# Importing system variables
|
||||
source /etc/profile
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
notify=${2-no}
|
||||
|
||||
|
@ -56,7 +56,6 @@ else
|
|||
subj="$user → backup failed"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
|
||||
fi
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
|
||||
# Check load average
|
||||
la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
|
||||
|
@ -137,8 +136,8 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
|
|||
# Parsing domain exclusions
|
||||
conf="$USER_DATA/web.conf"
|
||||
for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do
|
||||
check_exl=$(echo -e "${WEB//,/\n}" |grep "^$domain$")
|
||||
if [ -z "$check_exl" ]; then
|
||||
exclusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain$")
|
||||
if [ -z "$exclusion" ]; then
|
||||
web_list="$web_list $domain"
|
||||
else
|
||||
echo "$(date "+%F %T") excluding $domain"
|
||||
|
@ -207,36 +206,26 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
|
|||
fi
|
||||
|
||||
# Define exclude arguments
|
||||
exlusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain:")
|
||||
set -f
|
||||
fargs=()
|
||||
fargs+=(-not)
|
||||
fargs+=(-path)
|
||||
fargs+=("./logs*")
|
||||
check_exlusion=$(echo -e "${WEB//,/\n}" | grep "^$domain:")
|
||||
if [ ! -z "$check_exlusion" ]; then
|
||||
xdirs="$(echo -e "${check_exlusion//:/\n}" |grep -v $domain)"
|
||||
fargs+=(--exclude='logs/*')
|
||||
if [ ! -z "$exlusion" ]; then
|
||||
xdirs="$(echo -e "$exlusion" |tr ':' '\n' |grep -v $domain)"
|
||||
for xpath in $xdirs; do
|
||||
xpath="$(echo $xpath | sed -e 's/\/*$//' -e 's/^\/*//')"
|
||||
fargs+=(-not)
|
||||
fargs+=(-path)
|
||||
fargs+=("./$xpath/*")
|
||||
fargs+=(--exclude=$xpath/*)
|
||||
echo "$(date "+%F %T") excluding directory $xpath"
|
||||
msg="$msg\n$(date "+%F %T") excluding directory $xpath"
|
||||
done
|
||||
fi
|
||||
set +f
|
||||
|
||||
# Backup files
|
||||
cd $HOMEDIR/$user/web/$domain
|
||||
find . ${fargs[@]} -type f -print0 |\
|
||||
tar -cpf $tmpdir/web/$domain/domain_data.tar --null -T -
|
||||
|
||||
# Backup empty folders
|
||||
find . ${fargs[@]} -type d -empty -print0 |\
|
||||
tar -rpf $tmpdir/web/$domain/domain_data.tar --null -T -
|
||||
tar -cpf $tmpdir/web/$domain/domain_data.tar * ${fargs[@]}
|
||||
|
||||
# Compress archive
|
||||
gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
|
||||
set +f
|
||||
done
|
||||
|
||||
# Print total
|
||||
|
@ -259,8 +248,8 @@ if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS" != '*' ]; then
|
|||
|
||||
# Parsing domain exclusions
|
||||
for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
|
||||
check_exl=$(echo -e "${DNS//,/\n}" |grep "^$domain$")
|
||||
if [ -z "$check_exl" ]; then
|
||||
exclusion=$(echo "$DNS" |tr ',' '\n' |grep "^$domain$")
|
||||
if [ -z "$exclusion" ]; then
|
||||
dns_list="$dns_list $domain"
|
||||
else
|
||||
echo "$(date "+%F %T") excluding $domain"
|
||||
|
@ -312,7 +301,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
|
|||
# Parsing domain exclusions
|
||||
conf="$USER_DATA/mail.conf"
|
||||
for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do
|
||||
check_exl=$(echo -e "${MAIL//,/\n}" |grep "^$domain$")
|
||||
check_exl=$(echo "$MAIL" |tr ',' '\n' |grep "^$domain$")
|
||||
if [ -z "$check_exl" ]; then
|
||||
mail_list="$mail_list $domain"
|
||||
else
|
||||
|
@ -348,8 +337,8 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
|
|||
# Backup emails
|
||||
cd $HOMEDIR/$user/mail/$domain_idn
|
||||
for account in $(ls); do
|
||||
exclusion=$(echo -e "${MAIL//,/\n}" |grep "$domain:")
|
||||
exclusion=$(echo -e "${exclusion//:/\n}" |grep "^$account$")
|
||||
exclusion=$(echo "$MAIL" |tr ',' '\n' |grep "$domain:")
|
||||
exclusion=$(echo "$exclusion" |tr ':' '\n' |grep "^$account$")
|
||||
|
||||
# Checking exlusions
|
||||
if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
||||
|
@ -390,8 +379,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
|
|||
|
||||
# Parsing database exclusions
|
||||
for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do
|
||||
check_exl=$(echo -e "${DB//,/\n}" |grep "^$database$")
|
||||
if [ -z "$check_exl" ]; then
|
||||
exclusion=$(echo "$DB" |tr ',' '\n' |grep "^$database$")
|
||||
if [ -z "$exclusion" ]; then
|
||||
db_list="$db_list $database"
|
||||
else
|
||||
echo "$(date "+%F %T") excluding $database"
|
||||
|
@ -477,9 +466,8 @@ if [ "$USER" != '*' ]; then
|
|||
if [ -e "$USER_DATA/backup-excludes.conf" ]; then
|
||||
source $USER_DATA/backup-excludes.conf
|
||||
fi
|
||||
exlusion_list=$(echo -e "${USER//,/\n}")
|
||||
fargs=()
|
||||
for xpath in $exlusion_list; do
|
||||
for xpath in $(echo "$USER" |tr ',' '\n'); do
|
||||
fargs+=(-not)
|
||||
fargs+=(-path)
|
||||
fargs+=("./$xpath*")
|
||||
|
@ -490,21 +478,17 @@ if [ "$USER" != '*' ]; then
|
|||
IFS=$'\n'
|
||||
set -f
|
||||
i=0
|
||||
for udir in $(ls |egrep -v "conf|web|dns|mail"); do
|
||||
check_exl=$(echo -e "${USER//,/\n}" |grep "^$udir$")
|
||||
if [ -z "$check_exl" ]; then
|
||||
|
||||
for udir in $(ls -a |egrep -v "conf|web|dns|mail|^\.\.$|^\.$"); do
|
||||
exclusion=$(echo "$USER" |tr ',' '\n' |grep "^$udir$")
|
||||
if [ -z "$exclusion" ]; then
|
||||
((i ++))
|
||||
udir_list="$udir_list $udir"
|
||||
echo -e "$(date "+%F %T") adding directory $udir"
|
||||
msg="$msg\n$(date "+%F %T") adding directory $udir"
|
||||
echo -e "$(date "+%F %T") adding $udir"
|
||||
msg="$msg\n$(date "+%F %T") adding $udir"
|
||||
|
||||
# Backup files
|
||||
find ./$udir ${fargs[@]} -type f -print0 |\
|
||||
tar -cpf $tmpdir/user_dir/$udir.tar --null -T -
|
||||
|
||||
# Backup empty folders
|
||||
find ./$udir ${fargs[@]} -type d -empty -print0 |\
|
||||
tar -rpf $tmpdir/user_dir/$udir.tar --null -T -
|
||||
# Backup files and dirs
|
||||
tar -cpf $tmpdir/user_dir/$udir.tar $udir
|
||||
|
||||
# Compress arhive
|
||||
gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
|
||||
|
@ -869,7 +853,7 @@ msg="$msg\n$(date "+%F %T") Runtime: $run_time $min"
|
|||
touch $USER_DATA/backup.conf
|
||||
sed -i "/$user.$DATE.tar/d" $USER_DATA/backup.conf
|
||||
|
||||
# Regestering new backup
|
||||
# Registering new backup
|
||||
backup_str="BACKUP='$user.$DATE.tar'"
|
||||
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
|
||||
backup_str="$backup_str WEB='${web_list// /,}'"
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Importing system enviroment as we run this script
|
||||
# mostly by cron wich not read it by itself
|
||||
# Importing system environment as we run this script
|
||||
# mostly by cron which not read it by itself
|
||||
source /etc/profile
|
||||
|
||||
# Includes
|
||||
|
@ -22,6 +22,8 @@ source $VESTA/conf/vesta.conf
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
$BIN/v-check-vesta-license >/dev/null
|
||||
|
||||
if [ -z "$BACKUP_SYSTEM" ]; then
|
||||
exit
|
||||
fi
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
job=$2
|
||||
min=$3
|
||||
|
@ -64,11 +64,9 @@ sync_cron_jobs
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart crond
|
||||
# Restarting crond
|
||||
$BIN/v-restart-cron
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Cron restart failed" >/dev/null
|
||||
|
||||
# Logging
|
||||
log_history "changed cron job $job"
|
||||
|
|
|
@ -9,21 +9,17 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
type=$1
|
||||
host=$2
|
||||
dbuser=$3
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/db.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
database=$1
|
||||
user=$2
|
||||
|
||||
|
|
|
@ -10,20 +10,16 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
database=$2
|
||||
password=$3
|
||||
password=$3; HIDE=3
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/db.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A3='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
database=$2
|
||||
dbuser="$user"_"$3"
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -21,10 +21,6 @@ source $VESTA/func/db.sh
|
|||
source $VESTA/func/rebuild.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# info: change dns domain expiriation date
|
||||
# info: change dns domain expiration date
|
||||
# options: USER DOMAIN EXP
|
||||
#
|
||||
# The function of changing the term of expiration domain's registration. The
|
||||
|
@ -10,7 +10,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -57,7 +57,7 @@ fi
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_history "changed whois expiriation date for $domain"
|
||||
log_history "changed whois expiration date for $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -51,6 +51,7 @@ sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf
|
|||
|
||||
# Updating zone
|
||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||
update_domain_serial
|
||||
update_domain_zone
|
||||
fi
|
||||
|
||||
|
@ -59,7 +60,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
|
|||
# Check for first sync
|
||||
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
|
||||
if [ -z "$dlock" ]; then
|
||||
cmd="$BIN/v-add-remote-dns-domain $user $domain domain"
|
||||
cmd="$BIN/v-add-remote-dns-domain $user $domain domain yes"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
fi
|
||||
|
@ -69,12 +70,10 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
# Restarting named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "DNS restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -45,6 +45,7 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa"
|
|||
|
||||
# Updating zone
|
||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||
update_domain_serial
|
||||
update_domain_zone
|
||||
fi
|
||||
|
||||
|
@ -63,12 +64,10 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
# Restarting named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "DNS restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -67,6 +67,7 @@ records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')"
|
|||
|
||||
# Updating zone
|
||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||
update_domain_serial
|
||||
update_domain_zone
|
||||
fi
|
||||
|
||||
|
@ -89,12 +90,10 @@ fi
|
|||
update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
|
||||
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
|
||||
|
||||
# Restart named
|
||||
# Restarting named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "DNS restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
# info: change dns domain ttl
|
||||
# options: USER DOMAIN TTL
|
||||
#
|
||||
# The function for chaning the time to live TTL parameter for all records.
|
||||
# The function for changing the time to live TTL parameter for all records.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -44,6 +44,7 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl"
|
|||
|
||||
# Updating zone
|
||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||
update_domain_serial
|
||||
update_domain_zone
|
||||
fi
|
||||
|
||||
|
@ -62,12 +63,10 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
# Restarting named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "DNS restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
@ -77,6 +77,7 @@ sort_dns_records
|
|||
|
||||
# Updating zone
|
||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||
update_domain_serial
|
||||
update_domain_zone
|
||||
fi
|
||||
|
||||
|
@ -95,12 +96,10 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
# Restarting named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "DNS restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
@ -51,6 +51,7 @@ sort_dns_records
|
|||
|
||||
# Updating zone
|
||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||
update_domain_serial
|
||||
update_domain_zone
|
||||
fi
|
||||
|
||||
|
@ -69,12 +70,10 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
# Restarting named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "DNS restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
domain=$1
|
||||
user=$2
|
||||
ip=$3
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# Importing system variables
|
||||
source /etc/profile
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
rule=$1
|
||||
action=$(echo $2|tr '[:lower:]' '[:upper:]')
|
||||
ip=$3
|
||||
|
|
51
bin/v-change-fs-file-permission
Executable file
51
bin/v-change-fs-file-permission
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
# info: change file permission
|
||||
# options: USER FILE PERMISSIONS
|
||||
#
|
||||
# The function changes file access permissions on the file system
|
||||
|
||||
user=$1
|
||||
src_file=$2
|
||||
permissions=$3
|
||||
|
||||
# Checking arguments
|
||||
if [ -z "$permissions" ]; then
|
||||
echo "Usage: USER FILE PERMISSIONS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking vesta user
|
||||
if [ ! -e "$VESTA/data/users/$user" ]; then
|
||||
echo "Error: vesta user $user doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Checking user homedir
|
||||
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
||||
if [ -z $homedir ]; then
|
||||
echo "Error: user home directory doesn't exist"
|
||||
exit 12
|
||||
fi
|
||||
|
||||
# Checking source file
|
||||
if [ ! -f "$src_file" ]; then
|
||||
echo "Error: source file doesn't exist $src_file"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Checking source path
|
||||
rpath=$(readlink -f "$src_file")
|
||||
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||
echo "Error: invalid source path $src_file"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Changing file permissions
|
||||
sudo -u $user chmod $permissions "$src_file" >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: access permission on $src_file was not changed"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Exiting
|
||||
exit
|
|
@ -9,23 +9,19 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
account=$3
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
# info: change mail domain catchall email
|
||||
# options: USER DOMAIN EMAIL
|
||||
#
|
||||
# The function changes mail domain cathcall.
|
||||
# The function changes mail domain catchall.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# info: change remote dns domain expiriation date
|
||||
# info: change remote dns domain expiration date
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function synchronize dns domain with the remote server.
|
||||
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
|
@ -28,79 +28,42 @@ validate_format 'user' 'domain'
|
|||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||
check_result $E_EXISTS "another sync process already running"
|
||||
fi
|
||||
remote_dns_health_check
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Check remote dns nodes
|
||||
remote_dns_health_check
|
||||
# Parsing remote host parameters
|
||||
eval $cluster
|
||||
|
||||
for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
# Syncing domain
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
eval $str
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'scheduled'
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
||||
check_result $? "$HOST connection failed (exp insert)" $E_CONNECT
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
exit
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
|
@ -28,82 +28,46 @@ validate_format 'user' 'domain'
|
|||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
check_result 1 $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
if [ "$(ps auxf |grep -v grep |grep $VESTA/bin/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||
check_result 1 $E_EXISTS "another sync process already running"
|
||||
fi
|
||||
remote_dns_health_check
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Check remote dns nodes
|
||||
remote_dns_health_check
|
||||
# Parsing remote host parameters
|
||||
eval $cluster
|
||||
|
||||
for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
# Syncing SOA
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
eval $str
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
||||
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
|
||||
check_result $? "$HOST connection failed (sync)" $E_CONNECT
|
||||
|
||||
# Rebuild dns zone
|
||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
# Rebuilding dns zone
|
||||
cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
|
||||
check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
exit
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
|
@ -28,96 +28,46 @@ validate_format 'user' 'domain'
|
|||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||
check_result $E_EXISTS "another sync process already running"
|
||||
fi
|
||||
remote_dns_health_check
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Check remote dns nodes
|
||||
remote_dns_health_check
|
||||
# Parsing remote host parameters
|
||||
eval $cluster
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
# Syncing TTL
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
eval $str
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
||||
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
|
||||
check_result $? "$HOST connection failed (sync)" $E_CONNECT
|
||||
|
||||
# Rebuild dns zone
|
||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
# Rebuilding dns zone
|
||||
cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
|
||||
check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
|
||||
value=$2
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
domain=$1
|
||||
|
||||
# Includes
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
ip=$1
|
||||
ip_name=$2
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
ip=$1
|
||||
nat_ip=$2
|
||||
restart=$3
|
||||
|
@ -77,9 +77,7 @@ fi
|
|||
# Restart ftp server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-ftp
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "FTP restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
ip=$1
|
||||
user=$2
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
ip=$1
|
||||
ip_status=$2
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
language=$1
|
||||
|
||||
# Includes
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
timezone=$1
|
||||
|
||||
# Includes
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
email=$2
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
language=$2
|
||||
|
||||
|
@ -19,9 +19,14 @@ source $VESTA/conf/vesta.conf
|
|||
|
||||
|
||||
is_language_valid() {
|
||||
if [ ! -e "$VESTA/web/inc/i18n/$language.php" ]; then
|
||||
echo "Error: language $language not exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
if ! [[ "$1" =~ ^[[:alnum:]_-]+$ ]]; then
|
||||
echo "Error: language $1 is not valid"
|
||||
log_event "$E_INVALID" "$EVENT"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
if [ ! -e "$VESTA/web/inc/i18n/$1.php" ]; then
|
||||
echo "Error: language $1 doesn't exist"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
fname=$2
|
||||
lname=$3
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
#!/bin/bash
|
||||
# info: change user nameservers
|
||||
# options: USER NS1 NS2 [NS3] [NS4]
|
||||
# options: USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]
|
||||
#
|
||||
# The function for changing default nameservers for speciefic user.
|
||||
# The function for changing default nameservers for specific user.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
ns3=$4
|
||||
ns4=$5
|
||||
ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
ns5=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
ns6=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
ns7=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
ns8=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -26,7 +30,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4]'
|
||||
check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]'
|
||||
|
||||
# Checking argument format
|
||||
validate_format 'user' 'ns1' 'ns2'
|
||||
|
@ -38,7 +42,22 @@ if [ ! -z "$ns4" ]; then
|
|||
ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns4'
|
||||
fi
|
||||
|
||||
if [ ! -z "$ns5" ]; then
|
||||
ns5=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns5'
|
||||
fi
|
||||
if [ ! -z "$ns6" ]; then
|
||||
ns6=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns6'
|
||||
fi
|
||||
if [ ! -z "$ns7" ]; then
|
||||
ns7=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns7'
|
||||
fi
|
||||
if [ ! -z "$ns8" ]; then
|
||||
ns8=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||
validate_format 'ns8'
|
||||
fi
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
||||
|
@ -48,7 +67,7 @@ is_object_unsuspended 'user' 'USER' "$user"
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Merging values
|
||||
ns="$ns1,$ns2,$ns3,$ns4"
|
||||
ns="$ns1,$ns2,$ns3,$ns4,$ns5,$ns6,$ns7,$ns8"
|
||||
ns=$(echo "$ns" | sed -e "s/,,//g" -e "s/,$//")
|
||||
|
||||
# Changing ns values
|
||||
|
@ -60,7 +79,7 @@ update_user_value "$user" '$NS' "$ns"
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_history "changed user nameservers to $ns1, $ns2"
|
||||
log_history "updated nameservers $ns1 $ns2 $ns3 $ns4 $ns5 $ns6 $ns7 $ns8"
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
package=$2
|
||||
force=$3
|
||||
|
@ -148,6 +148,7 @@ U_DATABASES='$U_DATABASES'
|
|||
U_CRON_JOBS='$U_CRON_JOBS'
|
||||
U_BACKUPS='$U_BACKUPS'
|
||||
LANGUAGE='$LANGUAGE'
|
||||
NOTIFICATIONS='$NOTIFICATIONS'
|
||||
TIME='$TIME'
|
||||
DATE='$DATE'" > $USER_DATA/user.conf
|
||||
}
|
||||
|
|
|
@ -9,18 +9,14 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
password=$2
|
||||
password=$2; HIDE=2
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A2="******"
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
# info: change user shell
|
||||
# options: USER SHELL
|
||||
#
|
||||
# The function changes system shell of a user. Shell gives abilty to use ssh.
|
||||
# The function changes system shell of a user. Shell gives ability to use ssh.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
shell=$2
|
||||
|
||||
|
@ -36,9 +36,18 @@ is_object_unsuspended 'user' 'USER' "$user"
|
|||
shell_path=$(grep -w "$shell" /etc/shells | head -n1)
|
||||
|
||||
# Changing passwd file
|
||||
/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null
|
||||
/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1
|
||||
shell=$(basename $shell_path)
|
||||
|
||||
# Adding jailed sftp env
|
||||
if [ ! -z "$SFTPJAIL_KEY" ]; then
|
||||
if [[ "$shell" =~ nologin ]] || [[ "$shell" =~ rssh ]]; then
|
||||
$BIN/v-add-user-sftp-jail $user >/dev/null 2>&1
|
||||
else
|
||||
$BIN/v-delete-user-sftp-jail $user >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
type=$(echo "$2" | tr '[:lower:]' '[:upper:]')
|
||||
template=$3
|
||||
|
@ -37,7 +37,7 @@ is_object_unsuspended 'user' 'USER' "$user"
|
|||
case $type in
|
||||
WEB) is_web_template_valid;
|
||||
update_user_value "$user" '$WEB_TEMPLATE' "$template";;
|
||||
PROXY) is_proxy_template_valid;
|
||||
PROXY) is_proxy_template_valid $template;
|
||||
update_user_value "$user" '$PROXY_TEMPLATE' "$template";;
|
||||
DNS) is_dns_template_valid;
|
||||
update_user_value "$user" '$DNS_TEMPLATE' "$template";;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -155,16 +155,13 @@ fi
|
|||
#----------------------------------------------------------#
|
||||
|
||||
|
||||
# Restart web
|
||||
# Restarting web
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
$BIN/v-restart-web-backend
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Web backend restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -9,22 +9,18 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
ftp_user=$3
|
||||
password=$4
|
||||
password=$4; HIDE=4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4="******"
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
|
76
bin/v-change-web-domain-httpauth
Executable file
76
bin/v-change-web-domain-httpauth
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/bin/bash
|
||||
# info: change password for http auth user
|
||||
# options: USER DOMAIN AUTH_USER AUTH_PASSWORD
|
||||
#
|
||||
# The call is used for changing http auth user password
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$2
|
||||
auth_user=$3
|
||||
password=$4; HIDE=4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Defining htpasswd file
|
||||
htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '4' "$#" 'USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART]'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||
is_password_valid
|
||||
get_domain_values 'web'
|
||||
if [ -z "$(echo "$AUTH_USER" |tr : '\n' |grep ^$auth_user$)" ]; then
|
||||
echo "Error: auth user $auth_user doesn't exist"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Adding httpasswd user
|
||||
auth_hash=$($BIN/v-generate-password-hash htpasswd htpasswd $password)
|
||||
touch $htpasswd
|
||||
sed -i "/^$auth_user:/d" $htpasswd
|
||||
echo "$auth_user:$auth_hash" >> $htpasswd
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Rebuilding AUTH_HASH variable
|
||||
position=$(echo $AUTH_USER |tr ':' '\n' |grep -n '' |grep ":$auth_user$" |\
|
||||
cut -f 1 -d:)
|
||||
auth_hash=$(echo $AUTH_HASH |tr ':' '\n' |grep -n '' |\
|
||||
sed -e "s%^$position:.*%$position:$auth_hash%" |\
|
||||
cut -f 2 -d :| sed -e "/^$/d"| sed -e ':a;N;$!ba;s/\n/:/g')
|
||||
|
||||
# Updating config
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_HASH' "$auth_hash"
|
||||
|
||||
# Logging
|
||||
log_history "changed auth user $httpauth_user password on $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -59,11 +59,10 @@ if [ "$SSL" = 'yes' ]; then
|
|||
fi
|
||||
|
||||
# Checking proxy
|
||||
if [ ! -z "$PROXY" ]; then
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
replace_web_config
|
||||
fi
|
||||
|
||||
# Checking SSL proxy
|
||||
if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then
|
||||
|
@ -71,6 +70,7 @@ if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then
|
|||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
replace_web_config
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -87,13 +87,11 @@ update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$3"
|
|||
# Restart web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "WEB restart failed" >/dev/null
|
||||
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
@ -39,7 +39,7 @@ is_object_unsuspended 'user' 'USER' "$user"
|
|||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||
is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
|
||||
is_proxy_template_valid
|
||||
is_proxy_template_valid $template
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -87,16 +87,14 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Update config
|
||||
# Updating config
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
|
||||
|
||||
# Restart web
|
||||
# Restarting proxy
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-proxy
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: change domain ssl certificate
|
||||
# options: USER DOMAIN SSL_DIR
|
||||
# options: USER DOMAIN SSL_DIR [RESTART]
|
||||
#
|
||||
# The function changes SSL domain certificate and the key. If ca file present
|
||||
# it will be replaced as well.
|
||||
|
@ -10,11 +10,12 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
ssl_dir=$3
|
||||
restart=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -26,7 +27,7 @@ source $VESTA/conf/vesta.conf
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN SSL_DIR'
|
||||
check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]'
|
||||
validate_format 'user' 'domain' 'ssl_dir'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
@ -69,15 +70,15 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart web server
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
ssl_home=$3
|
||||
restart=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -21,7 +22,7 @@ source $VESTA/conf/vesta.conf
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN SSL_HOME'
|
||||
check_args '3' "$#" 'USER DOMAIN SSL_HOME [RESTART]'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
@ -55,7 +56,7 @@ esac
|
|||
replace_web_config
|
||||
|
||||
# Checking proxy config
|
||||
if [ ! -z "$PROXY" ]; then
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
replace_web_config
|
||||
|
@ -69,15 +70,15 @@ fi
|
|||
# Update config
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
|
||||
|
||||
# Restart web server
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue