mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-01-23 11:13:01 -08:00
107 lines
2.6 KiB
Bash
Executable File
107 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: adding system ip
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument defenition
|
|
owner="$1"
|
|
ip_status="$2"
|
|
owner="${3-vesta}"
|
|
ip_status="${4-shared}"
|
|
|
|
# Importing variables
|
|
source $VESTA/conf/vars.conf # include for internal func
|
|
source $V_FUNC/shared_func.sh
|
|
source $V_FUNC/ip_func.sh
|
|
source $V_FUNC/domain_func.sh
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
# Checking arg number
|
|
check_args '0' "$#" '[owner] [ip_status]'
|
|
|
|
# Checking owner
|
|
if [ ! -z "$owner" ]; then
|
|
format_validation 'owner'
|
|
is_user_valid "$owner"
|
|
fi
|
|
|
|
# Checking ip_status
|
|
if [ ! -z "$ip_status" ]; then
|
|
format_validation 'ip_status'
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Get ip list
|
|
ip_list=$(/sbin/ifconfig |grep 'inet addr:'|cut -f 2 -d :|\
|
|
cut -f 1 -d ' '| grep -v 127.0.0.1)
|
|
|
|
# Get vesta registered ip list
|
|
vesta_ip_list=$(ls $V_IPS/)
|
|
|
|
# Importing main config
|
|
source $V_CONF/vesta.conf
|
|
|
|
# Defining config paths
|
|
conf='/etc/httpd/conf.d/vesta.conf'
|
|
nconf='/etc/nginx/conf.d/vesta_ip.conf'
|
|
iconf='/etc/sysconfig/network-scripts/ifcfg'
|
|
rconf='/etc/httpd/conf.d/rpaf.conf'
|
|
|
|
# Comparing each ip
|
|
for ip in $ip_list; do
|
|
check_ip=$(echo $vesta_ip_list|grep -w "$ip")
|
|
|
|
# Checking ip registered
|
|
if [ -z "$check_ip" ]; then
|
|
|
|
# Parsing additional params
|
|
iface=$(/sbin/ifconfig|grep -B1 -w "$ip"|head -n 1|cut -f 1 -d ' '|\
|
|
cut -f 1 -d :)
|
|
mask=$(/sbin/ifconfig |grep -w "$ip"|awk -F "Mask:" '{print $2}')
|
|
|
|
# Adding vesta ip
|
|
ip_add_vesta
|
|
|
|
# Adding namehosting support
|
|
namehost_ip_support
|
|
|
|
# Creating startup script
|
|
if [ ! -e "$iconf-$iface" ]; then
|
|
ip_add_startup
|
|
fi
|
|
fi
|
|
|
|
# NOTE: later we'll make revers comparation
|
|
done
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Updating user conf
|
|
if [ ! -z "$owner" ]; then
|
|
user="$owner"
|
|
increase_user_value "$user" '$IP_OWNED'
|
|
fi
|
|
|
|
# Adding task to the vesta pipe
|
|
if [ "$web_restart" = 'yes' ]; then
|
|
restart_schedule 'web'
|
|
fi
|
|
|
|
# Logging
|
|
log_event 'system' "$V_EVENT"
|
|
|
|
exit $OK
|