mirror of
https://github.com/myvesta/vesta
synced 2025-08-21 13:54:28 -07:00
Merge remote-tracking branch 'refs/remotes/serghey-rodin/master'
This commit is contained in:
commit
e3149992e8
2192 changed files with 101406 additions and 14417 deletions
12
README.md
12
README.md
|
@ -13,12 +13,18 @@ Connect to your server as root via SSH
|
||||||
ssh root@your.server
|
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
|
```bash
|
||||||
curl -O http://vestacp.com/pub/vst-install.sh
|
curl -O http://vestacp.com/pub/vst-install.sh
|
||||||
```
|
```
|
||||||
|
Then run it:
|
||||||
Run it
|
|
||||||
```bash
|
```bash
|
||||||
bash vst-install.sh
|
bash vst-install.sh
|
||||||
```
|
```
|
||||||
|
|
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 defenition
|
||||||
|
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
|
|
@ -1,101 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# info: add backup ftp host
|
|
||||||
# options: HOST USERNAME PASSWORD [PATH] [PORT]
|
|
||||||
#
|
|
||||||
# The function adds ftp host for system backups
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Variable&Function #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Argument defenition
|
|
||||||
host=$1
|
|
||||||
ftp_user=$2
|
|
||||||
ftp_password=$3
|
|
||||||
ftp_path=${4-/backup}
|
|
||||||
ftp_port=${5-21}
|
|
||||||
A3='******'
|
|
||||||
|
|
||||||
# Includes
|
|
||||||
source $VESTA/func/main.sh
|
|
||||||
source $VESTA/conf/vesta.conf
|
|
||||||
|
|
||||||
# Defining ftp command function
|
|
||||||
ftpc() {
|
|
||||||
ftp -p -n $host $ftp_port <<EOF
|
|
||||||
quote USER $ftp_user
|
|
||||||
quote PASS $ftp_password
|
|
||||||
binary
|
|
||||||
$1
|
|
||||||
$2
|
|
||||||
$3
|
|
||||||
quit
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Verifications #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
check_args '3' "$#" "HOST USERNAME PASSWORD [PATH] [PORT]"
|
|
||||||
validate_format 'host' 'ftp_user' 'ftp_password'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Action #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Checking network connection
|
|
||||||
fconn=$(ftpc)
|
|
||||||
ferror=$(echo $fconn |grep -i -e failed -e error -e "Can't" -e "not conn")
|
|
||||||
if [ ! -z "$ferror" ]; then
|
|
||||||
echo "Error: can't login to ftp"
|
|
||||||
log_event "$E_CONNECT" "$EVENT"
|
|
||||||
exit $E_CONNECT
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking write permissions
|
|
||||||
ftpc "mkdir $ftp_path" > /dev/null 2>&1
|
|
||||||
ftmpdir="$ftp_path/vst.bK76A9SUkt"
|
|
||||||
ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir"|grep -v Trying)
|
|
||||||
if [ ! -z "$ftp_result" ] ; then
|
|
||||||
echo "$ftp_result"
|
|
||||||
rm -rf $tmpdir
|
|
||||||
echo "Error: can't create temp folder on the ftp"
|
|
||||||
log_event "$E_FTP" "$EVENT"
|
|
||||||
exit $E_FTP
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Adding backup host
|
|
||||||
echo "HOST='$host'
|
|
||||||
USERNAME='$ftp_user'
|
|
||||||
PASSWORD='$ftp_password'
|
|
||||||
BPATH='$ftp_path'
|
|
||||||
PORT='$ftp_port'
|
|
||||||
TIME='$TIME'
|
|
||||||
DATE='$DATE'" > $VESTA/conf/ftp.backup.conf
|
|
||||||
chmod 660 $VESTA/conf/ftp.backup.conf
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Vesta #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Update vesta.conf
|
|
||||||
if [ -z "$(grep LANGUAGE $VESTA/conf/vesta.conf)" ]; then
|
|
||||||
echo "BACKUP_SYSTEM='ftp'" >> $VESTA/conf/vesta.conf
|
|
||||||
else
|
|
||||||
bckp=$(echo "$BACKUP_SYSTEM,ftp" |\
|
|
||||||
sed "s/,/\n/g"|\
|
|
||||||
sort -r -u |\
|
|
||||||
sed "/^$/d"|\
|
|
||||||
sed ':a;N;$!ba;s/\n/,/g')
|
|
||||||
sed -i "s/BACKUP_SYSTEM=.*/BACKUP_SYSTEM='$bckp'/g" $VESTA/conf/vesta.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
log_event "$OK" "$EVENT"
|
|
||||||
|
|
||||||
exit
|
|
186
bin/v-add-backup-host
Executable file
186
bin/v-add-backup-host
Executable file
|
@ -0,0 +1,186 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: add backup host
|
||||||
|
# options: TYPE HOST USERNAME PASSWORD [PATH] [PORT]
|
||||||
|
#
|
||||||
|
# The function adds backup host
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
type=$1
|
||||||
|
host=$2
|
||||||
|
user=$3
|
||||||
|
password=$4; HIDE=4
|
||||||
|
path=${5-/backup}
|
||||||
|
port=$6
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
# Defining ftp command function
|
||||||
|
ftpc() {
|
||||||
|
ftp -p -n $host $port <<EOF
|
||||||
|
quote USER $user
|
||||||
|
quote PASS $password
|
||||||
|
binary
|
||||||
|
$1
|
||||||
|
$2
|
||||||
|
$3
|
||||||
|
quit
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Defining sftp command function
|
||||||
|
sftpc() {
|
||||||
|
expect -f "-" <<EOF "$@"
|
||||||
|
set count 0
|
||||||
|
spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o \
|
||||||
|
Port=$port $user@$host
|
||||||
|
expect {
|
||||||
|
"password:" {
|
||||||
|
send "$password\r"
|
||||||
|
exp_continue
|
||||||
|
}
|
||||||
|
|
||||||
|
-re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
|
||||||
|
set count \$argc
|
||||||
|
set output "Disconnected."
|
||||||
|
set rc $E_FTP
|
||||||
|
exp_continue
|
||||||
|
}
|
||||||
|
|
||||||
|
-re ".*denied.*(publickey|password)." {
|
||||||
|
set output "Permission denied, wrong publickey or password."
|
||||||
|
set rc $E_CONNECT
|
||||||
|
}
|
||||||
|
|
||||||
|
"sftp>" {
|
||||||
|
if {\$count < \$argc} {
|
||||||
|
set arg [lindex \$argv \$count]
|
||||||
|
send "\$arg\r"
|
||||||
|
incr count
|
||||||
|
} else {
|
||||||
|
send "exit\r"
|
||||||
|
set output "Disconnected."
|
||||||
|
if {[info exists rc] != 1} {
|
||||||
|
set rc $OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exp_continue
|
||||||
|
}
|
||||||
|
|
||||||
|
timeout {
|
||||||
|
set output "Connection timeout."
|
||||||
|
set rc $E_CONNECT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if {[info exists output] == 1} {
|
||||||
|
puts "\$output"
|
||||||
|
}
|
||||||
|
|
||||||
|
exit \$rc
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [ "$type" != 'local' ];then
|
||||||
|
check_args '4' "$#" "TYPE HOST USERNAME PASSWORD [PATH] [PORT]"
|
||||||
|
validate_format 'host'
|
||||||
|
is_password_valid
|
||||||
|
if [ "$type" = 'sftp' ]; then
|
||||||
|
which expect >/dev/null 2>&1
|
||||||
|
check_result $? "expect command not found" $E_NOTEXIST
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Checking network connection
|
||||||
|
if [ "$type" = 'ftp' ]; then
|
||||||
|
if [ -z $port ]; then
|
||||||
|
port=21
|
||||||
|
fi
|
||||||
|
fconn=$(ftpc 2>&1)
|
||||||
|
ferror=$(echo $fconn |\
|
||||||
|
grep -i -e failed -e error -e "can't" -e "not conn" -e "incorrect")
|
||||||
|
if [ ! -z "$ferror" ]; then
|
||||||
|
echo "Error: can't login to ftp $user@$host"
|
||||||
|
log_event "$E_CONNECT" "$EVENT"
|
||||||
|
exit $E_CONNECT
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checking write permissions
|
||||||
|
ftpc "mkdir $path" > /dev/null 2>&1
|
||||||
|
ftmpdir="$path/vst.bK76A9SUkt"
|
||||||
|
ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir"|grep -v Trying)
|
||||||
|
if [ ! -z "$ftp_result" ] ; then
|
||||||
|
echo "$ftp_result"
|
||||||
|
rm -rf $tmpdir
|
||||||
|
echo "Error: can't create $ftmpdir folder on the ftp"
|
||||||
|
log_event "$E_FTP" "$EVENT"
|
||||||
|
exit $E_FTP
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$type" = 'sftp' ]; then
|
||||||
|
if [ -z $port ]; then
|
||||||
|
port=22
|
||||||
|
fi
|
||||||
|
sftmpdir="$path/vst.bK76A9SUkt"
|
||||||
|
sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1
|
||||||
|
rc=$?
|
||||||
|
if [[ "$rc" != 0 ]]; then
|
||||||
|
case $rc in
|
||||||
|
$E_CONNECT) echo "Error: can't login to sftp $user@$host";;
|
||||||
|
$E_FTP) echo "Error: can't create temp folder on the sftp host";;
|
||||||
|
esac
|
||||||
|
log_event "$rc" "$EVENT"
|
||||||
|
exit "$rc"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Adding backup host
|
||||||
|
if [ $type != 'local' ]; then
|
||||||
|
echo "HOST='$host'
|
||||||
|
USERNAME='$user'
|
||||||
|
PASSWORD='$password'
|
||||||
|
BPATH='$path'
|
||||||
|
PORT='$port'
|
||||||
|
TIME='$TIME'
|
||||||
|
DATE='$DATE'" > $VESTA/conf/$type.backup.conf
|
||||||
|
chmod 660 $VESTA/conf/$type.backup.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Update vesta.conf
|
||||||
|
if [ -z "$(grep BACKUP_SYSTEM $VESTA/conf/vesta.conf)" ]; then
|
||||||
|
echo "BACKUP_SYSTEM='$type'" >> $VESTA/conf/vesta.conf
|
||||||
|
else
|
||||||
|
bckp=$(echo "$BACKUP_SYSTEM,$type" |\
|
||||||
|
sed "s/,/\n/g"|\
|
||||||
|
sort -r -u |\
|
||||||
|
sed "/^$/d"|\
|
||||||
|
sed ':a;N;$!ba;s/\n/,/g')
|
||||||
|
sed -i "s/BACKUP_SYSTEM=.*/BACKUP_SYSTEM='$bckp'/g" $VESTA/conf/vesta.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
|
@ -72,11 +72,9 @@ sync_cron_jobs
|
||||||
# Increasing cron value
|
# Increasing cron value
|
||||||
increase_user_value $user '$U_CRON_JOBS'
|
increase_user_value $user '$U_CRON_JOBS'
|
||||||
|
|
||||||
# Restart crond
|
# Restarting crond
|
||||||
$BIN/v-restart-cron
|
$BIN/v-restart-cron
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Cron restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "added cron job $job"
|
log_history "added cron job $job"
|
||||||
|
|
|
@ -46,9 +46,7 @@ sync_cron_jobs
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v-restart-cron
|
$BIN/v-restart-cron
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Cron restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "enabled cron reporting"
|
log_history "enabled cron reporting"
|
||||||
|
|
|
@ -66,11 +66,9 @@ sync_cron_jobs
|
||||||
# Increasing cron value
|
# Increasing cron value
|
||||||
increase_user_value $user '$U_CRON_JOBS'
|
increase_user_value $user '$U_CRON_JOBS'
|
||||||
|
|
||||||
# Restart crond
|
# Restarting crond
|
||||||
$BIN/v-restart-cron
|
$BIN/v-restart-cron
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Cron restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "added cron job $job"
|
log_history "added cron job $job"
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
user=$1
|
user=$1
|
||||||
database="$user"_"$2"
|
database="$user"_"$2"
|
||||||
dbuser="$user"_"$3"
|
dbuser="$user"_"$3"
|
||||||
dbpass=$4
|
password=$4; HIDE=4
|
||||||
type=${5-mysql}
|
type=${5-mysql}
|
||||||
host=$6
|
host=$6
|
||||||
charset=${7-UTF8}
|
charset=${7-UTF8}
|
||||||
|
@ -30,17 +30,13 @@ source $VESTA/func/main.sh
|
||||||
source $VESTA/func/db.sh
|
source $VESTA/func/db.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A4='******'
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DATABASE DBUSER DBPASS [TYPE] [HOST] [CHARSET]'
|
check_args '4' "$#" 'USER DATABASE DBUSER DBPASS [TYPE] [HOST] [CHARSET]'
|
||||||
validate_format 'user' 'database' 'dbuser' 'dbpass' 'charset'
|
validate_format 'user' 'database' 'dbuser' 'charset'
|
||||||
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
|
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
|
||||||
is_type_valid "$DB_SYSTEM" "$type"
|
is_type_valid "$DB_SYSTEM" "$type"
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
@ -51,6 +47,8 @@ is_object_valid "../../../conf/$type" 'DBHOST' "$host"
|
||||||
is_object_unsuspended "../../../conf/$type" 'DBHOST' "$host"
|
is_object_unsuspended "../../../conf/$type" 'DBHOST' "$host"
|
||||||
#is_charset_valid
|
#is_charset_valid
|
||||||
is_package_full 'DATABASES'
|
is_package_full 'DATABASES'
|
||||||
|
is_password_valid
|
||||||
|
dbpass="$password"
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
type=$1
|
type=$1
|
||||||
host=$2
|
host=$2
|
||||||
dbuser=$3
|
dbuser=$3
|
||||||
dbpass=$4
|
password=$4; HIDE=4
|
||||||
max_db=${6-500}
|
max_db=${6-500}
|
||||||
charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8}
|
charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8}
|
||||||
template=${8-template1}
|
template=${8-template1}
|
||||||
|
@ -27,8 +27,31 @@ source $VESTA/func/main.sh
|
||||||
source $VESTA/func/db.sh
|
source $VESTA/func/db.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
is_mysql_host_alive() {
|
||||||
A4='******'
|
mycnf=$(mktemp)
|
||||||
|
echo "[client]">$mycnf
|
||||||
|
echo "host='$HOST'" >> $mycnf
|
||||||
|
echo "user='$USER'" >> $mycnf
|
||||||
|
echo "password='$PASSWORD'" >> $mycnf
|
||||||
|
chmod 600 $mycnf
|
||||||
|
mysql --defaults-file=$mycnf -e 'SELECT VERSION()' >/dev/null 2>&1
|
||||||
|
rm $mycnf
|
||||||
|
if [ '0' -ne "$?" ]; then
|
||||||
|
echo "Error: MySQL connection to $host failed"
|
||||||
|
log_event "$E_CONNECT" "$EVENT"
|
||||||
|
exit $E_CONNECT
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
is_pgsql_host_alive() {
|
||||||
|
export PGPASSWORD="$dbpass"
|
||||||
|
psql -h $host -U $dbuser -c "SELECT VERSION()" > /dev/null 2>&1
|
||||||
|
if [ '0' -ne "$?" ]; then
|
||||||
|
echo "Error: PostgreSQL connection to $host failed"
|
||||||
|
log_event "$E_CONNECT" "$EVENT"
|
||||||
|
exit $E_CONNECT
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -37,10 +60,12 @@ A4='******'
|
||||||
|
|
||||||
args_usage='TYPE HOST DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL]'
|
args_usage='TYPE HOST DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL]'
|
||||||
check_args '4' "$#" "$args_usage"
|
check_args '4' "$#" "$args_usage"
|
||||||
validate_format 'host' 'dbuser' 'dbpass' 'max_db' 'charsets' 'template'
|
validate_format 'host' 'dbuser' 'max_db' 'charsets' 'template'
|
||||||
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
|
#is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
|
||||||
is_type_valid "$DB_SYSTEM" "$type"
|
#is_type_valid "$DB_SYSTEM" "$type"
|
||||||
is_dbhost_new
|
is_dbhost_new
|
||||||
|
is_password_valid
|
||||||
|
dbpass="$password"
|
||||||
case $type in
|
case $type in
|
||||||
mysql) is_mysql_host_alive ;;
|
mysql) is_mysql_host_alive ;;
|
||||||
pgsql) is_pgsql_host_alive ;;
|
pgsql) is_pgsql_host_alive ;;
|
||||||
|
@ -62,15 +87,28 @@ case $type in
|
||||||
str="$str TIME='$TIME' DATE='$DATE'";;
|
str="$str TIME='$TIME' DATE='$DATE'";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Adding host to conf
|
|
||||||
echo "$str" >> $VESTA/conf/$type.conf
|
|
||||||
chmod 660 $VESTA/conf/$type.conf
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Adding host to conf
|
||||||
|
echo "$str" >> $VESTA/conf/$type.conf
|
||||||
|
chmod 660 $VESTA/conf/$type.conf
|
||||||
|
|
||||||
|
# Updating vesta.conf
|
||||||
|
if [ -z "$(grep DB_SYSTEM $VESTA/conf/vesta.conf)" ]; then
|
||||||
|
echo "DB_SYSTEM='$type'" >> $VESTA/conf/vesta.conf
|
||||||
|
else
|
||||||
|
db=$(echo "$DB_SYSTEM,$type" |\
|
||||||
|
sed "s/,/\n/g"|\
|
||||||
|
sort -r -u |\
|
||||||
|
sed "/^$/d"|\
|
||||||
|
sed ':a;N;$!ba;s/\n/,/g')
|
||||||
|
sed -i "s/DB_SYSTEM=.*/DB_SYSTEM='$db'/g" $VESTA/conf/vesta.conf
|
||||||
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: add dns domain
|
# 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
|
# 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.
|
# argument isn't stated, the expiration date value will be set to next year.
|
||||||
|
@ -24,7 +24,11 @@ ns1=$4
|
||||||
ns2=$5
|
ns2=$5
|
||||||
ns3=$6
|
ns3=$6
|
||||||
ns4=$7
|
ns4=$7
|
||||||
restart=$8
|
ns5=$8
|
||||||
|
ns6=$9
|
||||||
|
ns7=${10}
|
||||||
|
ns8=${11}
|
||||||
|
restart=${12}
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -36,14 +40,13 @@ source $VESTA/conf/vesta.conf
|
||||||
# Verifications #
|
# 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'
|
validate_format 'user' 'domain' 'ip'
|
||||||
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_domain_new 'dns'
|
is_domain_new 'dns'
|
||||||
is_package_full 'DNS_DOMAINS'
|
is_package_full 'DNS_DOMAINS'
|
||||||
|
|
||||||
template=$(get_user_value '$DNS_TEMPLATE')
|
template=$(get_user_value '$DNS_TEMPLATE')
|
||||||
is_dns_template_valid
|
is_dns_template_valid
|
||||||
|
|
||||||
|
@ -64,6 +67,23 @@ if [ ! -z "$ns4" ]; then
|
||||||
ns4=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
ns4=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||||
validate_format 'ns4'
|
validate_format 'ns4'
|
||||||
fi
|
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
|
fi
|
||||||
soa="$ns1"
|
soa="$ns1"
|
||||||
exp=$(date +%F -d "+ 1 year")
|
exp=$(date +%F -d "+ 1 year")
|
||||||
|
serial=$(date +'%Y%m%d01')
|
||||||
ttl=14400
|
ttl=14400
|
||||||
|
|
||||||
# Reading template
|
# Reading template
|
||||||
|
@ -93,8 +114,20 @@ fi
|
||||||
if [ -z "$ns4" ]; then
|
if [ -z "$ns4" ]; then
|
||||||
template_data=$(echo "$template_data" |grep -v %ns4%)
|
template_data=$(echo "$template_data" |grep -v %ns4%)
|
||||||
fi
|
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" |\
|
echo "$template_data" |\
|
||||||
sed -e "s/%ip%/$ip/g" \
|
sed -e "s/%ip%/$ip/g" \
|
||||||
-e "s/%domain_idn%/$domain_idn/g" \
|
-e "s/%domain_idn%/$domain_idn/g" \
|
||||||
|
@ -103,6 +136,10 @@ echo "$template_data" |\
|
||||||
-e "s/%ns2%/$ns2/g" \
|
-e "s/%ns2%/$ns2/g" \
|
||||||
-e "s/%ns3%/$ns3/g" \
|
-e "s/%ns3%/$ns3/g" \
|
||||||
-e "s/%ns4%/$ns4/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/%time%/$TIME/g" \
|
||||||
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
|
-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
|
# Adding dns.conf record
|
||||||
dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
|
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 SOA='$soa' SERIAL='$serial' SRC='' RECORDS='$records'"
|
||||||
dns_rec="$dns_rec DATE='$DATE'"
|
dns_rec="$dns_rec SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
|
||||||
|
|
||||||
echo "$dns_rec" >> $USER_DATA/dns.conf
|
echo "$dns_rec" >> $USER_DATA/dns.conf
|
||||||
chmod 660 $USER_DATA/dns.conf
|
chmod 660 $USER_DATA/dns.conf
|
||||||
|
|
||||||
# Create system configs
|
# Creating system configs
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
if [ -e '/etc/named.conf' ]; then
|
if [ -e '/etc/named.conf' ]; then
|
||||||
dns_conf='/etc/named.conf'
|
dns_conf='/etc/named.conf'
|
||||||
|
@ -135,14 +172,14 @@ if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
# Updating domain dns zone
|
# Updating domain dns zone
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
|
|
||||||
# Set permissions
|
# Changing permissions
|
||||||
chmod 640 $conf
|
chmod 640 $HOMEDIR/$user/conf/dns/$domain.db
|
||||||
chown root:$dns_group $conf
|
chown root:$dns_group $HOMEDIR/$user/conf/dns/$domain.db
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Updating dns-cluster queue
|
# Updating dns-cluster queue
|
||||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
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
|
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -158,9 +195,7 @@ increase_user_value "$user" '$U_DNS_RECORDS' "$records"
|
||||||
# Restart named
|
# Restart named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "DNS restart failed"
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: add dns domain or dns record based on web domain alias restart
|
# info: add dns domain or dns record after web domain alias
|
||||||
# options: USER DOMAIN
|
# options: USER ALIAS IP [RESTART]
|
||||||
#
|
#
|
||||||
# The function adds dns domain or dns record based on web domain alias.
|
# The function adds dns domain or dns record based on web domain alias.
|
||||||
|
|
||||||
|
@ -11,13 +11,9 @@
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
alias=$2
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
ip=$3
|
||||||
dom_alias=$(idn -t --quiet -u "$3" )
|
restart=$4
|
||||||
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"
|
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -29,58 +25,54 @@ source $VESTA/conf/vesta.conf
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '3' "$#" 'USER DOMAIN ALIAS'
|
check_args '3' "$#" 'USER ALIAS IP [RESTART]'
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'alias' 'ip'
|
||||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
|
||||||
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
if [ -e "$USER_DATA/dns/$alias.conf" ]; then
|
||||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Parsing domain values
|
# Logging
|
||||||
get_domain_values 'web'
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
# Check if it a simple domain
|
# Define additional vars
|
||||||
if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then
|
sub_domain=$(echo "$alias" |awk -F '.' '{print $1}')
|
||||||
if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then
|
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 \
|
$BIN/v-add-dns-domain \
|
||||||
$user $dom_alias $IP '' '' '' '' '' $restart > /dev/null
|
$user $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
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
|
# Adding toplevel domain and then its sub
|
||||||
$BIN/v-add-dns-domain \
|
$BIN/v-add-dns-domain $user $top_domain $ip '' '' '' '' $restart >> /dev/null
|
||||||
$user $dom $IP '' '' '' '' $restart > /dev/null
|
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
# Checking top-level domain
|
||||||
$BIN/v-add-dns-record \
|
if [ ! -e "$USER_DATA/dns/$top_domain.conf" ]; then
|
||||||
$user $dom "$sub" A $IP '' '' $restart
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Checking subdomain record
|
||||||
|
if [ "$sub_domain" == '*' ]; then
|
||||||
|
check_record=$(grep -w "RECORD='\*'" $USER_DATA/dns/$top_domain.conf)
|
||||||
else
|
else
|
||||||
if [ "$sub" == '*' ]; then
|
check_record=$(grep -w "RECORD='$sub_domain'" $USER_DATA/dns/$top_domain.conf)
|
||||||
rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf)
|
|
||||||
else
|
|
||||||
rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$rec" ]; then
|
|
||||||
|
# Adding subdomain record
|
||||||
|
if [ -z "$check_record" ]; then
|
||||||
$BIN/v-add-dns-record \
|
$BIN/v-add-dns-record \
|
||||||
$user $dom "$sub" A $IP '' '' $restart > /dev/null
|
$user $top_domain "$sub_domain" A $ip '' '' $restart >> /dev/null
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,6 +80,6 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# No Logging
|
# No logging
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -82,6 +82,7 @@ sort_dns_records
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
|
update_domain_serial
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -108,9 +109,7 @@ increase_user_value "$user" '$U_DNS_RECORDS'
|
||||||
# Restart named
|
# Restart named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? $E_RESTART 'dns failed to restart'
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -47,37 +47,34 @@ if [ -z "$ip" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Web domain
|
# Working on web domain
|
||||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||||
$BIN/v-add-web-domain $user $domain $ip 'no'
|
$BIN/v-add-web-domain $user $domain $ip 'no'
|
||||||
return_code=$?
|
check_result $? "can't add web domain" >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Proxy support
|
# Working on DNS domain
|
||||||
if [ ! -z "$PROXY_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||||
extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls"
|
$BIN/v-add-dns-domain $user $domain $ip "" "" "" "" "" 'no'
|
||||||
extentions="$extentions,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav"
|
check_result $? "can't add dns domain" >/dev/null
|
||||||
extentions="$extentions,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
|
|
||||||
$BIN/v-add-web-domain-proxy $user $domain 'default' "$extentions" 'no'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# DNS domain
|
# Working on mail domain
|
||||||
if [ ! -z "$DNS_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||||
$BIN/v-add-dns-domain $user $domain $ip 'no'
|
|
||||||
return_code=$?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Mail domain
|
|
||||||
if [ ! -z "$MAIL_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
|
||||||
$BIN/v-add-mail-domain $user $domain
|
$BIN/v-add-mail-domain $user $domain
|
||||||
return_code=$?
|
check_result $? "can't add mail domain" >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart services
|
# Restarting services
|
||||||
if [ "$restart" != 'no' ] && [ "$return_code" -eq 0 ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
|
check_result $? "can't restart web" > /dev/null
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
|
check_result $? "can't restart proxy" > /dev/null
|
||||||
|
fi
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
|
check_result $? "can't restart dns" > /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,4 +82,4 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
exit $return_code
|
exit
|
||||||
|
|
59
bin/v-add-fs-archive
Executable file
59
bin/v-add-fs-archive
Executable file
|
@ -0,0 +1,59 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: archive directory
|
||||||
|
# options: USER ARCHIVE DIRECTORY [DIRECTORY_N]
|
||||||
|
#
|
||||||
|
# The function creates tar archive
|
||||||
|
|
||||||
|
user=$1
|
||||||
|
archive=$2
|
||||||
|
src1=$3
|
||||||
|
src2=$4
|
||||||
|
src3=$5
|
||||||
|
src4=$6
|
||||||
|
src5=$7
|
||||||
|
src6=$8
|
||||||
|
src7=$9
|
||||||
|
|
||||||
|
# Checking arguments
|
||||||
|
if [ -z "$src1" ]; then
|
||||||
|
echo "Usage: USER ARCHIVE DIRECTORY [DIRECTORY_N]"
|
||||||
|
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
|
||||||
|
for src_path in $src1 $src2 $src3 $src4 $src5 $src6 $src7; do
|
||||||
|
rpath=$(readlink -f "$src_path")
|
||||||
|
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||||
|
echo "Error: invalid source path $src_path"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Creating tar.gz archive
|
||||||
|
sudo -u $user tar -czf "$archive.tar.gz" \
|
||||||
|
$src1 $src2 $src3 $src4 $src5 $src6 $src7 > /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
|
|
@ -15,25 +15,24 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
account=$(echo $3 | tr '[:upper:]' '[:lower:]')
|
account=$(echo $3 | tr '[:upper:]' '[:lower:]')
|
||||||
password=$4
|
password=$4; HIDE=4
|
||||||
quota=${5-0}
|
quota=${5-unlimited}
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A4='******'
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]'
|
check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]'
|
||||||
validate_format 'user' 'domain' 'account' 'password' 'quota'
|
validate_format 'user' 'domain' 'account'
|
||||||
|
if [ "$quota" != 'unlimited' ]; then
|
||||||
|
validate_format 'quota'
|
||||||
|
fi
|
||||||
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
@ -41,19 +40,22 @@ is_object_valid 'mail' 'DOMAIN' "$domain"
|
||||||
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
|
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
|
||||||
is_package_full 'MAIL_ACCOUNTS'
|
is_package_full 'MAIL_ACCOUNTS'
|
||||||
is_mail_new "$account"
|
is_mail_new "$account"
|
||||||
|
is_password_valid
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
if [ -x '/usr/bin/doveadm' ]; then
|
# Generating hashed password
|
||||||
md5=$(/usr/bin/doveadm pw -s md5 -p "$password")
|
salt=$(gen_password "$PW_MATRIX" "8")
|
||||||
else
|
md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)"
|
||||||
md5=$(/usr/sbin/dovecotpw -s md5 -p "$password")
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Adding account info into password file
|
||||||
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
||||||
|
if [ "$quota" = 'unlimited' ]; then
|
||||||
|
quota='0'
|
||||||
|
fi
|
||||||
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
|
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
|
||||||
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||||
fi
|
fi
|
||||||
|
@ -63,6 +65,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [[ "$quota" -eq '0' ]]; then
|
||||||
|
quota='unlimited'
|
||||||
|
fi
|
||||||
|
|
||||||
str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''"
|
str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''"
|
||||||
str="$str FWD_ONLY='' MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME'"
|
str="$str FWD_ONLY='' MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME'"
|
||||||
str="$str DATE='$DATE'"
|
str="$str DATE='$DATE'"
|
||||||
|
|
|
@ -27,101 +27,64 @@ source $VESTA/conf/vesta.conf
|
||||||
check_args '2' "$#" 'USER DOMAIN [FLUSH]'
|
check_args '2' "$#" 'USER DOMAIN [FLUSH]'
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||||
|
|
||||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||||
echo "Error: dns-cluster.conf doesn't exist"
|
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||||
log_event "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
check_result $E_EXISTS "another sync process already running"
|
||||||
if [ "$number_of_proc" -gt 2 ]; then
|
|
||||||
echo "Error: another sync process already exists"
|
|
||||||
log_event "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
|
remote_dns_health_check
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Check domain existance
|
# Parsing domain record
|
||||||
check_local_domain=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf 2>/dev/null)
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf 2>/dev/null)
|
||||||
if [ -z "$check_local_domain" ]; then
|
if [ -z "$str" ]; then
|
||||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||||
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
|
queue_str=$(grep -n "$SCRIPT $1 $2 no$" $pipe |cut -f1 -d: |head -n1)
|
||||||
if [ ! -z "$str" ]; then
|
if [ ! -z "$queue_str" ]; then
|
||||||
sed -i "$str d" $pipe
|
sed -i "$queue_str d" $pipe
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
old_ifs="$IFS"
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||||
|
|
||||||
# Check remote dns nodes
|
# Parsing remote dns host parameters
|
||||||
remote_dns_health_check
|
eval $cluster
|
||||||
|
|
||||||
search_str=$(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf)
|
# Parsing domain parameters
|
||||||
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)
|
|
||||||
eval $str
|
eval $str
|
||||||
|
|
||||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME "$flush" 'no'
|
# Syncing domain data
|
||||||
if [ $? -eq 0 ]; then
|
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME $flush 'no'
|
||||||
# Sync records
|
check_result $? "$HOST connection failed" $E_CONNECT
|
||||||
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
|
|
||||||
|
|
||||||
# Rebuild dns zone
|
# Syncing domain records
|
||||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
|
tmp_file="/tmp/vst-sync.$DOMAIN"
|
||||||
if [ $? -ne 0 ]; then
|
cluster_file $USER_DATA/dns/$DOMAIN.conf $tmp_file
|
||||||
echo "Error: $TYPE connection to $HOST failed"
|
check_result $? "$HOST connection failed" $E_CONNECT
|
||||||
log_event "$E_CONNECT $EVENT"
|
|
||||||
exit $E_CONNECT
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# 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
|
done
|
||||||
|
|
||||||
# Update pipe
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Updating pipe
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||||
str=$(grep -n "$SCRIPT $1 $2 " $pipe | cut -f1 -d: | head -n1)
|
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
|
sed -i "$str d" $pipe
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Vesta #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -11,10 +11,15 @@
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
host=$1
|
host=$1
|
||||||
|
HOST=$host
|
||||||
port=$2
|
port=$2
|
||||||
|
PORT=$port
|
||||||
user=$3
|
user=$3
|
||||||
password=$4
|
USER=$user
|
||||||
|
password=$4; HIDE=4
|
||||||
|
PASSWORD=$password
|
||||||
type=${5-api}
|
type=${5-api}
|
||||||
|
TYPE="$type"
|
||||||
dns_user=${6-dns-cluster}
|
dns_user=${6-dns-cluster}
|
||||||
DNS_USER=$dns_user
|
DNS_USER=$dns_user
|
||||||
|
|
||||||
|
@ -23,9 +28,6 @@ source $VESTA/func/main.sh
|
||||||
source $VESTA/func/remote.sh
|
source $VESTA/func/remote.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding passwords
|
|
||||||
A4='******'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
|
@ -33,8 +35,9 @@ A4='******'
|
||||||
|
|
||||||
args_usage='HOST PORT USER PASSWORD [TYPE] [DNS_USER]'
|
args_usage='HOST PORT USER PASSWORD [TYPE] [DNS_USER]'
|
||||||
check_args '4' "$#" "$args_usage"
|
check_args '4' "$#" "$args_usage"
|
||||||
validate_format 'host' 'port' 'user' 'password' 'type' 'dns_user'
|
validate_format 'host' 'port' 'user' 'type' 'dns_user'
|
||||||
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
||||||
|
is_password_valid
|
||||||
is_dnshost_new
|
is_dnshost_new
|
||||||
is_dnshost_alive
|
is_dnshost_alive
|
||||||
|
|
||||||
|
@ -59,36 +62,26 @@ else
|
||||||
sed -i "s/DNS_CLUSTER=.*/DNS_CLUSTER='yes'/g" $VESTA/conf/vesta.conf
|
sed -i "s/DNS_CLUSTER=.*/DNS_CLUSTER='yes'/g" $VESTA/conf/vesta.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Enabling restart queue
|
# Enabling remote dns-cluster queue
|
||||||
HOST=$host
|
cluster_cmd v-add-cron-restart-job
|
||||||
PORT=$port
|
check_result $? "$HOST connection failed" $E_CONNECT
|
||||||
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
|
|
||||||
|
|
||||||
# Sync current zones
|
# Syncing all domains
|
||||||
$BIN/v-sync-dns-cluster $host
|
$BIN/v-sync-dns-cluster $host
|
||||||
return_code=$?
|
check_result $? "$HOST sync failed" $E_CONNECT
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# 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
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
|
|
@ -29,83 +29,62 @@ validate_format 'user' 'domain' 'id'
|
||||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||||
is_object_valid "dns/$domain" 'ID' "$id"
|
|
||||||
|
|
||||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||||
echo "Error: dns-cluster.conf doesn't exist"
|
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||||
log_event "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
check_result $E_EXISTS "another sync process already running"
|
||||||
if [ "$number_of_proc" -gt 2 ]; then
|
|
||||||
echo "Error: another sync process already exists"
|
|
||||||
log_event "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
|
remote_dns_health_check
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
old_ifs="$IFS"
|
# Parsing record
|
||||||
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
|
|
||||||
str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
|
str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
|
||||||
str=$(echo "$str" | sed 's/"/\\"/g')
|
if [ -z "$str" ]; then
|
||||||
$send_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no'
|
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||||
if [ $? -eq 0 ]; then
|
queue_str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||||
# Rebuild dns zone
|
if [ ! -z "$queue_str" ]; then
|
||||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
|
sed -i "$queue_str d" $pipe
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
|
||||||
log_event "$E_CONNECT $EVENT"
|
|
||||||
exit $E_CONNECT
|
|
||||||
fi
|
fi
|
||||||
|
exit
|
||||||
fi
|
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
|
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 #
|
# 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
|
exit
|
||||||
|
|
|
@ -159,14 +159,19 @@ else
|
||||||
increase_user_value 'admin' '$IP_AVAIL'
|
increase_user_value 'admin' '$IP_AVAIL'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart web server
|
# Restarting web server
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
# Restarting proxy server
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
fi
|
||||||
|
|
||||||
|
# Restarting firewall
|
||||||
|
if [ ! -z "$FIREWALL_SYSTEM" ]; then
|
||||||
|
$BIN/v-update-firewall
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -22,18 +22,11 @@ source $VESTA/conf/vesta.conf
|
||||||
if [ ! -e "/usr/sbin/setquota" ]; then
|
if [ ! -e "/usr/sbin/setquota" ]; then
|
||||||
if [ -e "/etc/redhat-release" ]; then
|
if [ -e "/etc/redhat-release" ]; then
|
||||||
yum -y install quota >/dev/null 2>&1
|
yum -y install quota >/dev/null 2>&1
|
||||||
result=$?
|
check_result $? "quota package installation failed" $E_UPDATE
|
||||||
else
|
else
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get -y install quota >/dev/null 2>&1
|
apt-get -y install quota >/dev/null 2>&1
|
||||||
result=$?
|
check_result $? "quota package installation failed" $E_UPDATE
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -66,11 +59,7 @@ chmod a+x /etc/cron.daily/quotacheck
|
||||||
# Enabling fs quota
|
# Enabling fs quota
|
||||||
if [ ! -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
|
if [ ! -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
|
||||||
quotaon $mnt
|
quotaon $mnt
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "quota can't be enabled in $mtn" $E_DISK
|
||||||
echo "Error: quota can't be enabled on $mnt partition"
|
|
||||||
log_event "$E_DISK" "$EVENT"
|
|
||||||
exit $E_DISK
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Updating DISK_QUOTA value
|
# Updating DISK_QUOTA value
|
||||||
|
|
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
|
||||||
|
# opions: NONE
|
||||||
|
#
|
||||||
|
# The script enables sftp jailed environment
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Importing system enviroment as we run this script
|
||||||
|
# mostly by cron wich 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
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
password=$2
|
password=$2; HIDE=2
|
||||||
email=$3
|
email=$3
|
||||||
package=${4-default}
|
package=${4-default}
|
||||||
fname=$5
|
fname=$5
|
||||||
|
@ -21,10 +21,6 @@ lname=$6
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A2='******'
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
is_user_free() {
|
is_user_free() {
|
||||||
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
|
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
|
||||||
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
|
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
|
||||||
|
@ -40,12 +36,12 @@ is_user_free() {
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '3' "$#" 'USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]'
|
check_args '3' "$#" 'USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]'
|
||||||
validate_format 'user' 'password' 'email' 'package'
|
validate_format 'user' 'email' 'package'
|
||||||
if [ ! -z "$fname" ]; then
|
if [ ! -z "$fname" ]; then
|
||||||
validate_format 'fname' 'lname'
|
validate_format 'fname' 'lname'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_user_free "$user"
|
is_user_free "$user"
|
||||||
|
is_password_valid
|
||||||
is_package_valid
|
is_package_valid
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,11 +58,7 @@ shell=$(grep -w "$shell_conf" /etc/shells |head -n1)
|
||||||
|
|
||||||
# Adding user
|
# Adding user
|
||||||
/usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
|
/usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "user creation failed" $E_INVALID
|
||||||
echo "Error: user creation failed"
|
|
||||||
log_event "$E_INVALID" "$EVENT"
|
|
||||||
exit $E_INVALID
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Adding password
|
# Adding password
|
||||||
echo "$user:$password" | /usr/sbin/chpasswd
|
echo "$user:$password" | /usr/sbin/chpasswd
|
||||||
|
@ -75,21 +67,15 @@ echo "$user:$password" | /usr/sbin/chpasswd
|
||||||
mkdir $HOMEDIR/$user/conf
|
mkdir $HOMEDIR/$user/conf
|
||||||
|
|
||||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||||
mkdir $HOMEDIR/$user/conf/web
|
mkdir $HOMEDIR/$user/conf/web $HOMEDIR/$user/web $HOMEDIR/$user/tmp
|
||||||
mkdir $HOMEDIR/$user/web
|
chmod 751 $HOMEDIR/$user/conf/web $HOMEDIR/$user/web
|
||||||
mkdir $HOMEDIR/$user/tmp
|
|
||||||
chmod 751 $HOMEDIR/$user/conf/web
|
|
||||||
chmod 751 $HOMEDIR/$user/web
|
|
||||||
chmod 771 $HOMEDIR/$user/tmp
|
chmod 771 $HOMEDIR/$user/tmp
|
||||||
chown $user:$user $HOMEDIR/$user/web
|
chown $user:$user $HOMEDIR/$user/web $HOMEDIR/$user/tmp
|
||||||
chown $user:$user $HOMEDIR/$user/tmp
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||||
mkdir $HOMEDIR/$user/conf/mail
|
mkdir $HOMEDIR/$user/conf/mail $HOMEDIR/$user/mail
|
||||||
mkdir $HOMEDIR/$user/mail
|
chmod 751 $HOMEDIR/$user/mail $HOMEDIR/$user/conf/mail
|
||||||
chmod 751 $HOMEDIR/$user/mail
|
|
||||||
chmod 751 $HOMEDIR/$user/conf/mail
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||||
|
@ -107,54 +93,47 @@ chattr +i $HOMEDIR/$user/conf
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding user dir
|
# Adding user dir
|
||||||
mkdir $USER_DATA
|
mkdir -p $USER_DATA/ssl $USER_DATA/dns $USER_DATA/mail
|
||||||
chmod 770 $USER_DATA
|
|
||||||
|
|
||||||
# Creating configuration files and pipes
|
# Creating configuration files and pipes
|
||||||
touch $USER_DATA/backup.conf
|
touch $USER_DATA/backup.conf \
|
||||||
chmod 660 $USER_DATA/backup.conf
|
$USER_DATA/history.log \
|
||||||
touch $USER_DATA/history.log
|
$USER_DATA/stats.log \
|
||||||
chmod 660 $USER_DATA/history.log
|
$USER_DATA/web.conf \
|
||||||
touch $USER_DATA/stats.log
|
$USER_DATA/dns.conf \
|
||||||
chmod 660 $USER_DATA/stats.log
|
$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
|
echo "$BIN/v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe
|
||||||
|
|
||||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
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" \
|
echo "$BIN/v-update-web-domains-traff $user" \
|
||||||
>> $VESTA/data/queue/traffic.pipe
|
>> $VESTA/data/queue/traffic.pipe
|
||||||
echo "$BIN/v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe
|
echo "$BIN/v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe
|
||||||
fi
|
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
|
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
|
echo "$BIN/v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$DB_SYSTEM" ]; then
|
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
|
echo "$BIN/v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$CRON_SYSTEM" ]; then
|
|
||||||
touch $USER_DATA/cron.conf
|
|
||||||
chmod 660 $USER_DATA/cron.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Filling user config
|
# Filling user config
|
||||||
if [ "$user" != 'admin' ]; then
|
if [ "$user" != 'admin' ]; then
|
||||||
|
@ -201,6 +180,7 @@ U_DATABASES='0'
|
||||||
U_CRON_JOBS='0'
|
U_CRON_JOBS='0'
|
||||||
U_BACKUPS='0'
|
U_BACKUPS='0'
|
||||||
LANGUAGE=''
|
LANGUAGE=''
|
||||||
|
NOTIFICATIONS='no'
|
||||||
TIME='$TIME'
|
TIME='$TIME'
|
||||||
DATE='$DATE'" > $USER_DATA/user.conf
|
DATE='$DATE'" > $USER_DATA/user.conf
|
||||||
chmod 660 $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"
|
$VESTA/data/packages/$package.sh "$user" "$email" "$fname" "$lname"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Adding jailed sftp env
|
||||||
|
if [ ! -z "$SFTPJAIL_KEY" ]; then
|
||||||
|
$BIN/v-add-user-sftp-jail $user
|
||||||
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "added system user $user" '' 'admin'
|
log_history "added system user $user" '' 'admin'
|
||||||
log_event "$OK" "$EVENT"
|
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 defenition
|
||||||
|
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 defenition
|
||||||
|
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
|
|
@ -29,16 +29,39 @@ is_package_new() {
|
||||||
|
|
||||||
is_package_consistent() {
|
is_package_consistent() {
|
||||||
source $pkg_dir/$package.pkg
|
source $pkg_dir/$package.pkg
|
||||||
|
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
|
||||||
validate_format_int $WEB_DOMAINS 'WEB_DOMAINS'
|
validate_format_int $WEB_DOMAINS 'WEB_DOMAINS'
|
||||||
|
fi
|
||||||
|
if [ "$WEB_ALIASES" != 'unlimited' ]; then
|
||||||
validate_format_int $WEB_ALIASES 'WEB_ALIASES'
|
validate_format_int $WEB_ALIASES 'WEB_ALIASES'
|
||||||
|
fi
|
||||||
|
if [ "$DNS_DOMAINS" != 'unlimited' ]; then
|
||||||
validate_format_int $DNS_DOMAINS 'DNS_DOMAINS'
|
validate_format_int $DNS_DOMAINS 'DNS_DOMAINS'
|
||||||
|
fi
|
||||||
|
if [ "$DNS_RECORDS" != 'unlimited' ]; then
|
||||||
validate_format_int $DNS_RECORDS 'DNS_RECORDS'
|
validate_format_int $DNS_RECORDS 'DNS_RECORDS'
|
||||||
|
fi
|
||||||
|
if [ "$MAIL_DOMAINS" != 'unlimited' ]; then
|
||||||
validate_format_int $MAIL_DOMAINS 'MAIL_DOMAINS'
|
validate_format_int $MAIL_DOMAINS 'MAIL_DOMAINS'
|
||||||
|
fi
|
||||||
|
if [ "$MAIL_ACCOUNTS" != 'unlimited' ]; then
|
||||||
validate_format_int $MAIL_ACCOUNTS 'MAIL_ACCOUNTS'
|
validate_format_int $MAIL_ACCOUNTS 'MAIL_ACCOUNTS'
|
||||||
|
fi
|
||||||
|
if [ "$DATABASES" != 'unlimited' ]; then
|
||||||
validate_format_int $DATABASES 'DATABASES'
|
validate_format_int $DATABASES 'DATABASES'
|
||||||
|
fi
|
||||||
|
if [ "$CRON_JOBS" != 'unlimited' ]; then
|
||||||
validate_format_int $CRON_JOBS 'CRON_JOBS'
|
validate_format_int $CRON_JOBS 'CRON_JOBS'
|
||||||
|
fi
|
||||||
|
if [ "$DISK_QUOTA" != 'unlimited' ]; then
|
||||||
validate_format_int $DISK_QUOTA 'DISK_QUOTA'
|
validate_format_int $DISK_QUOTA 'DISK_QUOTA'
|
||||||
|
fi
|
||||||
|
if [ "$BANDWIDTH" != 'unlimited' ]; then
|
||||||
|
validate_format_int $BANDWIDTH 'BANDWIDTH'
|
||||||
|
fi
|
||||||
|
if [ "$BACKUPS" != 'unlimited' ]; then
|
||||||
validate_format_int $BACKUPS 'BACKUPS'
|
validate_format_int $BACKUPS 'BACKUPS'
|
||||||
|
fi
|
||||||
validate_format_shell $SHELL
|
validate_format_shell $SHELL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
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
|
||||||
|
# opions: USER
|
||||||
|
#
|
||||||
|
# The script enables sftp jailed environment
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
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,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: add web domain
|
# 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
|
# 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
|
# undefined in the script, the template "default" will be used. The alias of
|
||||||
|
@ -20,8 +20,12 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ip=$3
|
ip=$3; IP=$3
|
||||||
restart=$4
|
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
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -34,7 +38,7 @@ source $VESTA/conf/vesta.conf
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '3' "$#" 'USER DOMAIN IP [RESTART]'
|
check_args '3' "$#" 'USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]'
|
||||||
validate_format 'user' 'domain' 'ip'
|
validate_format 'user' 'domain' 'ip'
|
||||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
@ -43,43 +47,60 @@ is_domain_new 'web'
|
||||||
is_ip_valid
|
is_ip_valid
|
||||||
is_ip_avalable
|
is_ip_avalable
|
||||||
is_package_full 'WEB_DOMAINS'
|
is_package_full 'WEB_DOMAINS'
|
||||||
|
|
||||||
template=$(get_user_value '$WEB_TEMPLATE')
|
template=$(get_user_value '$WEB_TEMPLATE')
|
||||||
is_web_template_valid
|
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 #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Define real ip in case of NAT
|
# Checking domain backend in case PHP-FPM is configured
|
||||||
IP=$ip
|
if [ ! -z "$WEB_BACKEND" ]; then
|
||||||
ip=$(get_real_ip $ip)
|
is_web_backend_pool_valid
|
||||||
|
$BIN/v-add-web-domain-backend $user $domain
|
||||||
# Defining domain aliases
|
rc=$?
|
||||||
ip_name=$(get_ip_name)
|
if [ $rc -ne 0 ]; then
|
||||||
ip_name_idn=$(idn -t --quiet -a "$ip_name")
|
exit $rc
|
||||||
domain_alias="www.$domain"
|
fi
|
||||||
domain_alias_idn="www.$domain_idn"
|
get_domain_backend_values
|
||||||
if [ ! -z "$ip_name" ]; then
|
backend=$(get_user_value '$BACKEND_TEMPLATE')
|
||||||
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
|
fi
|
||||||
|
|
||||||
# Defining vars for add_config function
|
# Defining variables for add_config function
|
||||||
|
ip=$(get_real_ip $ip)
|
||||||
group="$user"
|
group="$user"
|
||||||
email="info@$domain"
|
email="info@$domain"
|
||||||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$template.tpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
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
|
# Adding web config
|
||||||
add_web_config
|
add_web_config
|
||||||
|
|
||||||
|
@ -123,34 +144,54 @@ done
|
||||||
|
|
||||||
# Changing file owner
|
# Changing file owner
|
||||||
chown -R $user:$user $HOMEDIR/$user/web/$domain
|
chown -R $user:$user $HOMEDIR/$user/web/$domain
|
||||||
chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.*
|
chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.* $conf
|
||||||
chown root:$user $conf
|
|
||||||
|
|
||||||
# Changing file permissions
|
# Changing file permissions
|
||||||
chmod 640 $conf
|
chmod 640 $conf /var/log/$WEB_SYSTEM/domains/$domain.*
|
||||||
chmod 551 $HOMEDIR/$user/web/$domain
|
chmod 551 $HOMEDIR/$user/web/$domain
|
||||||
chmod 751 $HOMEDIR/$user/web/$domain/private
|
chmod 751 $HOMEDIR/$user/web/$domain/private \
|
||||||
chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin
|
$HOMEDIR/$user/web/$domain/cgi-bin \
|
||||||
chmod 751 $HOMEDIR/$user/web/$domain/public_html
|
$HOMEDIR/$user/web/$domain/public_html \
|
||||||
chmod 751 $HOMEDIR/$user/web/$domain/public_shtml
|
$HOMEDIR/$user/web/$domain/public_shtml \
|
||||||
chmod 751 $HOMEDIR/$user/web/$domain/document_errors
|
$HOMEDIR/$user/web/$domain/document_errors
|
||||||
chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/*
|
chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/* \
|
||||||
chmod -f -R 665 $HOMEDIR/$user/web/$domain/public_html/*
|
$HOMEDIR/$user/web/$domain/public_html/* \
|
||||||
chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/*
|
$HOMEDIR/$user/web/$domain/document_errors/* \
|
||||||
chmod 551 $HOMEDIR/$user/web/$domain/stats
|
chmod 551 $HOMEDIR/$user/web/$domain/stats \
|
||||||
chmod 551 $HOMEDIR/$user/web/$domain/logs
|
$HOMEDIR/$user/web/$domain/logs
|
||||||
chmod 640 /var/log/$WEB_SYSTEM/domains/$domain.*
|
|
||||||
|
|
||||||
# Running template trigger
|
# Running template trigger
|
||||||
if [ -x $WEBTPL/$WEB_SYSTEM/$template.sh ]; then
|
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||||
$WEBTPL/$WEB_SYSTEM/$template.sh $user $domain $ip $HOMEDIR $docroot
|
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh \
|
||||||
|
$user $domain $ip $HOMEDIR $docroot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking web config
|
# Checking web config include
|
||||||
web_conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
|
web_conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
|
||||||
if [ -z "$(grep $conf $web_conf)" ]; then
|
web_include=$(grep "$conf" $web_conf )
|
||||||
|
if [ -z "$web_include" ] && [ "$WEB_SYSTEM" != 'nginx' ]; then
|
||||||
echo "Include $conf" >> $web_conf
|
echo "Include $conf" >> $web_conf
|
||||||
fi
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -164,20 +205,22 @@ increase_user_value "$user" '$U_WEB_ALIASES'
|
||||||
|
|
||||||
# Defining domain variables
|
# Defining domain variables
|
||||||
str="DOMAIN='$domain' IP='$IP' IP6='' ALIAS='$aliases' TPL='$template'"
|
str="DOMAIN='$domain' IP='$IP' IP6='' ALIAS='$aliases' TPL='$template'"
|
||||||
str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5=''"
|
str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5='' BACKEND='$backend'"
|
||||||
str="$str PROXY='' PROXY_EXT='' STATS='' STATS_USER=''"
|
str="$str PROXY='$proxy' PROXY_EXT='$extentions' STATS='' STATS_USER=''"
|
||||||
str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
|
str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
|
||||||
str="$str TIME='$TIME' DATE='$DATE'"
|
str="$str TIME='$TIME' DATE='$DATE'"
|
||||||
|
|
||||||
# Registering domain
|
# Registering domain
|
||||||
echo "$str" >> $USER_DATA/web.conf
|
echo "$str" >> $USER_DATA/web.conf
|
||||||
chmod 660 $USER_DATA/web.conf
|
|
||||||
|
|
||||||
# Restart web server
|
# Restarting web server
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
|
$BIN/v-restart-proxy
|
||||||
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
is_object_unsuspended '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'
|
is_package_full 'WEB_ALIASES'
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ is_package_full 'WEB_ALIASES'
|
||||||
|
|
||||||
# Parsing domain values
|
# Parsing domain values
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.tpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
ip=$(get_real_ip $IP)
|
ip=$(get_real_ip $IP)
|
||||||
|
|
||||||
|
@ -68,14 +68,14 @@ del_web_config
|
||||||
add_web_config
|
add_web_config
|
||||||
|
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
add_web_config
|
add_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking proxy
|
# Checking proxy
|
||||||
if [ ! -z "$PROXY" ]; then
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
|
@ -100,16 +100,14 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
|
||||||
# Update counters
|
# Update counters
|
||||||
increase_user_value "$user" '$U_WEB_ALIASES'
|
increase_user_value "$user" '$U_WEB_ALIASES'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restarting web server
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
77
bin/v-add-web-domain-backend
Executable file
77
bin/v-add-web-domain-backend
Executable file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: add web domain backend
|
||||||
|
# options: USER DOMAIN [TEMPLATE] [RESTART]
|
||||||
|
#
|
||||||
|
# The call is used for adding web backend configuration for user
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
user=$1
|
||||||
|
domain=$2
|
||||||
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
template=$3
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/func/domain.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [RESTART]'
|
||||||
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||||
|
is_system_enabled "$WEB_BACKEND" 'WEB_BACKEND'
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_web_backend_template_valid $template
|
||||||
|
is_web_backend_pool_valid
|
||||||
|
if [ -e "$pool/$backend.conf" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Allocating backend port
|
||||||
|
backend_port=9000
|
||||||
|
ports=$(grep -v '^;' $pool/* 2>/dev/null |grep listen |grep -o :[0-9].*)
|
||||||
|
ports=$(echo "$ports" |sed "s/://" |sort -n)
|
||||||
|
for port in $ports; do
|
||||||
|
if [ "$backend_port" -eq "$port" ]; then
|
||||||
|
backend_port=$((backend_port + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Adding backend config
|
||||||
|
cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
|
||||||
|
sed -e "s|%backend_port%|$backend_port|" \
|
||||||
|
-e "s|%user%|$user|"\
|
||||||
|
-e "s|%domain%|$domain|"\
|
||||||
|
-e "s|%domain_idn%|$domain_idn|"\
|
||||||
|
-e "s|%backend%|$backend|g" > $pool/$backend.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Restart backend server
|
||||||
|
if [ "$restart" != 'no' ]; then
|
||||||
|
$BIN/v-restart-web-backend
|
||||||
|
check_result $? "Web backend restart failed" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_history "added $WEB_BACKEND backend configuration for $domain"
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
|
@ -14,7 +14,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ftp_user=${1}_${3}
|
ftp_user=${1}_${3}
|
||||||
ftp_password=$4
|
password=$4; HIDE=4
|
||||||
ftp_path=$5
|
ftp_path=$5
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
|
@ -22,17 +22,13 @@ source $VESTA/func/main.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A4='******'
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD [FTP_PATH]'
|
check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD [FTP_PATH]'
|
||||||
validate_format 'user' 'domain' 'ftp_user' 'ftp_password'
|
validate_format 'user' 'domain' 'ftp_user'
|
||||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
@ -44,6 +40,7 @@ if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then
|
||||||
log_event "$E_EXISTS" "$EVENT"
|
log_event "$E_EXISTS" "$EVENT"
|
||||||
exit $E_EXISTS
|
exit $E_EXISTS
|
||||||
fi
|
fi
|
||||||
|
is_password_valid
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -90,9 +87,14 @@ fi
|
||||||
-M -d "$ftp_path_a" > /dev/null 2>&1
|
-M -d "$ftp_path_a" > /dev/null 2>&1
|
||||||
|
|
||||||
# Set ftp user password
|
# Set ftp user password
|
||||||
echo "$ftp_user:$ftp_password" | /usr/sbin/chpasswd
|
echo "$ftp_user:$password" | /usr/sbin/chpasswd
|
||||||
ftp_md5=$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)
|
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 #
|
# 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 defenition
|
||||||
|
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
|
||||||
|
|
||||||
|
# Definining 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
|
|
@ -42,7 +42,7 @@ is_object_value_empty 'web' 'DOMAIN' "$domain" '$PROXY'
|
||||||
if [ -z $template ]; then
|
if [ -z $template ]; then
|
||||||
template=$(get_user_value '$PROXY_TEMPLATE')
|
template=$(get_user_value '$PROXY_TEMPLATE')
|
||||||
fi
|
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' "$PROXY"
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
|
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
|
||||||
|
|
||||||
# Restart web server
|
# Restarting web server
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_history "enabled proxy support for $domain"
|
log_history "enabled proxy support for $domain"
|
||||||
|
|
|
@ -63,7 +63,7 @@ chmod 660 $USER_DATA/ssl/$domain.*
|
||||||
# Parsing domain values
|
# Parsing domain values
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
SSL_HOME="$ssl_home"
|
SSL_HOME="$ssl_home"
|
||||||
ip=$(get_real_ip $IP)
|
ip=$(get_real_ip $IP)
|
||||||
|
|
||||||
|
@ -85,8 +85,9 @@ if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Running template trigger
|
# Running template trigger
|
||||||
if [ -x $WEBTPL/$WEB_SYSTEM/$template.sh ]; then
|
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||||
$WEBTPL/$WEB_SYSTEM/$template.sh $user $domain $ip $HOMEDIR $sdocroot
|
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh \
|
||||||
|
$user $domain $ip $HOMEDIR $sdocroot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking web config
|
# Checking web config
|
||||||
|
@ -96,7 +97,7 @@ if [ -z "$(grep "$conf" $web_conf)" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking proxy
|
# Checking proxy
|
||||||
if [ ! -z "$PROXY" ]; then
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||||
add_web_config
|
add_web_config
|
||||||
|
@ -123,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_HOME' "$SSL_HOME"
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
|
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
|
||||||
|
|
||||||
# Restart web server
|
# Restarting web server
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -13,29 +13,26 @@
|
||||||
user=$1
|
user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
stats_user=$3
|
stats_user=$3
|
||||||
stats_pass=$4
|
password=$4; HIDE=4
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A4='******'
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DOMAIN STATS_USER STATS_PASS'
|
check_args '4' "$#" 'USER DOMAIN STATS_USER STATS_PASS'
|
||||||
validate_format 'user' 'domain' 'stats_user' 'stats_pass'
|
validate_format 'user' 'domain' 'stats_user'
|
||||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
|
is_password_valid
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -53,7 +50,7 @@ Require valid-user" > $stats_dir/.htaccess
|
||||||
|
|
||||||
# Generating htaccess user and password
|
# Generating htaccess user and password
|
||||||
rm -f $stats_dir/.htpasswd
|
rm -f $stats_dir/.htpasswd
|
||||||
htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$stats_pass" &>/dev/null
|
htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$password" &>/dev/null
|
||||||
stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :)
|
stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :)
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -56,7 +56,6 @@ else
|
||||||
subj="$user → backup failed"
|
subj="$user → backup failed"
|
||||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
|
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
|
||||||
fi
|
fi
|
||||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
|
||||||
|
|
||||||
# Check load average
|
# Check load average
|
||||||
la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
|
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
|
# Parsing domain exclusions
|
||||||
conf="$USER_DATA/web.conf"
|
conf="$USER_DATA/web.conf"
|
||||||
for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do
|
for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do
|
||||||
check_exl=$(echo -e "${WEB//,/\n}" |grep "^$domain$")
|
exclusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain$")
|
||||||
if [ -z "$check_exl" ]; then
|
if [ -z "$exclusion" ]; then
|
||||||
web_list="$web_list $domain"
|
web_list="$web_list $domain"
|
||||||
else
|
else
|
||||||
echo "$(date "+%F %T") excluding $domain"
|
echo "$(date "+%F %T") excluding $domain"
|
||||||
|
@ -166,14 +165,14 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
|
||||||
grep "DOMAIN='$domain'" $conf > vesta/web.conf
|
grep "DOMAIN='$domain'" $conf > vesta/web.conf
|
||||||
|
|
||||||
# Backup vhost config
|
# Backup vhost config
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.tpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
get_web_config_brds
|
get_web_config_brds
|
||||||
sed -n "$top_line,$bottom_line p" $conf > conf/$WEB_SYSTEM.conf
|
sed -n "$top_line,$bottom_line p" $conf > conf/$WEB_SYSTEM.conf
|
||||||
|
|
||||||
# Backup ssl vhost
|
# Backup ssl vhost
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
get_web_config_brds
|
get_web_config_brds
|
||||||
sed -n "$top_line,$bottom_line p" $conf > conf/s$WEB_SYSTEM.conf
|
sed -n "$top_line,$bottom_line p" $conf > conf/s$WEB_SYSTEM.conf
|
||||||
|
@ -207,36 +206,26 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define exclude arguments
|
# Define exclude arguments
|
||||||
|
exlusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain:")
|
||||||
set -f
|
set -f
|
||||||
fargs=()
|
fargs=()
|
||||||
fargs+=(-not)
|
fargs+=(--exclude='logs/*')
|
||||||
fargs+=(-path)
|
if [ ! -z "$exlusion" ]; then
|
||||||
fargs+=("./logs*")
|
xdirs="$(echo -e "$exlusion" |tr ':' '\n' |grep -v $domain)"
|
||||||
check_exlusion=$(echo -e "${WEB//,/\n}" | grep "^$domain:")
|
|
||||||
if [ ! -z "$check_exlusion" ]; then
|
|
||||||
xdirs="$(echo -e "${check_exlusion//:/\n}" |grep -v $domain)"
|
|
||||||
for xpath in $xdirs; do
|
for xpath in $xdirs; do
|
||||||
xpath="$(echo $xpath | sed -e 's/\/*$//' -e 's/^\/*//')"
|
fargs+=(--exclude=$xpath/*)
|
||||||
fargs+=(-not)
|
|
||||||
fargs+=(-path)
|
|
||||||
fargs+=("./$xpath/*")
|
|
||||||
echo "$(date "+%F %T") excluding directory $xpath"
|
echo "$(date "+%F %T") excluding directory $xpath"
|
||||||
msg="$msg\n$(date "+%F %T") excluding directory $xpath"
|
msg="$msg\n$(date "+%F %T") excluding directory $xpath"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
set +f
|
||||||
|
|
||||||
# Backup files
|
# Backup files
|
||||||
cd $HOMEDIR/$user/web/$domain
|
cd $HOMEDIR/$user/web/$domain
|
||||||
find . ${fargs[@]} -type f -print0 |\
|
tar -cpf $tmpdir/web/$domain/domain_data.tar * ${fargs[@]}
|
||||||
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 -
|
|
||||||
|
|
||||||
# Compress archive
|
# Compress archive
|
||||||
gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
|
gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
|
||||||
set +f
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Print total
|
# Print total
|
||||||
|
@ -259,8 +248,8 @@ if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS" != '*' ]; then
|
||||||
|
|
||||||
# Parsing domain exclusions
|
# Parsing domain exclusions
|
||||||
for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
|
for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
|
||||||
check_exl=$(echo -e "${DNS//,/\n}" |grep "^$domain$")
|
exclusion=$(echo "$DNS" |tr ',' '\n' |grep "^$domain$")
|
||||||
if [ -z "$check_exl" ]; then
|
if [ -z "$exclusion" ]; then
|
||||||
dns_list="$dns_list $domain"
|
dns_list="$dns_list $domain"
|
||||||
else
|
else
|
||||||
echo "$(date "+%F %T") excluding $domain"
|
echo "$(date "+%F %T") excluding $domain"
|
||||||
|
@ -312,7 +301,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
|
||||||
# Parsing domain exclusions
|
# Parsing domain exclusions
|
||||||
conf="$USER_DATA/mail.conf"
|
conf="$USER_DATA/mail.conf"
|
||||||
for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do
|
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
|
if [ -z "$check_exl" ]; then
|
||||||
mail_list="$mail_list $domain"
|
mail_list="$mail_list $domain"
|
||||||
else
|
else
|
||||||
|
@ -348,8 +337,8 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
|
||||||
# Backup emails
|
# Backup emails
|
||||||
cd $HOMEDIR/$user/mail/$domain_idn
|
cd $HOMEDIR/$user/mail/$domain_idn
|
||||||
for account in $(ls); do
|
for account in $(ls); do
|
||||||
exclusion=$(echo -e "${MAIL//,/\n}" |grep "$domain:")
|
exclusion=$(echo "$MAIL" |tr ',' '\n' |grep "$domain:")
|
||||||
exclusion=$(echo -e "${exclusion//:/\n}" |grep "^$account$")
|
exclusion=$(echo "$exclusion" |tr ':' '\n' |grep "^$account$")
|
||||||
|
|
||||||
# Checking exlusions
|
# Checking exlusions
|
||||||
if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
||||||
|
@ -390,8 +379,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
|
||||||
|
|
||||||
# Parsing database exclusions
|
# Parsing database exclusions
|
||||||
for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do
|
for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do
|
||||||
check_exl=$(echo -e "${DB//,/\n}" |grep "^$database$")
|
exclusion=$(echo "$DB" |tr ',' '\n' |grep "^$database$")
|
||||||
if [ -z "$check_exl" ]; then
|
if [ -z "$exclusion" ]; then
|
||||||
db_list="$db_list $database"
|
db_list="$db_list $database"
|
||||||
else
|
else
|
||||||
echo "$(date "+%F %T") excluding $database"
|
echo "$(date "+%F %T") excluding $database"
|
||||||
|
@ -477,9 +466,8 @@ if [ "$USER" != '*' ]; then
|
||||||
if [ -e "$USER_DATA/backup-excludes.conf" ]; then
|
if [ -e "$USER_DATA/backup-excludes.conf" ]; then
|
||||||
source $USER_DATA/backup-excludes.conf
|
source $USER_DATA/backup-excludes.conf
|
||||||
fi
|
fi
|
||||||
exlusion_list=$(echo -e "${USER//,/\n}")
|
|
||||||
fargs=()
|
fargs=()
|
||||||
for xpath in $exlusion_list; do
|
for xpath in $(echo "$USER" |tr ',' '\n'); do
|
||||||
fargs+=(-not)
|
fargs+=(-not)
|
||||||
fargs+=(-path)
|
fargs+=(-path)
|
||||||
fargs+=("./$xpath*")
|
fargs+=("./$xpath*")
|
||||||
|
@ -490,21 +478,17 @@ if [ "$USER" != '*' ]; then
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
set -f
|
set -f
|
||||||
i=0
|
i=0
|
||||||
for udir in $(ls |egrep -v "conf|web|dns|mail"); do
|
|
||||||
check_exl=$(echo -e "${USER//,/\n}" |grep "^$udir$")
|
for udir in $(ls -a |egrep -v "conf|web|dns|mail|^\.\.$|^\.$"); do
|
||||||
if [ -z "$check_exl" ]; then
|
exclusion=$(echo "$USER" |tr ',' '\n' |grep "^$udir$")
|
||||||
|
if [ -z "$exclusion" ]; then
|
||||||
((i ++))
|
((i ++))
|
||||||
udir_list="$udir_list $udir"
|
udir_list="$udir_list $udir"
|
||||||
echo -e "$(date "+%F %T") adding directory $udir"
|
echo -e "$(date "+%F %T") adding $udir"
|
||||||
msg="$msg\n$(date "+%F %T") adding directory $udir"
|
msg="$msg\n$(date "+%F %T") adding $udir"
|
||||||
|
|
||||||
# Backup files
|
# Backup files and dirs
|
||||||
find ./$udir ${fargs[@]} -type f -print0 |\
|
tar -cpf $tmpdir/user_dir/$udir.tar $udir
|
||||||
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 -
|
|
||||||
|
|
||||||
# Compress arhive
|
# Compress arhive
|
||||||
gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
|
gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
|
||||||
|
@ -536,11 +520,8 @@ TIME=$(date +%T)
|
||||||
|
|
||||||
# Defining local storage function
|
# Defining local storage function
|
||||||
local_backup(){
|
local_backup(){
|
||||||
# Removing dublicate for this day
|
|
||||||
if [ -e "$BACKUP/$user.$DATE.tar" ]; then
|
|
||||||
deprecated="$DATE"
|
|
||||||
rm -f $BACKUP/$user.$DATE.tar
|
rm -f $BACKUP/$user.$DATE.tar
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking retention
|
# Checking retention
|
||||||
backup_list=$(ls -lrt $BACKUP/ |awk '{print $9}' |grep "^$user\.")
|
backup_list=$(ls -lrt $BACKUP/ |awk '{print $9}' |grep "^$user\.")
|
||||||
|
@ -549,10 +530,9 @@ local_backup(){
|
||||||
backups_rm_number=$((backups_count - BACKUPS))
|
backups_rm_number=$((backups_count - BACKUPS))
|
||||||
(( ++backups_rm_number))
|
(( ++backups_rm_number))
|
||||||
|
|
||||||
for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
|
|
||||||
# Removing old backup
|
# Removing old backup
|
||||||
|
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
|
||||||
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
|
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
|
||||||
deprecated="$deprecated $backup_date"
|
|
||||||
echo -e "$(date "+%F %T") Roated: $backup_date"
|
echo -e "$(date "+%F %T") Roated: $backup_date"
|
||||||
msg="$msg\n$(date "+%F %T") Rotated: $backup_date"
|
msg="$msg\n$(date "+%F %T") Rotated: $backup_date"
|
||||||
rm -f $BACKUP/$backup
|
rm -f $BACKUP/$backup
|
||||||
|
@ -672,7 +652,6 @@ ftp_backup() {
|
||||||
backups_rm_number=$((backups_count - BACKUPS + 1))
|
backups_rm_number=$((backups_count - BACKUPS + 1))
|
||||||
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
|
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
|
||||||
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
|
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
|
||||||
deprecated="$deprecated $backup"
|
|
||||||
echo -e "$(date "+%F %T") Roated ftp backup: $backup_date"
|
echo -e "$(date "+%F %T") Roated ftp backup: $backup_date"
|
||||||
msg="$msg\n$(date "+%F %T") Roated ftp backup: $backup_date"
|
msg="$msg\n$(date "+%F %T") Roated ftp backup: $backup_date"
|
||||||
ftpc "cd $BPATH" "delete $backup"
|
ftpc "cd $BPATH" "delete $backup"
|
||||||
|
@ -692,6 +671,147 @@ ftp_backup() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# sftp command function
|
||||||
|
sftpc() {
|
||||||
|
expect -f "-" <<EOF "$@"
|
||||||
|
set timeout 60
|
||||||
|
set count 0
|
||||||
|
spawn /usr/bin/sftp -o StrictHostKeyChecking=no \
|
||||||
|
-o Port=$PORT $USERNAME@$HOST
|
||||||
|
expect {
|
||||||
|
"password:" {
|
||||||
|
send "$PASSWORD\r"
|
||||||
|
exp_continue
|
||||||
|
}
|
||||||
|
|
||||||
|
-re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
|
||||||
|
set count \$argc
|
||||||
|
set output "Disconnected."
|
||||||
|
set rc $E_FTP
|
||||||
|
exp_continue
|
||||||
|
}
|
||||||
|
|
||||||
|
-re ".*denied.*(publickey|password)." {
|
||||||
|
set output "Permission denied, wrong publickey or password."
|
||||||
|
set rc $E_CONNECT
|
||||||
|
}
|
||||||
|
|
||||||
|
-re "\[0-9]*%" {
|
||||||
|
exp_continue
|
||||||
|
}
|
||||||
|
|
||||||
|
"sftp>" {
|
||||||
|
if {\$count < \$argc} {
|
||||||
|
set arg [lindex \$argv \$count]
|
||||||
|
send "\$arg\r"
|
||||||
|
incr count
|
||||||
|
} else {
|
||||||
|
send "exit\r"
|
||||||
|
set output "Disconnected."
|
||||||
|
if {[info exists rc] != 1} {
|
||||||
|
set rc $OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exp_continue
|
||||||
|
}
|
||||||
|
|
||||||
|
timeout {
|
||||||
|
set output "Connection timeout."
|
||||||
|
set rc $E_CONNECT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if {[info exists output] == 1} {
|
||||||
|
puts "\$output"
|
||||||
|
}
|
||||||
|
|
||||||
|
exit \$rc
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
sftp_backup() {
|
||||||
|
|
||||||
|
# Checking config
|
||||||
|
if [ ! -e "$VESTA/conf/sftp.backup.conf" ]; then
|
||||||
|
sftp_conf_error="Can't open $VESTA/conf/sftp.backup.conf"
|
||||||
|
echo "$sftp_conf_error" |$send_mail -s "$subj" $email
|
||||||
|
echo "Error: $VESTA/conf/sftp.backup.conf doesn't exist"
|
||||||
|
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
|
||||||
|
log_event "$E_NOTEXIST" "$EVENT"
|
||||||
|
exit $E_NOTEXIST
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Parse config
|
||||||
|
source $VESTA/conf/sftp.backup.conf
|
||||||
|
|
||||||
|
# Set current data
|
||||||
|
DATE=$(date +%F)
|
||||||
|
TIME=$(date +%T)
|
||||||
|
|
||||||
|
# Set default port
|
||||||
|
if [ -z "$(grep 'PORT=' $VESTA/conf/sftp.backup.conf)" ]; then
|
||||||
|
PORT='22'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checking variables
|
||||||
|
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
|
||||||
|
rm -rf $tmpdir
|
||||||
|
echo "Can't parse sftp backup configuration" |\
|
||||||
|
$send_mail -s "$subj" $email
|
||||||
|
echo "Error: Parsing error"
|
||||||
|
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
|
||||||
|
log_event "$E_PARSING" "$EVENT"
|
||||||
|
exit $E_PARSING
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Debug info
|
||||||
|
echo -e "$(date "+%F %T") Remote: sftp://$HOST/$BPATH/$user.$DATE.tar"
|
||||||
|
|
||||||
|
# Checking network connection and write permissions
|
||||||
|
sftmpdir="$BPATH/vst.bK76A9SUkt"
|
||||||
|
sftpc "mkdir $BPATH" > /dev/null 2>&1
|
||||||
|
sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1
|
||||||
|
rc=$?
|
||||||
|
if [[ "$rc" != 0 ]]; then
|
||||||
|
rm -rf $tmpdir
|
||||||
|
case $rc in
|
||||||
|
$E_CONNECT) echo "Error: can't login to sftp host $HOST" |\
|
||||||
|
$send_mail -s "$subj" $email;;
|
||||||
|
$E_FTP) echo "Error: can't create temp folder on sftp $HOST" |\
|
||||||
|
$send_mail -s "$subj" $email;;
|
||||||
|
esac
|
||||||
|
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
|
||||||
|
log_event "$rc" "$EVENT"
|
||||||
|
exit "$rc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checking retention
|
||||||
|
backup_list=$(sftpc "cd $BPATH" "ls -l" |awk '{print $9}' |grep "^$user\.")
|
||||||
|
backups_count=$(echo "$backup_list" |wc -l)
|
||||||
|
if [ "$backups_count" -ge "$BACKUPS" ]; then
|
||||||
|
backups_rm_number=$((backups_count - BACKUPS + 1))
|
||||||
|
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
|
||||||
|
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar.*$//")
|
||||||
|
echo -e "$(date "+%F %T") Roated sftp backup: $backup_date"
|
||||||
|
msg="$msg\n$(date "+%F %T") Roated sftp backup: $backup_date"
|
||||||
|
sftpc "cd $BPATH" "rm $backup" > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Uploading backup archive
|
||||||
|
echo -e "$(date "+%F %T") Uploading $user.$DATE.tar ..."
|
||||||
|
if [ "$localbackup" = 'yes' ]; then
|
||||||
|
cd $BACKUP
|
||||||
|
sftpc "cd $BPATH" "put $user.$DATE.tar" > /dev/null 2>&1
|
||||||
|
else
|
||||||
|
cd $tmpdir
|
||||||
|
tar -cf $BACKUP/$user.$DATE.tar .
|
||||||
|
cd $BACKUP/
|
||||||
|
sftpc "cd $BPATH" "put $user.$DATE.tar" > /dev/null 2>&1
|
||||||
|
rm -f $user.$DATE.tar
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo "-- SUMMARY --"
|
echo "-- SUMMARY --"
|
||||||
msg="$msg\n-- SUMMARY --"
|
msg="$msg\n-- SUMMARY --"
|
||||||
|
|
||||||
|
@ -700,11 +820,11 @@ for backup_type in $(echo -e "${BACKUP_SYSTEM//,/\\n}"); do
|
||||||
case $backup_type in
|
case $backup_type in
|
||||||
local) local_backup ;;
|
local) local_backup ;;
|
||||||
ftp) ftp_backup ;;
|
ftp) ftp_backup ;;
|
||||||
|
sftp) sftp_backup ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Removing tmpdir
|
# Removing tmpdir
|
||||||
cd /
|
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
|
|
||||||
# Calculation run time
|
# Calculation run time
|
||||||
|
@ -729,14 +849,11 @@ msg="$msg\n$(date "+%F %T") Runtime: $run_time $min"
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Deleting old backup records
|
# Removing duplicate
|
||||||
for backup_record in $deprecated; do
|
touch $USER_DATA/backup.conf
|
||||||
if [ -e "$USER_DATA/backup.conf" ]; then
|
sed -i "/$user.$DATE.tar/d" $USER_DATA/backup.conf
|
||||||
sed -i "/DATE='$backup_record/d" $USER_DATA/backup.conf
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Concatenating string
|
# Regestering new backup
|
||||||
backup_str="BACKUP='$user.$DATE.tar'"
|
backup_str="BACKUP='$user.$DATE.tar'"
|
||||||
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
|
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
|
||||||
backup_str="$backup_str WEB='${web_list// /,}'"
|
backup_str="$backup_str WEB='${web_list// /,}'"
|
||||||
|
@ -747,9 +864,13 @@ backup_str="$backup_str CRON='$cron_list'"
|
||||||
backup_str="$backup_str UDIR='${udir_list// /,}'"
|
backup_str="$backup_str UDIR='${udir_list// /,}'"
|
||||||
backup_str="$backup_str RUNTIME='$run_time' TIME='$TIME' DATE='$DATE'"
|
backup_str="$backup_str RUNTIME='$run_time' TIME='$TIME' DATE='$DATE'"
|
||||||
echo "$backup_str" >> $USER_DATA/backup.conf
|
echo "$backup_str" >> $USER_DATA/backup.conf
|
||||||
|
|
||||||
|
# Removing old backups
|
||||||
|
tail -n $BACKUPS $USER_DATA/backup.conf > $USER_DATA/backup.conf_
|
||||||
|
mv -f $USER_DATA/backup.conf_ $USER_DATA/backup.conf
|
||||||
chmod 660 $USER_DATA/backup.conf
|
chmod 660 $USER_DATA/backup.conf
|
||||||
|
|
||||||
# Clean backup queue
|
# Deleting task from queue
|
||||||
sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe
|
sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe
|
||||||
|
|
||||||
# Send notification
|
# Send notification
|
||||||
|
|
|
@ -22,6 +22,9 @@ source $VESTA/conf/vesta.conf
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [ -z "$BACKUP_SYSTEM" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
for user in $(ls $VESTA/data/users); do
|
for user in $(ls $VESTA/data/users); do
|
||||||
check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf)
|
check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf)
|
||||||
log=$VESTA/log/backup.log
|
log=$VESTA/log/backup.log
|
||||||
|
|
|
@ -64,11 +64,9 @@ sync_cron_jobs
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart crond
|
# Restarting crond
|
||||||
$BIN/v-restart-cron
|
$BIN/v-restart-cron
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Cron restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "changed cron job $job"
|
log_history "changed cron job $job"
|
||||||
|
|
64
bin/v-change-database-host-password
Executable file
64
bin/v-change-database-host-password
Executable file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: change database server password
|
||||||
|
# options: TYPE HOST USER PASSWORD
|
||||||
|
#
|
||||||
|
# The function changes database server password.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
type=$1
|
||||||
|
host=$2
|
||||||
|
dbuser=$3
|
||||||
|
password=$4; HIDE=4
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/func/db.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
args_usage='TYPE HOST DBUSER DBPASS'
|
||||||
|
check_args '4' "$#" "$args_usage"
|
||||||
|
validate_format 'host' 'dbuser'
|
||||||
|
is_object_valid "../../conf/$type" 'HOST' "$host"
|
||||||
|
dbpass="$password"
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Define email
|
||||||
|
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f2 -d \')
|
||||||
|
subj="v-change-database-host-password $*"
|
||||||
|
|
||||||
|
case $type in
|
||||||
|
mysql) mysql_connect $host;
|
||||||
|
query="USE mysql; UPDATE user SET"
|
||||||
|
query="$query password=PASSWORD('$dbpass')"
|
||||||
|
query="$query WHERE User='$dbuser';"
|
||||||
|
query="$query FLUSH PRIVILEGES;"
|
||||||
|
mysql_query "$query" ;;
|
||||||
|
pgsql) echo "TBD" >/dev/null;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
update_object_value "../../conf/$type" 'HOST' "$host" '$USER' "$dbuser"
|
||||||
|
update_object_value "../../conf/$type" 'HOST' "$host" '$PASSWORD' "$dbpass"
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: change database password
|
# info: change database owner
|
||||||
# options: DATABASE USER
|
# options: DATABASE USER
|
||||||
#
|
#
|
||||||
# The function for changing database owner.
|
# The function for changing database owner.
|
||||||
|
|
|
@ -13,30 +13,27 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
database=$2
|
database=$2
|
||||||
dbpass=$3
|
password=$3; HIDE=3
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/func/db.sh
|
source $VESTA/func/db.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A3='******'
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '3' "$#" 'USER DATABASE DBPASS'
|
check_args '3' "$#" 'USER DATABASE DBPASS'
|
||||||
validate_format 'user' 'database' 'dbpass'
|
validate_format 'user' 'database'
|
||||||
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
|
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'db' 'DB' "$database"
|
is_object_valid 'db' 'DB' "$database"
|
||||||
is_object_unsuspended 'db' 'DB' "$database"
|
is_object_unsuspended 'db' 'DB' "$database"
|
||||||
|
is_password_valid
|
||||||
|
dbpass="$password"
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
user=$1
|
user=$1
|
||||||
database=$2
|
database=$2
|
||||||
dbuser="$user"_"$3"
|
dbuser="$user"_"$3"
|
||||||
dbpass=$4
|
password=$4; HIDE=4
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -21,10 +21,6 @@ source $VESTA/func/db.sh
|
||||||
source $VESTA/func/rebuild.sh
|
source $VESTA/func/rebuild.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A4='******'
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
|
@ -32,14 +28,18 @@ EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||||
|
|
||||||
check_args '3' "$#" 'USER DATABASE DBUSER [DBPASS]'
|
check_args '3' "$#" 'USER DATABASE DBUSER [DBPASS]'
|
||||||
validate_format 'user' 'database' 'dbuser'
|
validate_format 'user' 'database' 'dbuser'
|
||||||
if [ ! -z "$dbpass" ]; then
|
|
||||||
validate_format 'dbpass'
|
|
||||||
fi
|
|
||||||
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
|
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'db' 'DB' "$database"
|
is_object_valid 'db' 'DB' "$database"
|
||||||
is_object_unsuspended 'db' 'DB' "$database"
|
is_object_unsuspended 'db' 'DB' "$database"
|
||||||
|
is_password_valid
|
||||||
|
dbpass="$password"
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Compare old and new user
|
# Compare old and new user
|
||||||
old_dbuser=$(get_object_value 'db' 'DB' "$database" '$DBUSER')
|
old_dbuser=$(get_object_value 'db' 'DB' "$database" '$DBUSER')
|
||||||
|
@ -47,11 +47,6 @@ if [ "$old_dbuser" = "$dbuser" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Action #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Set new dbuser
|
# Set new dbuser
|
||||||
update_object_value 'db' 'DB' "$database" '$DBUSER' "$dbuser"
|
update_object_value 'db' 'DB' "$database" '$DBUSER' "$dbuser"
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
|
update_domain_serial
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
|
||||||
# Check for first sync
|
# Check for first sync
|
||||||
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
|
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
|
||||||
if [ -z "$dlock" ]; then
|
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
|
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -69,12 +70,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "DNS restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -45,6 +45,7 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa"
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
|
update_domain_serial
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -63,12 +64,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "DNS restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -67,6 +67,7 @@ records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')"
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
|
update_domain_serial
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -89,12 +90,10 @@ fi
|
||||||
update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
|
update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
|
||||||
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
|
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "DNS restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -44,6 +44,7 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl"
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
|
update_domain_serial
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -62,12 +63,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "DNS restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -77,6 +77,7 @@ sort_dns_records
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
|
update_domain_serial
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -95,12 +96,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "DNS restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -51,6 +51,7 @@ sort_dns_records
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
|
update_domain_serial
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -69,12 +70,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "DNS restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
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
|
|
@ -15,24 +15,20 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
account=$3
|
account=$3
|
||||||
password=$4
|
password=$4; HIDE=4
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A4='******'
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD'
|
check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD'
|
||||||
validate_format 'user' 'domain' 'account' 'password'
|
validate_format 'user' 'domain' 'account'
|
||||||
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
@ -40,17 +36,16 @@ is_object_valid 'mail' 'DOMAIN' "$domain"
|
||||||
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
|
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
|
||||||
is_object_valid "mail/$domain" 'ACCOUNT' "$account"
|
is_object_valid "mail/$domain" 'ACCOUNT' "$account"
|
||||||
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
|
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
|
||||||
|
is_password_valid
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
if [ -x '/usr/bin/doveadm' ]; then
|
# Generating hashed password
|
||||||
md5=$(/usr/bin/doveadm pw -s md5 -p "$password")
|
salt=$(gen_password "$PW_MATRIX" "8")
|
||||||
else
|
md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)"
|
||||||
md5=$(/usr/sbin/dovecotpw -s md5 -p "$password")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
||||||
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
|
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||||
|
|
|
@ -28,7 +28,10 @@ source $VESTA/conf/vesta.conf
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA'
|
check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA'
|
||||||
validate_format 'user' 'domain' 'account' 'quota'
|
validate_format 'user' 'domain' 'account'
|
||||||
|
if [ "$quota" != 'unlimited' ]; then
|
||||||
|
validate_format 'quota'
|
||||||
|
fi
|
||||||
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
@ -44,6 +47,9 @@ is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
|
||||||
|
|
||||||
md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
|
md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
|
||||||
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
||||||
|
if [ "$quota" = 'unlimited' ]; then
|
||||||
|
quota=0
|
||||||
|
fi
|
||||||
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
|
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||||
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
|
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
|
||||||
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
|
||||||
|
@ -54,6 +60,10 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [[ "$quota" -eq 0 ]]; then
|
||||||
|
quota='unlimited'
|
||||||
|
fi
|
||||||
|
|
||||||
# Update quota
|
# Update quota
|
||||||
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota"
|
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota"
|
||||||
|
|
||||||
|
|
|
@ -28,79 +28,42 @@ validate_format 'user' 'domain'
|
||||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||||
|
|
||||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||||
echo "Error: dns-cluster.conf doesn't exist"
|
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||||
log_event "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
check_result $E_EXISTS "another sync process already running"
|
||||||
if [ "$number_of_proc" -gt 2 ]; then
|
|
||||||
echo "Error: another sync process already exists"
|
|
||||||
log_event "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
|
remote_dns_health_check
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
old_ifs="$IFS"
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||||
|
|
||||||
# Check remote dns nodes
|
# Parsing remote host parameters
|
||||||
remote_dns_health_check
|
eval $cluster
|
||||||
|
|
||||||
for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
# Syncing domain
|
||||||
|
|
||||||
# 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
|
|
||||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||||
eval $str
|
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
||||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'scheduled'
|
check_result $? "$HOST connection failed (exp insert)" $E_CONNECT
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error: $TYPE connection to $HOST failed"
|
|
||||||
log_event "$E_CONNECT $EVENT"
|
|
||||||
exit $E_CONNECT
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
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 #
|
# 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
|
exit
|
||||||
|
|
|
@ -28,82 +28,46 @@ validate_format 'user' 'domain'
|
||||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||||
|
|
||||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||||
echo "Error: dns-cluster.conf doesn't exist"
|
check_result 1 $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||||
log_event "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$(ps auxf |grep -v grep |grep $VESTA/bin/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
check_result 1 $E_EXISTS "another sync process already running"
|
||||||
if [ "$number_of_proc" -gt 2 ]; then
|
|
||||||
echo "Error: another sync process already exists"
|
|
||||||
log_event "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
|
remote_dns_health_check
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
old_ifs="$IFS"
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||||
|
|
||||||
# Check remote dns nodes
|
# Parsing remote host parameters
|
||||||
remote_dns_health_check
|
eval $cluster
|
||||||
|
|
||||||
for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
# Syncing SOA
|
||||||
|
|
||||||
# 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
|
|
||||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||||
eval $str
|
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
|
||||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
check_result $? "$HOST connection failed (sync)" $E_CONNECT
|
||||||
|
|
||||||
# Rebuild dns zone
|
# Rebuilding dns zone
|
||||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
|
cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
|
||||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
|
||||||
log_event "$E_CONNECT $EVENT"
|
|
||||||
exit $E_CONNECT
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
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 #
|
# 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
|
exit
|
||||||
|
|
|
@ -28,96 +28,46 @@ validate_format 'user' 'domain'
|
||||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||||
|
|
||||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||||
echo "Error: dns-cluster.conf doesn't exist"
|
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||||
log_event "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
check_result $E_EXISTS "another sync process already running"
|
||||||
if [ "$number_of_proc" -gt 2 ]; then
|
|
||||||
echo "Error: another sync process already exists"
|
|
||||||
log_event "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
|
remote_dns_health_check
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
old_ifs="$IFS"
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||||
|
|
||||||
# Check remote dns nodes
|
# Parsing remote host parameters
|
||||||
remote_dns_health_check
|
eval $cluster
|
||||||
|
|
||||||
# Starting cluster loop
|
# Syncing TTL
|
||||||
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
|
|
||||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||||
eval $str
|
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
|
||||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
check_result $? "$HOST connection failed (sync)" $E_CONNECT
|
||||||
|
|
||||||
# Rebuild dns zone
|
# Rebuilding dns zone
|
||||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
|
cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
|
||||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
|
||||||
log_event "$E_CONNECT $EVENT"
|
|
||||||
exit $E_CONNECT
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Update pipe
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Updating pipe
|
||||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||||
if [ ! -z "$str" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
sed -i "$str d" $pipe
|
sed -i "$str d" $pipe
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Vesta #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -25,12 +25,6 @@ source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
check_args '2' "$#" 'KEY VALUE'
|
check_args '2' "$#" 'KEY VALUE'
|
||||||
validate_format 'key'
|
validate_format 'key'
|
||||||
check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf)
|
|
||||||
if [ -z "$check_ckey" ]; then
|
|
||||||
echo "Error: key $key not found"
|
|
||||||
log_event "$E_INVALID" "$EVENT"
|
|
||||||
exit $E_INVALID
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -38,7 +32,17 @@ fi
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Updating conf
|
# Updating conf
|
||||||
sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf
|
check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf)
|
||||||
|
if [ -z "$check_ckey" ]; then
|
||||||
|
echo "$key='$value'" >> $VESTA/conf/vesta.conf
|
||||||
|
else
|
||||||
|
sed -i "s|$key=.*|$key='$value'|g" $VESTA/conf/vesta.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$key" = "BACKUP" ] && [ "$value" != '/backup' ]; then
|
||||||
|
rm /backup
|
||||||
|
ln -s $value /backup
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -77,9 +77,7 @@ fi
|
||||||
# Restart ftp server
|
# Restart ftp server
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-ftp
|
$BIN/v-restart-ftp
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "FTP restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
72
bin/v-change-sys-timezone
Executable file
72
bin/v-change-sys-timezone
Executable file
|
@ -0,0 +1,72 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: change system timezone
|
||||||
|
# options: TIMEZONE
|
||||||
|
#
|
||||||
|
# The function for changing system timezone.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
timezone=$1
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
is_timezone_valid() {
|
||||||
|
if [ ! -e "/usr/share/zoneinfo/$timezone" ]; then
|
||||||
|
echo "Error: tz file $timezone doesn't exist"
|
||||||
|
log_event $E_NOTEXIST "$EVENT"
|
||||||
|
exit $E_NOTEXIST
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'TIMEZONE'
|
||||||
|
is_timezone_valid
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Changing system timezone
|
||||||
|
which timedatectls >/dev/null 2>&1
|
||||||
|
if [ "$?" -eq 0 ]; then
|
||||||
|
timedatectl set-timezone $timezone
|
||||||
|
else
|
||||||
|
if [ -e "/etc/sysconfig/clock" ]; then
|
||||||
|
sed -i "s/ZONE.*//" /etc/sysconfig/clock
|
||||||
|
echo "ZONE=\"$timezone\"" >> /etc/sysconfig/clock
|
||||||
|
fi
|
||||||
|
if [ -e "/etc/timezone" ]; then
|
||||||
|
echo "$timezone" > /etc/timezone
|
||||||
|
fi
|
||||||
|
rm -f /etc/localtime
|
||||||
|
ln -sf /usr/share/zoneinfo/$timezone /etc/localtime
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Chaning php timezone
|
||||||
|
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||||
|
for conf in $(find /etc/php* -name php.ini); do
|
||||||
|
sed -i "s|;date.timezone =|date.timezone =|" $conf
|
||||||
|
sed -i "s|date.timezone =.*|date.timezone = $timezone|" $conf
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: change user nameservers
|
# 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 speciefic user.
|
||||||
|
|
||||||
|
@ -13,8 +13,12 @@
|
||||||
user=$1
|
user=$1
|
||||||
ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||||
ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||||
ns3=$4
|
ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||||
ns4=$5
|
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
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -26,7 +30,7 @@ source $VESTA/conf/vesta.conf
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# 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
|
# Checking argument format
|
||||||
validate_format 'user' 'ns1' 'ns2'
|
validate_format 'user' 'ns1' 'ns2'
|
||||||
|
@ -38,7 +42,22 @@ if [ ! -z "$ns4" ]; then
|
||||||
ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
|
||||||
validate_format 'ns4'
|
validate_format 'ns4'
|
||||||
fi
|
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_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
@ -48,7 +67,7 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Merging values
|
# 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/,$//")
|
ns=$(echo "$ns" | sed -e "s/,,//g" -e "s/,$//")
|
||||||
|
|
||||||
# Changing ns values
|
# Changing ns values
|
||||||
|
@ -60,7 +79,7 @@ update_user_value "$user" '$NS' "$ns"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Logging
|
# 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"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -19,7 +19,7 @@ source $VESTA/func/main.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
is_package_avalable() {
|
is_package_avalable() {
|
||||||
# Parsing user data
|
|
||||||
usr_data=$(cat $USER_DATA/user.conf)
|
usr_data=$(cat $USER_DATA/user.conf)
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for key in $usr_data; do
|
for key in $usr_data; do
|
||||||
|
@ -37,18 +37,56 @@ is_package_avalable() {
|
||||||
grep -v DATE)
|
grep -v DATE)
|
||||||
eval $pkg_data
|
eval $pkg_data
|
||||||
|
|
||||||
# Comparing user data with package
|
# Checking usage agains package limits
|
||||||
if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\
|
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
|
||||||
[[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\
|
if [ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]; then
|
||||||
[[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\
|
echo "Error: Package doesn't cover WEB_DOMAIN usage"
|
||||||
[[ "$DATABASES" -lt "$U_DATABASES" ]] ||\
|
|
||||||
[[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\
|
|
||||||
[[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\
|
|
||||||
[[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then
|
|
||||||
echo "Error: Package not cover current usage"
|
|
||||||
log_event "$E_LIMIT" "$EVENT"
|
log_event "$E_LIMIT" "$EVENT"
|
||||||
exit $E_LIMIT
|
exit $E_LIMIT
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$DNS_DOMAINS" ! = 'unlimited' ]; then
|
||||||
|
if [ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]; then
|
||||||
|
echo "Error: Package doesn't cover DNS_DOMAIN usage"
|
||||||
|
log_event "$E_LIMIT" "$EVENT"
|
||||||
|
exit $E_LIMIT
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$MAIL_DOMAINS" != 'unlimited' ]; then
|
||||||
|
if [ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]; then
|
||||||
|
echo "Error: Package doesn't cover MAIL_DOMAIN usage"
|
||||||
|
log_event "$E_LIMIT" "$EVENT"
|
||||||
|
exit $E_LIMIT
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$DATABASES" != 'unlimited' ]; then
|
||||||
|
if [ "$DATABASES" -lt "$U_DATABASES" ]; then
|
||||||
|
echo "Error: Package doesn't cover DATABASE usage"
|
||||||
|
log_event "$E_LIMIT" "$EVENT"
|
||||||
|
exit $E_LIMIT
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$CRON_JOBS" != 'unlimited' ]; then
|
||||||
|
if [ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]; then
|
||||||
|
echo "Error: Package doesn't cover CRON usage"
|
||||||
|
log_event "$E_LIMIT" "$EVENT"
|
||||||
|
exit $E_LIMIT
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$DISK_QUOTA" != 'unlimited' ]; then
|
||||||
|
if [ "$DISK_QUOTA" -lt "$U_DISK" ]; then
|
||||||
|
echo "Error: Package doesn't cover DISK usage"
|
||||||
|
log_event "$E_LIMIT" "$EVENT"
|
||||||
|
exit $E_LIMIT
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$BANDWIDTH" != 'unlimited' ]; then
|
||||||
|
if [ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]; then
|
||||||
|
echo "Error: Package doesn't cover BANDWIDTH usage"
|
||||||
|
log_event "$E_LIMIT" "$EVENT"
|
||||||
|
exit $E_LIMIT
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
change_user_package() {
|
change_user_package() {
|
||||||
|
@ -110,6 +148,7 @@ U_DATABASES='$U_DATABASES'
|
||||||
U_CRON_JOBS='$U_CRON_JOBS'
|
U_CRON_JOBS='$U_CRON_JOBS'
|
||||||
U_BACKUPS='$U_BACKUPS'
|
U_BACKUPS='$U_BACKUPS'
|
||||||
LANGUAGE='$LANGUAGE'
|
LANGUAGE='$LANGUAGE'
|
||||||
|
NOTIFICATIONS='$NOTIFICATIONS'
|
||||||
TIME='$TIME'
|
TIME='$TIME'
|
||||||
DATE='$DATE'" > $USER_DATA/user.conf
|
DATE='$DATE'" > $USER_DATA/user.conf
|
||||||
}
|
}
|
||||||
|
@ -145,6 +184,12 @@ if [ -x "$VESTA/data/packages/$package.sh" ]; then
|
||||||
$VESTA/data/packages/$package.sh "$user" "$CONTACT" "$FNAME" "$LNAME"
|
$VESTA/data/packages/$package.sh "$user" "$CONTACT" "$FNAME" "$LNAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Update disk quota
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
if [ "$DISK_QUOTA" = 'yes' ]; then
|
||||||
|
$BIN/v-update-user-quota $user
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
|
|
|
@ -11,25 +11,22 @@
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
password=$2
|
password=$2; HIDE=2
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
A2="******"
|
|
||||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '2' "$#" 'USER PASSWORD'
|
check_args '2' "$#" 'USER PASSWORD'
|
||||||
validate_format 'user' 'password'
|
validate_format 'user'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_password_valid
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -36,9 +36,18 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
shell_path=$(grep -w "$shell" /etc/shells | head -n1)
|
shell_path=$(grep -w "$shell" /etc/shells | head -n1)
|
||||||
|
|
||||||
# Changing passwd file
|
# 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)
|
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 #
|
# Vesta #
|
||||||
|
|
|
@ -37,7 +37,7 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
case $type in
|
case $type in
|
||||||
WEB) is_web_template_valid;
|
WEB) is_web_template_valid;
|
||||||
update_user_value "$user" '$WEB_TEMPLATE' "$template";;
|
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";;
|
update_user_value "$user" '$PROXY_TEMPLATE' "$template";;
|
||||||
DNS) is_dns_template_valid;
|
DNS) is_dns_template_valid;
|
||||||
update_user_value "$user" '$DNS_TEMPLATE' "$template";;
|
update_user_value "$user" '$DNS_TEMPLATE' "$template";;
|
||||||
|
|
171
bin/v-change-web-domain-backend-tpl
Executable file
171
bin/v-change-web-domain-backend-tpl
Executable file
|
@ -0,0 +1,171 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: change web domain backend template
|
||||||
|
# options: USER DOMAIN TEMPLATE [RESTART]
|
||||||
|
#
|
||||||
|
# The function changes backend template
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
user=$1
|
||||||
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
template=$3
|
||||||
|
restart="$4"
|
||||||
|
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/func/domain.sh
|
||||||
|
source $VESTA/func/ip.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]'
|
||||||
|
validate_format 'user' 'domain' 'template'
|
||||||
|
is_system_enabled "$WEB_BACKEND" 'WEB_BACKEND'
|
||||||
|
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_web_backend_template_valid $template
|
||||||
|
is_web_backend_pool_valid
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Deleting backend
|
||||||
|
rm -f $pool/$backend.conf
|
||||||
|
|
||||||
|
# Allocating backend port
|
||||||
|
backend_port=9000
|
||||||
|
ports=$(grep -v '^;' $pool/* 2>/dev/null |grep listen |grep -o :[0-9].*)
|
||||||
|
ports=$(echo "$ports" |sed "s/://" |sort -n)
|
||||||
|
for port in $ports; do
|
||||||
|
if [ "$backend_port" -eq "$port" ]; then
|
||||||
|
backend_port=$((backend_port + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Changing backend config
|
||||||
|
cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
|
||||||
|
sed -e "s|%backend_port%|$backend_port|" \
|
||||||
|
-e "s|%user%|$user|"\
|
||||||
|
-e "s|%domain%|$domain|"\
|
||||||
|
-e "s|%domain_idn%|$domain_idn|"\
|
||||||
|
-e "s|%backend%|$backend|g" > $pool/$backend.conf
|
||||||
|
|
||||||
|
# Checking backend pool configuration
|
||||||
|
if [ "$backend" = "$user" ]; then
|
||||||
|
conf=$USER_DATA/web.conf
|
||||||
|
fields='$DOMAIN'
|
||||||
|
nohead=1
|
||||||
|
|
||||||
|
for domain in $(shell_list); do
|
||||||
|
|
||||||
|
# Parsing domain values
|
||||||
|
get_domain_values 'web'
|
||||||
|
ip=$(get_real_ip $IP)
|
||||||
|
|
||||||
|
# Deleting old vhost
|
||||||
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
|
del_web_config
|
||||||
|
|
||||||
|
# Deleting old ssl vhost
|
||||||
|
if [ "$SSL" = 'yes' ]; then
|
||||||
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
|
del_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Adding new vhost
|
||||||
|
upd_web_domain_values
|
||||||
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
|
add_web_config
|
||||||
|
|
||||||
|
# Adding new ssl vhost
|
||||||
|
if [ "$SSL" = 'yes' ]; then
|
||||||
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
|
add_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update config
|
||||||
|
add_object_key "web" 'DOMAIN' "$domain" 'BACKEND' 'PROXY'
|
||||||
|
update_object_value 'web' 'DOMAIN' "$domain" '$BACKEND' "$template"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Chaning template in user config
|
||||||
|
old_template=$(grep BACKEND_TEMPLATE $USER_DATA/user.conf)
|
||||||
|
if [ -z "$old_template" ]; then
|
||||||
|
sed -i "s/^WEB_DOMAINS/BACKEND_TEMPLATE='$template'\nWEB_DOMAINS/g" \
|
||||||
|
$USER_DATA/user.conf
|
||||||
|
else
|
||||||
|
update_user_value "$user" '$BACKEND_TEMPLATE' "$template"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Parsing domain values
|
||||||
|
get_domain_values 'web'
|
||||||
|
ip=$(get_real_ip $IP)
|
||||||
|
|
||||||
|
# Deleting old vhost
|
||||||
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
|
del_web_config
|
||||||
|
|
||||||
|
# Deleting old ssl vhost
|
||||||
|
if [ "$SSL" = 'yes' ]; then
|
||||||
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
|
del_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Adding new vhost
|
||||||
|
upd_web_domain_values
|
||||||
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
|
add_web_config
|
||||||
|
|
||||||
|
# Adding new ssl vhost
|
||||||
|
if [ "$SSL" = 'yes' ]; then
|
||||||
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
|
add_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update config
|
||||||
|
add_object_key "web" 'DOMAIN' "$domain" 'BACKEND' 'PROXY'
|
||||||
|
update_object_value 'web' 'DOMAIN' "$domain" '$BACKEND' "$template"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
|
||||||
|
# Restarting web
|
||||||
|
if [ "$restart" != 'no' ]; then
|
||||||
|
$BIN/v-restart-web
|
||||||
|
check_result $? "Web restart failed" >/dev/null
|
||||||
|
|
||||||
|
$BIN/v-restart-web-backend
|
||||||
|
check_result $? "Web backend restart failed" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_history "changed backend template for $domain to $template"
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
|
@ -14,7 +14,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ftp_user=$3
|
ftp_user=$3
|
||||||
ftp_password=$4
|
password=$4; HIDE=4
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -27,12 +27,13 @@ source $VESTA/conf/vesta.conf
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD'
|
check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD'
|
||||||
validate_format 'user' 'domain' 'ftp_user' 'ftp_password'
|
validate_format 'user' 'domain' 'ftp_user'
|
||||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
|
is_password_valid
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
if [ -z "$(echo $FTP_USER | tr ':' '\n' | grep ^$ftp_user$)" ]; then
|
if [ -z "$(echo $FTP_USER | tr ':' '\n' | grep ^$ftp_user$)" ]; then
|
||||||
echo "Error: account $ftp_user doesn't exist"
|
echo "Error: account $ftp_user doesn't exist"
|
||||||
|
@ -46,7 +47,7 @@ fi
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Changing ftp user password
|
# Changing ftp user password
|
||||||
echo "$ftp_user:$ftp_password" | /usr/sbin/chpasswd
|
echo "$ftp_user:$password" | /usr/sbin/chpasswd
|
||||||
ftp_md5=$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)
|
ftp_md5=$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)
|
||||||
|
|
||||||
|
|
||||||
|
|
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 chaning http auth user password
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
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
|
||||||
|
|
||||||
|
# Definining 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
|
|
@ -45,7 +45,7 @@ is_ip_avalable
|
||||||
# Define variable for replace
|
# Define variable for replace
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
ip=$(get_real_ip $ip)
|
ip=$(get_real_ip $ip)
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.tpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
old=$(get_real_ip $IP)
|
old=$(get_real_ip $IP)
|
||||||
new=$ip
|
new=$ip
|
||||||
|
@ -53,17 +53,16 @@ replace_web_config
|
||||||
|
|
||||||
# Checking SSL
|
# Checking SSL
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
replace_web_config
|
replace_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking proxy
|
# Checking proxy
|
||||||
if [ ! -z "$PROXY" ]; then
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||||
replace_web_config
|
replace_web_config
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking SSL proxy
|
# Checking SSL proxy
|
||||||
if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then
|
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"
|
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||||
replace_web_config
|
replace_web_config
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -87,13 +87,11 @@ update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$3"
|
||||||
# Restart web server
|
# Restart web server
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "WEB restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
|
||||||
is_proxy_template_valid
|
is_proxy_template_valid $template
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -87,16 +87,14 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Update config
|
# Updating config
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
|
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
|
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
|
||||||
|
|
||||||
# Restart web
|
# Restarting proxy
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: change domain ssl certificate
|
# 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
|
# The function changes SSL domain certificate and the key. If ca file present
|
||||||
# it will be replaced as well.
|
# it will be replaced as well.
|
||||||
|
@ -15,6 +15,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ssl_dir=$3
|
ssl_dir=$3
|
||||||
|
restart=$4
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -26,7 +27,7 @@ source $VESTA/conf/vesta.conf
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '3' "$#" 'USER DOMAIN SSL_DIR'
|
check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]'
|
||||||
validate_format 'user' 'domain' 'ssl_dir'
|
validate_format 'user' 'domain' 'ssl_dir'
|
||||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
@ -69,15 +70,15 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart web server
|
# Restarting web server
|
||||||
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -10,6 +10,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ssl_home=$3
|
ssl_home=$3
|
||||||
|
restart=$4
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -21,7 +22,7 @@ source $VESTA/conf/vesta.conf
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '3' "$#" 'USER DOMAIN SSL_HOME'
|
check_args '3' "$#" 'USER DOMAIN SSL_HOME [RESTART]'
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
@ -39,7 +40,7 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
old_ssl_home=$SSL_HOME
|
old_ssl_home=$SSL_HOME
|
||||||
SSL_HOME=$ssl_home
|
SSL_HOME=$ssl_home
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
|
|
||||||
# Parsing tpl_option
|
# Parsing tpl_option
|
||||||
|
@ -55,7 +56,7 @@ esac
|
||||||
replace_web_config
|
replace_web_config
|
||||||
|
|
||||||
# Checking proxy config
|
# Checking proxy config
|
||||||
if [ ! -z "$PROXY" ]; then
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||||
replace_web_config
|
replace_web_config
|
||||||
|
@ -69,15 +70,15 @@ fi
|
||||||
# Update config
|
# Update config
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
|
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
|
||||||
|
|
||||||
# Restart web server
|
# Restarting web server
|
||||||
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -47,40 +47,40 @@ get_domain_values 'web'
|
||||||
ip=$(get_real_ip $IP)
|
ip=$(get_real_ip $IP)
|
||||||
|
|
||||||
# Deleting domain
|
# Deleting domain
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.tpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
old_tpl=$TPL
|
old_tpl=$TPL
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
|
|
||||||
# Deleting ssl vhost
|
# Deleting ssl vhost
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defining variables for new vhost config
|
# Defining variables for new vhost config
|
||||||
upd_web_domain_values
|
upd_web_domain_values
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$template.tpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
||||||
|
|
||||||
# Adding domain to the web conf
|
# Adding domain to the web conf
|
||||||
add_web_config
|
add_web_config
|
||||||
|
|
||||||
# Running template trigger
|
# Running template trigger
|
||||||
if [ -x $WEBTPL/$WEB_SYSTEM/$template.sh ]; then
|
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||||
$WEBTPL/$WEB_SYSTEM/$template.sh $user $domain $ip $HOMEDIR $docroot
|
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh \
|
||||||
|
$user $domain $ip $HOMEDIR $docroot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking SSL
|
# Checking SSL
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$template.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.stpl"
|
||||||
del_web_config
|
|
||||||
add_web_config
|
add_web_config
|
||||||
|
|
||||||
# Running template trigger
|
# Running template trigger
|
||||||
if [ -x $WEBTPL/$WEB_SYSTEM/$template.sh ]; then
|
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||||
$WEBTPL/$WEB_SYSTEM/$template.sh \
|
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh \
|
||||||
"$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot"
|
"$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -93,12 +93,10 @@ fi
|
||||||
# Changing tpl in config
|
# Changing tpl in config
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
|
update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
|
||||||
|
|
||||||
# Restart web
|
# Restarting web
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
54
bin/v-check-fs-permission
Executable file
54
bin/v-check-fs-permission
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: open file
|
||||||
|
# options: USER FILE
|
||||||
|
#
|
||||||
|
# The function opens/reads files on the file system
|
||||||
|
|
||||||
|
user=$1
|
||||||
|
src_file=$2
|
||||||
|
|
||||||
|
# Checking arguments
|
||||||
|
if [ -z "$src_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 path
|
||||||
|
if [ ! -z "$src_file" ]; then
|
||||||
|
rpath=$(readlink -f "$src_file")
|
||||||
|
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||||
|
echo "Error: invalid source path $src_file"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Reading file
|
||||||
|
#sudo -u $user cat "$src_file" 2>/dev/null
|
||||||
|
#if [ $? -ne 0 ]; then
|
||||||
|
# echo "Error: file $src_file was not opened"
|
||||||
|
# exit 3
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# Checking if file has readable permission
|
||||||
|
if [[ ! -r $src_file ]]
|
||||||
|
then
|
||||||
|
# echo "File is readable"
|
||||||
|
#else
|
||||||
|
echo "Cannot read file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Exiting
|
||||||
|
exit
|
91
bin/v-check-user-password
Executable file
91
bin/v-check-user-password
Executable file
|
@ -0,0 +1,91 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: check user password
|
||||||
|
# options: USER PASSWORD [IP]
|
||||||
|
#
|
||||||
|
# The function verifies user password from file
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
user=$1
|
||||||
|
password=$2; HIDE=2
|
||||||
|
ip=${3-127.0.0.1}
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '2' "$#" 'USER PASSWORD'
|
||||||
|
validate_format 'user'
|
||||||
|
|
||||||
|
# Checking user
|
||||||
|
if [ ! -d "$VESTA/data/users/$user" ] && [ "$user" != 'root' ]; then
|
||||||
|
echo "Error: password missmatch"
|
||||||
|
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checking user password
|
||||||
|
is_password_valid
|
||||||
|
|
||||||
|
# Checking empty password
|
||||||
|
if [[ -z "$password" ]]; then
|
||||||
|
echo "Error: password missmatch"
|
||||||
|
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Parsing user's salt
|
||||||
|
shadow=$(grep "^$user:" /etc/shadow)
|
||||||
|
salt=$(echo "$shadow" |cut -f 3 -d \$)
|
||||||
|
method=$(echo "$shadow" |cut -f 2 -d \$)
|
||||||
|
if [ "$method" -eq '1' ]; then
|
||||||
|
method='md5'
|
||||||
|
else
|
||||||
|
method='sha-512'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$salt" ]; then
|
||||||
|
echo "Error: password missmatch"
|
||||||
|
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generating SHA-512
|
||||||
|
hash=$($BIN/v-generate-password-hash $method $salt <<< $password)
|
||||||
|
if [[ -z "$hash" ]]; then
|
||||||
|
echo "Error: password missmatch"
|
||||||
|
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checking hash
|
||||||
|
result=$(grep "^$user:$hash:" /etc/shadow 2>/dev/null)
|
||||||
|
if [[ -z "$result" ]]; then
|
||||||
|
echo "Error: password missmatch"
|
||||||
|
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
echo "$DATE $TIME $user $ip successfully logged in" >> $VESTA/log/auth.log
|
||||||
|
|
||||||
|
exit
|
58
bin/v-copy-fs-directory
Executable file
58
bin/v-copy-fs-directory
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: copy directory
|
||||||
|
# options: USER SRC_DIRECTORY DST_DIRECTORY
|
||||||
|
#
|
||||||
|
# The function copies directory on the file system
|
||||||
|
|
||||||
|
user=$1
|
||||||
|
src_dir=$2
|
||||||
|
dst_dir=$3
|
||||||
|
|
||||||
|
# Checking arguments
|
||||||
|
if [ -z "$dst_dir" ]; then
|
||||||
|
echo "Usage: USER SRC_DIRECTORY DST_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 source dir
|
||||||
|
if [ ! -e "$src_dir" ]; then
|
||||||
|
echo "Error: source directory $src_dir doesn't exist"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checking source path
|
||||||
|
rpath=$(readlink -f "$src_dir")
|
||||||
|
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||||
|
echo "Error: invalid source path $src_dir"
|
||||||
|
exit 2
|
||||||
|
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
|
||||||
|
|
||||||
|
# Copying directory
|
||||||
|
sudo -u $user cp -r "$src_dir" "$dst_dir" >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: directory $src_dir was not copied"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Exiting
|
||||||
|
exit
|
|
@ -1,58 +1,58 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# File copier
|
# info: copy file
|
||||||
|
# options: USER SRC_FILE DST_FLE
|
||||||
|
#
|
||||||
|
# The function copies file on the file system
|
||||||
|
|
||||||
user=$1
|
user=$1
|
||||||
file_src=$2
|
src_file=$2
|
||||||
file_dst=$3
|
dst_file=$3
|
||||||
|
|
||||||
# Checking arguments
|
# Checking arguments
|
||||||
if [ -z "$file_dst" ]; then
|
if [ -z "$dst_file" ]; then
|
||||||
echo "Usage: USER SRC_FILE DST_FILE"
|
echo "Usage: USER SRC_FILE DST_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking users
|
# Checking vesta user
|
||||||
if [ ! -e "$VESTA/data/users/$user" ]; then
|
if [ ! -e "$VESTA/data/users/$user" ]; then
|
||||||
exit 1
|
echo "Error: vesta user $user doesn't exist"
|
||||||
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking homedir
|
# Checking user homedir
|
||||||
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
||||||
if [ -z $homedir ]; then
|
if [ -z $homedir ]; then
|
||||||
exit 1
|
echo "Error: user home directory doesn't exist"
|
||||||
|
exit 12
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking source file
|
# Checking source file
|
||||||
if [ ! -e "$file_src" ]; then
|
if [ ! -f "$src_file" ]; then
|
||||||
exit 1
|
echo "Error: $src_file doesn't exist"
|
||||||
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking source path
|
# Checking source path
|
||||||
rpath=$(readlink -f "$file_src")
|
rpath=$(readlink -f "$src_file")
|
||||||
if [ -z "$(echo $rpath |grep ^/tmp)" ]; then
|
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||||
exit 1
|
echo "Error: invalid source path $src_file"
|
||||||
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking destination path
|
# Checking destination path
|
||||||
rpath=$(readlink -f "$file_dst")
|
rpath=$(readlink -f "$dst_file")
|
||||||
if [ -z "$(echo $rpath |grep ^$homedir)" ]; then
|
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||||
exit 1
|
echo "Error: ivalid destination path $dst_file"
|
||||||
fi
|
exit 2
|
||||||
|
|
||||||
# Checking dst file permission
|
|
||||||
if [ -e "$file_dst" ]; then
|
|
||||||
perms=$(stat --format '%a' $file_dst)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copying file
|
# Copying file
|
||||||
cp $file_src $file_dst
|
sudo -u $user cp "$src_file" "$dst_file" >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
# Changing ownership
|
echo "Error: file $src_file was not copied"
|
||||||
chown $user:$user $file_dst
|
exit 3
|
||||||
|
|
||||||
# Changin permissions
|
|
||||||
if [ ! -z "$perms" ]; then
|
|
||||||
chmod $perms $file_dst
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Exiting
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: delete backup ftp server
|
# info: delete backup ftp server
|
||||||
# options: NONE
|
# options: TYPE
|
||||||
#
|
#
|
||||||
# The function deletes ftp backup host
|
# The function deletes ftp backup host
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@
|
||||||
# Variable&Function #
|
# Variable&Function #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
type=$1
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
@ -18,23 +21,31 @@ source $VESTA/conf/vesta.conf
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'TYPE [HOST]'
|
||||||
|
types=$(echo "$BACKUP_SYSTEM" |sed "s/,/\n/g" |grep "^$type$")
|
||||||
|
if [ -z "$types" ]; then
|
||||||
|
echo "Error: invalid backup type"
|
||||||
|
log_event "$E_INVALID" "$EVENT"
|
||||||
|
exit $E_INVALID
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking network connection
|
# Deleting host config
|
||||||
rm -f $VESTA/conf/ftp.backup.conf
|
rm -f $VESTA/conf/$type.backup.conf
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Update vesta.conf
|
# Updating vesta.conf
|
||||||
bckp=$(echo "$BACKUP_SYSTEM" |\
|
bckp=$(echo "$BACKUP_SYSTEM" |\
|
||||||
sed "s/,/\n/g"|\
|
sed "s/,/\n/g"|\
|
||||||
sed "s/ftp//" |\
|
sed "s/^$type$//" |\
|
||||||
sed "/^$/d"|\
|
sed "/^$/d"|\
|
||||||
sed ':a;N;$!ba;s/\n/,/g')
|
sed ':a;N;$!ba;s/\n/,/g')
|
||||||
sed -i "s/BACKUP_SYSTEM=.*/BACKUP_SYSTEM='$bckp'/g" $VESTA/conf/vesta.conf
|
sed -i "s/BACKUP_SYSTEM=.*/BACKUP_SYSTEM='$bckp'/g" $VESTA/conf/vesta.conf
|
|
@ -52,11 +52,9 @@ sync_cron_jobs
|
||||||
# Decreasing cron value
|
# Decreasing cron value
|
||||||
decrease_user_value "$user" '$U_CRON_JOBS'
|
decrease_user_value "$user" '$U_CRON_JOBS'
|
||||||
|
|
||||||
# Restart crond
|
# Restarting crond
|
||||||
$BIN/v-restart-cron
|
$BIN/v-restart-cron
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Restart restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "deleted cron job $job"
|
log_history "deleted cron job $job"
|
||||||
|
|
|
@ -44,11 +44,9 @@ sync_cron_jobs
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart crond
|
# Restarting crond
|
||||||
$BIN/v-restart-cron
|
$BIN/v-restart-cron
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Cron restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "disabled cron reporting"
|
log_history "disabled cron reporting"
|
||||||
|
|
|
@ -51,11 +51,9 @@ sync_cron_jobs
|
||||||
# Decreasing cron value
|
# Decreasing cron value
|
||||||
decrease_user_value "$user" '$U_CRON_JOBS'
|
decrease_user_value "$user" '$U_CRON_JOBS'
|
||||||
|
|
||||||
# Restart crond
|
# Restarting crond
|
||||||
$BIN/v-restart-cron
|
$BIN/v-restart-cron
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Cron restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -71,12 +71,10 @@ rm -f $USER_DATA/dns/$domain.conf
|
||||||
decrease_user_value "$user" '$U_DNS_DOMAINS'
|
decrease_user_value "$user" '$U_DNS_DOMAINS'
|
||||||
decrease_user_value "$user" '$U_DNS_RECORDS' "$records"
|
decrease_user_value "$user" '$U_DNS_RECORDS' "$records"
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns $restart
|
$BIN/v-restart-dns $restart
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Bind restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
restart=$2
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -41,10 +42,10 @@ done
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Bind restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -46,9 +46,7 @@ done
|
||||||
# Restart named
|
# Restart named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Bind restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -45,6 +45,7 @@ sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
|
||||||
|
|
||||||
# Updating zone
|
# Updating zone
|
||||||
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
||||||
|
update_domain_serial
|
||||||
update_domain_zone
|
update_domain_zone
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -68,12 +69,10 @@ records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
|
||||||
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
|
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
|
||||||
decrease_user_value "$user" '$U_DNS_RECORDS'
|
decrease_user_value "$user" '$U_DNS_RECORDS'
|
||||||
|
|
||||||
# Restart named
|
# Restarting named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Bind restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -16,7 +16,6 @@ restart="${3-yes}"
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/func/ip.sh
|
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,51 +33,53 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Web domain
|
# Working on Web domain
|
||||||
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
|
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||||
check_web=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='no")
|
||||||
if [ ! -z "$check_web" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
|
domain_found='yes'
|
||||||
$BIN/v-delete-web-domain $user $domain 'no'
|
$BIN/v-delete-web-domain $user $domain 'no'
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "can't suspend web" > /dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# DNS domain
|
# Working on DNS domain
|
||||||
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
|
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||||
check_dns=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='no")
|
||||||
if [ ! -z "$check_dns" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
|
domain_found='yes'
|
||||||
$BIN/v-delete-dns-domain $user $domain 'no'
|
$BIN/v-delete-dns-domain $user $domain 'no'
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "can't suspend dns" > /dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Mail domain
|
# Working on Mail domain
|
||||||
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
|
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||||
check_mail=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf)
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='no")
|
||||||
if [ ! -z "$check_mail" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
|
domain_found='yes'
|
||||||
$BIN/v-delete-mail-domain $user $domain
|
$BIN/v-delete-mail-domain $user $domain
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "can't suspend mail" > /dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check domain status
|
# Checking domain search result
|
||||||
if [ -z "$check_web" ] && [ -z "$check_dns" ] && [ -z "$check_mail" ]; then
|
if [ -z "$domain_found" ]; then
|
||||||
echo "Error: domain $domain doesn't exist"
|
echo "Error: domain $domain doesn't exist"
|
||||||
log_event "$E_NOTEXIST" "$EVENT"
|
log_event "$E_NOTEXIST" "$EVENT"
|
||||||
exit $E_NOTEXIST
|
exit $E_NOTEXIST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart services
|
# Restarting services
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
|
check_result $? "can't restart web" > /dev/null
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
|
check_result $? "can't restart proxy" > /dev/null
|
||||||
|
fi
|
||||||
$BIN/v-restart-dns
|
$BIN/v-restart-dns
|
||||||
|
check_result $? "can't restart dns" > /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ fi
|
||||||
|
|
||||||
# Deleting ip from banlist
|
# Deleting ip from banlist
|
||||||
sed -i "/IP='$ip' CHAIN='$chain'/d" $conf
|
sed -i "/IP='$ip' CHAIN='$chain'/d" $conf
|
||||||
$iptables -D fail2ban-$chain -s $ip \
|
b=$($iptables -L fail2ban-$chain --line-number -n|grep $ip|awk '{print $1}')
|
||||||
-j REJECT --reject-with icmp-port-unreachable 2>/dev/null
|
$iptables -D fail2ban-$chain $b 2>/dev/null
|
||||||
|
|
||||||
# Changing permissions
|
# Changing permissions
|
||||||
chmod 660 $conf
|
chmod 660 $conf
|
||||||
|
|
45
bin/v-delete-fs-directory
Executable file
45
bin/v-delete-fs-directory
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete directory
|
||||||
|
# options: USER DIRECTORY
|
||||||
|
#
|
||||||
|
# The function deletes 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 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Deleting directory
|
||||||
|
sudo -u $user rm -rf "$dst_dir" # >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: directory $dst_dir was not deleted"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Exiting
|
||||||
|
exit
|
45
bin/v-delete-fs-file
Executable file
45
bin/v-delete-fs-file
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete file
|
||||||
|
# options: USER FILE
|
||||||
|
#
|
||||||
|
# The function deletes file on the 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_file"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Deleting file
|
||||||
|
sudo -u $user rm -f "$dst_file" >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: file $dst_file was not deleted"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Exiting
|
||||||
|
exit
|
|
@ -26,84 +26,45 @@ source $VESTA/conf/vesta.conf
|
||||||
check_args '2' "$#" 'USER DOMAIN'
|
check_args '2' "$#" 'USER DOMAIN'
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||||
|
|
||||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||||
echo "Error: dns-cluster.conf doesn't exist"
|
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||||
log_event "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
check_result $E_EXISTS "another sync process already running"
|
||||||
if [ "$number_of_proc" -gt 2 ]; then
|
|
||||||
echo "Error: another sync process already exists"
|
|
||||||
log_event "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
|
remote_dns_health_check
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
old_ifs="$IFS"
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
# Starting cluster loop
|
# Starting cluster loop
|
||||||
for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
IFS=$'\n'
|
||||||
|
for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
|
||||||
|
|
||||||
# Get host values
|
# Parsing remote host parameters
|
||||||
eval $cluster_str
|
eval $cluster
|
||||||
|
|
||||||
# Check connection type
|
# Syncing domain
|
||||||
if [ -z "TYPE" ]; then
|
cluster_cmd v-delete-dns-domain $DNS_USER $domain 'yes'
|
||||||
TYPE='api'
|
rc=$?
|
||||||
|
if [ "$rc" -ne 0 ] && [ $rc -ne 3 ]; then
|
||||||
|
check_result $rc "$HOST connection failed (sync)" $E_CONNECT
|
||||||
fi
|
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
|
|
||||||
$send_cmd v-delete-dns-domain $DNS_USER $domain 'scheduled'
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Update pipe
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Updating pipe
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -22,26 +22,19 @@ source $VESTA/conf/vesta.conf
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||||
|
|
||||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||||
echo "Error: dns-cluster.conf doesn't exist"
|
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||||
log_event "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
check_result $E_EXISTS "another sync process already running"
|
||||||
if [ "$number_of_proc" -gt 2 ]; then
|
|
||||||
echo "Error: another sync process already exists"
|
|
||||||
log_event "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
|
remote_dns_health_check
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
old_ifs="$IFS"
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
|
||||||
if [ -z $host ]; then
|
if [ -z $host ]; then
|
||||||
|
@ -51,65 +44,18 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Starting cluster loop
|
# Starting cluster loop
|
||||||
for cluster_str in $hosts; do
|
for cluster in $hosts; do
|
||||||
|
|
||||||
# Get host values
|
# Parsing remote host parameters
|
||||||
eval $cluster_str
|
eval $cluster
|
||||||
|
|
||||||
# Check connection type
|
# Deleting source records
|
||||||
if [ -z "TYPE" ]; then
|
cluster_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME 'no'
|
||||||
TYPE='api'
|
check_result $? "$HOST connection failed (cleanup)" $E_CONNECT
|
||||||
fi
|
|
||||||
|
|
||||||
# Print hostname
|
# Rebuilding dns zones
|
||||||
if [ ! -z "$verbose" ]; then
|
$send_cmd v-rebuild-dns-domains $DNS_USER 'yes'
|
||||||
echo "HOSTNAME: $HOSTNAME"
|
check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
|
||||||
echo "TYPE: $TYPE"
|
|
||||||
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
|
|
||||||
if [ ! -z "$verbose" ]; then
|
|
||||||
echo "DNS_USER: $DNS_USER"
|
|
||||||
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
|
|
||||||
|
|
||||||
# Clean source records
|
|
||||||
$send_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME 'no'
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error: $TYPE connection to $HOST failed (cleanup)"
|
|
||||||
log_event "$E_CONNECT $EVENT"
|
|
||||||
exit $E_CONNECT
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Rebuild dns zones
|
|
||||||
$send_cmd v-rebuild-dns-domains $DNS_USER 'scheduled'
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
|
||||||
log_event "$E_CONNECT $EVENT"
|
|
||||||
exit $E_CONNECT
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -118,4 +64,11 @@ done
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Updating pipe
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -32,25 +32,13 @@ is_object_valid "../../conf/dns-cluster" 'HOST' "$host"
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
eval $(grep $host $VESTA/conf/dns-cluster.conf)
|
# Deleting remote domains
|
||||||
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 [ $? -eq 0 ]; then
|
|
||||||
# Deleting domains
|
|
||||||
$BIN/v-delete-remote-dns-domains $host >>/dev/null 2>&1
|
$BIN/v-delete-remote-dns-domains $host >>/dev/null 2>&1
|
||||||
$send_cmd v-add-cron-restart-job
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Deleting server
|
# Deleting server
|
||||||
sed -i "/HOST='$host' /d" $VESTA/conf/dns-cluster.conf
|
sed -i "/HOST='$host' /d" $VESTA/conf/dns-cluster.conf
|
||||||
|
|
||||||
# Delete DNS_CLUSTER key
|
# Deleting DNS_CLUSTER key
|
||||||
check_cluster=$(grep HOST $VESTA/conf/dns-cluster.conf |wc -l)
|
check_cluster=$(grep HOST $VESTA/conf/dns-cluster.conf |wc -l)
|
||||||
if [ "$check_cluster" -eq '0' ]; then
|
if [ "$check_cluster" -eq '0' ]; then
|
||||||
rm -f $VESTA/conf/dns-cluster.conf
|
rm -f $VESTA/conf/dns-cluster.conf
|
||||||
|
|
|
@ -27,79 +27,53 @@ source $VESTA/conf/vesta.conf
|
||||||
check_args '3' "$#" 'USER DOMAIN ID'
|
check_args '3' "$#" 'USER DOMAIN ID'
|
||||||
validate_format 'user' 'domain' 'id'
|
validate_format 'user' 'domain' 'id'
|
||||||
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
|
||||||
|
|
||||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||||
echo "Error: dns-cluster.conf doesn't exist"
|
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
|
||||||
log_event "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
|
||||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
check_result $E_EXISTS "another sync process already running"
|
||||||
if [ "$number_of_proc" -gt 2 ]; then
|
|
||||||
echo "Error: another sync process already exists"
|
|
||||||
log_event "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
|
remote_dns_health_check
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
old_ifs="$IFS"
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
# Starting cluster loop
|
# Starting cluster loop
|
||||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
IFS=$'\n'
|
||||||
|
for cluster in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||||
|
|
||||||
# Get host values
|
# Parsing remote host parameters
|
||||||
eval $cluster_str
|
eval $cluster
|
||||||
|
|
||||||
# Check connection type
|
# Syncing serial
|
||||||
if [ -z "TYPE" ]; then
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||||
TYPE='api'
|
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
|
||||||
fi
|
check_result $? "$HOST connection failed (soa sync)" $E_CONNECT
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# Sync domain
|
# Sync domain
|
||||||
$send_cmd v-delete-dns-record $DNS_USER $domain $id 'scheduled'
|
cluster_cmd v-delete-dns-record $DNS_USER $domain $id 'no'
|
||||||
|
check_result $? "$HOST connection failed (rebuild)" $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
|
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 #
|
# 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
|
exit
|
||||||
|
|
|
@ -121,15 +121,19 @@ else
|
||||||
decrease_user_value "$OWNER" '$IP_AVAIL'
|
decrease_user_value "$OWNER" '$IP_AVAIL'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restarting web server
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
|
# Restarting proxy server
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
|
$BIN/v-restart-proxy
|
||||||
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$BIN/v-restart-proxy
|
# Restarting firewall
|
||||||
if [ $? -ne 0 ]; then
|
if [ ! -z "$FIREWALL_SYSTEM" ]; then
|
||||||
exit $E_RESTART
|
$BIN/v-update-firewall
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
89
bin/v-delete-sys-sftp-jail
Executable file
89
bin/v-delete-sys-sftp-jail
Executable file
|
@ -0,0 +1,89 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete system sftp jail
|
||||||
|
# opions: NONE
|
||||||
|
#
|
||||||
|
# The script enables sftp jailed environment
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Importing system enviroment as we run this script
|
||||||
|
# mostly by cron wich 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 users
|
||||||
|
for user in $(grep "$HOMEDIR" /etc/passwd |cut -f 1 -d:); do
|
||||||
|
$BIN/v-delete-user-sftp-jail $user
|
||||||
|
done
|
||||||
|
|
||||||
|
# Checking sshd directives
|
||||||
|
config='/etc/ssh/sshd_config'
|
||||||
|
sftp_n=$(grep -n "Subsystem.*sftp" $config |grep -v internal |grep ":#")
|
||||||
|
sftp_i=$(grep -n "Subsystem.*sftp" $config |grep internal |grep -v ":#")
|
||||||
|
|
||||||
|
# Backing up config
|
||||||
|
cp $config $config.bak-$(date +%s)
|
||||||
|
|
||||||
|
# Enabling normal sftp
|
||||||
|
if [ ! -z "$sftp_n" ]; then
|
||||||
|
fline=$(echo $sftp_n |cut -f 1 -d :)
|
||||||
|
sed -i "${fline}s/#Subsystem/Subsystem sftp/" $config
|
||||||
|
restart='yes'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Disabling jailed sftp
|
||||||
|
if [ ! -z "$sftp_i" ]; then
|
||||||
|
fline=$(echo $sftp_i |cut -f 1 -d :)
|
||||||
|
lline=$((fline + 5))
|
||||||
|
sed -i "${fline},${lline}d" $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
|
||||||
|
|
||||||
|
# Deleting v-add-sys-sftp-jail from startup
|
||||||
|
sed -i "/v-add-sys-sftp-jail/d" /etc/rc.local 2>/dev/null
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
|
@ -91,11 +91,17 @@ sed -i "/ $user$/d" $VESTA/data/queue/traffic.pipe
|
||||||
|
|
||||||
# Deleting system user
|
# Deleting system user
|
||||||
/usr/sbin/userdel -f $user >> /dev/null 2>&1
|
/usr/sbin/userdel -f $user >> /dev/null 2>&1
|
||||||
|
|
||||||
if [ "$?" != 0 ]; then
|
if [ "$?" != 0 ]; then
|
||||||
sed -i "/^$user:/d" /etc/passwd
|
sed -i "/^$user:/d" /etc/passwd
|
||||||
sed -i "/^$user:/d" /etc/shadow
|
sed -i "/^$user:/d" /etc/shadow
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
/usr/sbin/groupdel $user >> /dev/null 2>&1
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
sed -i "/^$user:/d" /etc/group
|
||||||
|
fi
|
||||||
|
|
||||||
# Deleting user directories
|
# Deleting user directories
|
||||||
chattr -i $HOMEDIR/$user/conf
|
chattr -i $HOMEDIR/$user/conf
|
||||||
rm -rf $HOMEDIR/$user
|
rm -rf $HOMEDIR/$user
|
||||||
|
|
124
bin/v-delete-user-favourites
Executable file
124
bin/v-delete-user-favourites
Executable file
|
@ -0,0 +1,124 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: deleting user favourites
|
||||||
|
# options: USER SYSTEM OBJECT
|
||||||
|
#
|
||||||
|
# The function deletes object from users favourites
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
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'
|
||||||
|
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
|
||||||
|
|
||||||
|
# Deleting object from favorites
|
||||||
|
value=$(echo "$value" |\
|
||||||
|
sed -e "s/,/\n/g"|\
|
||||||
|
sed -e "s/^$object$//g"|\
|
||||||
|
sed -e "/^$/d"|\
|
||||||
|
sed -e ':a;N;$!ba;s/\n/,/g')
|
||||||
|
|
||||||
|
# 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 "deleted starred $object from $system listing"
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
66
bin/v-delete-user-notification
Executable file
66
bin/v-delete-user-notification
Executable file
|
@ -0,0 +1,66 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete user notification
|
||||||
|
# options: USER NOTIFICATION
|
||||||
|
#
|
||||||
|
# The function deletes user notification.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
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 #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Deleting notification
|
||||||
|
sed -i "/NID='$nid' /d" $USER_DATA/notifications.conf 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
|
63
bin/v-delete-user-sftp-jail
Executable file
63
bin/v-delete-user-sftp-jail
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete user sftp jail
|
||||||
|
# opions: USER
|
||||||
|
#
|
||||||
|
# The script enables sftp jailed environment
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
user=$1
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'USER'
|
||||||
|
validate_format 'user'
|
||||||
|
user_str=$(grep "^$user:" /etc/passwd)
|
||||||
|
if [ -z "$user_str" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Defining user homedir
|
||||||
|
home="$(echo $user_str |cut -f 6 -d :)"
|
||||||
|
|
||||||
|
# Unmounting home directory
|
||||||
|
mount_dir=$(mount |grep /chroot/$user/ |awk '{print $3}')
|
||||||
|
if [ ! -z "$mount_dir" ]; then
|
||||||
|
umount -f $mount_dir 2>/dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
gpasswd -d $user sftp-only >/dev/null 2>&1
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Deleting chroot dir
|
||||||
|
rmdir $mount_dir 2>/dev/null
|
||||||
|
rm -rf /chroot/$user
|
||||||
|
|
||||||
|
# Deleting user from sftp group
|
||||||
|
gpasswd -d $user sftp-only >/dev/null 2>&1
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
#log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
|
@ -44,7 +44,7 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
|
|
||||||
# Get template name
|
# Get template name
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.tpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
ip=$(get_real_ip $IP)
|
ip=$(get_real_ip $IP)
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ fi
|
||||||
|
|
||||||
# Checking SSL
|
# Checking SSL
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
|
|
||||||
|
@ -69,6 +69,11 @@ if [ "$SSL" = 'yes' ]; then
|
||||||
rm -f $USER_DATA/ssl/$domain.*
|
rm -f $USER_DATA/ssl/$domain.*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Checking backend
|
||||||
|
if [ ! -z "$WEB_BACKEND" ]; then
|
||||||
|
$BIN/v-delete-web-domain-backend $user $domain $restart
|
||||||
|
fi
|
||||||
|
|
||||||
# Checking proxy
|
# Checking proxy
|
||||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||||
|
@ -80,6 +85,12 @@ if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Deleting domain from proxy cache pool
|
||||||
|
pool="/etc/$PROXY_SYSTEM/conf.d/01_caching_pool.conf"
|
||||||
|
if [ -e "$pool" ]; then
|
||||||
|
sed -i "/=$domain:/d" $pool
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking stats
|
# Checking stats
|
||||||
|
@ -157,16 +168,14 @@ if [ "$SSL" = 'yes' ]; then
|
||||||
decrease_user_value "$user" '$U_WEB_SSL'
|
decrease_user_value "$user" '$U_WEB_SSL'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart web server
|
# Restarting web server
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ ALIAS=$(echo "$ALIAS" |\
|
||||||
sed -e "s/^$dom_alias$//g"|\
|
sed -e "s/^$dom_alias$//g"|\
|
||||||
sed -e "/^$/d"|\
|
sed -e "/^$/d"|\
|
||||||
sed -e ':a;N;$!ba;s/\n/,/g')
|
sed -e ':a;N;$!ba;s/\n/,/g')
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.tpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||||
|
|
||||||
# Preparing domain values for the template substitution
|
# Preparing domain values for the template substitution
|
||||||
|
@ -66,14 +66,14 @@ del_web_config
|
||||||
add_web_config
|
add_web_config
|
||||||
|
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$TPL.stpl"
|
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
add_web_config
|
add_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking proxy
|
# Checking proxy
|
||||||
if [ ! -z "$PROXY" ]; then
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
|
@ -98,16 +98,14 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
|
||||||
# Update counters
|
# Update counters
|
||||||
decrease_user_value "$user" '$U_WEB_ALIASES'
|
decrease_user_value "$user" '$U_WEB_ALIASES'
|
||||||
|
|
||||||
# Restart web server
|
# Restarting web server
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v-restart-web
|
$BIN/v-restart-web
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Web restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||||
$BIN/v-restart-proxy
|
$BIN/v-restart-proxy
|
||||||
if [ $? -ne 0 ]; then
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
65
bin/v-delete-web-domain-backend
Executable file
65
bin/v-delete-web-domain-backend
Executable file
|
@ -0,0 +1,65 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: deleting web domain backend configuration
|
||||||
|
# options: USER DOMAIN [RESTART]
|
||||||
|
#
|
||||||
|
# The function of deleting the virtualhost backend configuration.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
user=$1
|
||||||
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/func/domain.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '2' "$#" 'USER DOMAIN'
|
||||||
|
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_web_backend_pool_valid
|
||||||
|
|
||||||
|
# Checking last webdomain
|
||||||
|
domains=$(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'|wc -l)
|
||||||
|
if [ "$backend" = "$user" ] && [ "$domains" -gt 1 ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Deleting backend
|
||||||
|
rm -f $pool/$backend.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Restarting backend server
|
||||||
|
if [ "$restart" != 'no' ]; then
|
||||||
|
$BIN/v-restart-web-backend
|
||||||
|
check_result $? "Backend restart failed" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_history "deleting backend support for $domain"
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
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