mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-19 21:04:06 -07:00
OGLE-TR-123 Pre-Release
This commit is contained in:
commit
fd52d9819c
6 changed files with 78 additions and 12 deletions
|
@ -23,7 +23,7 @@ db_password=$4
|
||||||
type=$5
|
type=$5
|
||||||
host=$6
|
host=$6
|
||||||
encoding=${7-UTF8}
|
encoding=${7-UTF8}
|
||||||
|
encoding=$(echo "$encoding" |tr '[:lower:]' '[:upper:]')
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_CONF/vesta.conf
|
source $V_CONF/vesta.conf
|
||||||
|
@ -89,11 +89,12 @@ increase_user_value "$user" '$U_DATABASES'
|
||||||
|
|
||||||
# Adding db to db conf
|
# Adding db to db conf
|
||||||
v_str="DB='$database' USER='$db_user' HOST='$host' TYPE='$type'"
|
v_str="DB='$database' USER='$db_user' HOST='$host' TYPE='$type'"
|
||||||
v_str="$v_str U_DISK='0' SUSPEND='no' DATE='$V_DATE'"
|
v_str="$v_str CHARSET='$encoding' U_DISK='0' SUSPEND='no' DATE='$V_DATE'"
|
||||||
echo "$v_str">>$V_USERS/$user/db.conf
|
echo "$v_str">>$V_USERS/$user/db.conf
|
||||||
|
|
||||||
# Hiding password
|
# Hiding password
|
||||||
V_EVENT="$V_DATE $V_SCRIPT $user $database $db_user ***** $type $host"
|
V_EVENT="$V_DATE $V_SCRIPT $user $database $db_user ***** $type $host"
|
||||||
|
V_EVENT="$V_EVENT $encoding"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$V_EVENT" "v_delete_db_base $user $database"
|
log_history "$V_EVENT" "v_delete_db_base $user $database"
|
||||||
|
|
|
@ -19,7 +19,7 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ip=$3
|
ip=$3
|
||||||
template=${4-default}
|
template=${4-default}
|
||||||
next_year=$(date +F -d "+ 1 year")
|
next_year=$(date +%F -d "+ 1 year")
|
||||||
exp=${5-$next_year}
|
exp=${5-$next_year}
|
||||||
soa=$6
|
soa=$6
|
||||||
ttl=${7-14400}
|
ttl=${7-14400}
|
||||||
|
|
|
@ -40,9 +40,6 @@ is_user_suspended
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Changing user shell
|
|
||||||
update_user_value "$user" '$SHELL' "$shell"
|
|
||||||
|
|
||||||
# Get shell full path
|
# Get shell full path
|
||||||
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
|
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
|
||||||
|
|
||||||
|
@ -50,10 +47,14 @@ shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
|
||||||
/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1
|
/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Changing user shell
|
||||||
|
update_user_value "$user" '$SHELL' "$shell"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ is_db_valid
|
||||||
conf=$V_USERS/$user/db.conf
|
conf=$V_USERS/$user/db.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
|
fields='$DB $USER $HOST $TYPE $CHARSET $U_DISK $SUSPEND $DATE'
|
||||||
|
|
||||||
# Listing database
|
# Listing database
|
||||||
case $format in
|
case $format in
|
||||||
|
|
|
@ -40,13 +40,14 @@ is_user_valid
|
||||||
conf=$V_USERS/$user/db.conf
|
conf=$V_USERS/$user/db.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
|
fields='$DB $USER $HOST $TYPE $CHARSET $U_DISK $SUSPEND $DATE'
|
||||||
|
|
||||||
# Listing databases
|
# Listing databases
|
||||||
case $format in
|
case $format in
|
||||||
json) json_list ;;
|
json) json_list ;;
|
||||||
plain) nohead=1; shell_list ;;
|
plain) nohead=1; shell_list ;;
|
||||||
shell) shell_list | column -t ;;
|
shell) fields='$DB $USER $HOST $TYPE $U_DISK $DATE';
|
||||||
|
shell_list | column -t ;;
|
||||||
*) check_args '1' '0' 'user [format]'
|
*) check_args '1' '0' 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,10 @@ format_validation() {
|
||||||
|
|
||||||
# Checking shell
|
# Checking shell
|
||||||
check_shell=$(/usr/bin/chsh --list-shells | grep -w "$val" )
|
check_shell=$(/usr/bin/chsh --list-shells | grep -w "$val" )
|
||||||
if [ -z "$check_shell" ]; then
|
if [ -z "$1"] || [ -z "$check_shell" ]; then
|
||||||
echo "Error: shell not found"
|
echo "Error: shell not found"
|
||||||
log_event 'debug' "$E_INVALID $V_EVENT"
|
log_event 'debug' "$E_NOTEXIST $V_EVENT"
|
||||||
exit $E_INVALID
|
exit $E_NOTEXIST
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,6 +263,64 @@ format_validation() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Define minute/hour/day/month validator
|
||||||
|
format_mhd() {
|
||||||
|
val="$1"
|
||||||
|
digit=$val
|
||||||
|
limit=60
|
||||||
|
|
||||||
|
if [ "$var" = 'day' ]; then
|
||||||
|
limit=31
|
||||||
|
fi
|
||||||
|
if [ "$var" = 'month' ]; then
|
||||||
|
limit=12
|
||||||
|
fi
|
||||||
|
if [ "$var" = 'wday' ]; then
|
||||||
|
limit=7
|
||||||
|
fi
|
||||||
|
|
||||||
|
letters=$(echo "$val"|grep -c "[a-Z]")
|
||||||
|
lslash=$(echo "$val"| grep "^/")
|
||||||
|
if [ -z "$val" ] || [ 0 -ne "$letters" ] || [ -n "$lslash" ]; then
|
||||||
|
echo "Error: $var is out of range"
|
||||||
|
log_event 'debug' "$E_INVALID $V_EVENT"
|
||||||
|
exit $E_INVALID
|
||||||
|
fi
|
||||||
|
|
||||||
|
special_chars=$(echo "$val" | \
|
||||||
|
grep -c "[!|@|#|$|^|&|(|)|+|=|{|}|:|,|.|<|>|?|\|\"|'|;|%| ]" )
|
||||||
|
if [[ 0 -ne "$special_chars" ]] || [ 5 -le ${#val} ]; then
|
||||||
|
echo "Error: $var is out of range"
|
||||||
|
log_event 'debug' "$E_INVALID $V_EVENT"
|
||||||
|
exit $E_INVALID
|
||||||
|
fi
|
||||||
|
|
||||||
|
star=$(echo "$val" |grep '*')
|
||||||
|
if [ ! -z "$star" ]; then
|
||||||
|
slash=$(echo $val |grep "^*/")
|
||||||
|
if [ "$val" != '*' ] && [ -z "$slash" ]; then
|
||||||
|
echo "Error: $var is out of range"
|
||||||
|
log_event 'debug' "$E_INVALID $V_EVENT"
|
||||||
|
exit $E_INVALID
|
||||||
|
else
|
||||||
|
if [ -n "$slash" ]; then
|
||||||
|
digit=$(echo $val | cut -f 2 -d / )
|
||||||
|
fi
|
||||||
|
if [ "$val" = '*' ]; then
|
||||||
|
digit=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$limit" -lt "$digit" ]; then
|
||||||
|
echo "Error: $var is out of range"
|
||||||
|
log_event 'debug' "$E_INVALID $V_EVENT"
|
||||||
|
exit $E_INVALID
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Defining format_ext function
|
# Defining format_ext function
|
||||||
format_ext() {
|
format_ext() {
|
||||||
val="$1"
|
val="$1"
|
||||||
|
@ -313,6 +371,7 @@ format_validation() {
|
||||||
ssl) format_usr "$v" ;;
|
ssl) format_usr "$v" ;;
|
||||||
domain) format_dom "$v" ;;
|
domain) format_dom "$v" ;;
|
||||||
database) format_db "$v" ;;
|
database) format_db "$v" ;;
|
||||||
|
day) format_mhd "$v" ;;
|
||||||
db_user) format_dbu "$v" ;;
|
db_user) format_dbu "$v" ;;
|
||||||
dvalue) format_dvl "$v" ;;
|
dvalue) format_dvl "$v" ;;
|
||||||
fname) format_usr "$v" ;;
|
fname) format_usr "$v" ;;
|
||||||
|
@ -328,6 +387,7 @@ format_validation() {
|
||||||
ns8) format_dom "$v" ;;
|
ns8) format_dom "$v" ;;
|
||||||
email) format_eml "$v" ;;
|
email) format_eml "$v" ;;
|
||||||
extentions) format_ext "$v" ;;
|
extentions) format_ext "$v" ;;
|
||||||
|
hour) format_mhd "$v" ;;
|
||||||
host) format_usr "$v" ;;
|
host) format_usr "$v" ;;
|
||||||
interface) format_ifc "$v" ;;
|
interface) format_ifc "$v" ;;
|
||||||
ip) format_ip "$v" ;;
|
ip) format_ip "$v" ;;
|
||||||
|
@ -337,6 +397,8 @@ format_validation() {
|
||||||
mask) format_ip "$v" ;;
|
mask) format_ip "$v" ;;
|
||||||
max_usr) format_int "$v" ;;
|
max_usr) format_int "$v" ;;
|
||||||
max_db) format_int "$v" ;;
|
max_db) format_int "$v" ;;
|
||||||
|
min) format_mhd "$v" ;;
|
||||||
|
month) format_mhd "$v" ;;
|
||||||
lname) format_usr "$v" ;;
|
lname) format_usr "$v" ;;
|
||||||
owner) format_usr "$v" ;;
|
owner) format_usr "$v" ;;
|
||||||
package) format_usr "$v" ;;
|
package) format_usr "$v" ;;
|
||||||
|
@ -349,6 +411,7 @@ format_validation() {
|
||||||
template) format_usr "$v" ;;
|
template) format_usr "$v" ;;
|
||||||
ttl) format_int "$v" ;;
|
ttl) format_int "$v" ;;
|
||||||
user) format_usr "$v" ;;
|
user) format_usr "$v" ;;
|
||||||
|
wday) format_mhd "$v" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue