vesta/bin/v_add_sys_ip
2011-06-14 00:22:25 +03:00

101 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# info: adding system ip
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
ip="$1"
mask="$2"
interface="${3-eth0}"
owner="${4-vesta}"
ip_status="${5-shared}"
ip_name="$6"
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared_func.sh
source $V_FUNC/ip_func.sh
source $V_FUNC/domain_func.sh # for namehosting
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'ip mask [interface] [owner] [ip_status] [ip_name]'
# Checking argument format
format_validation 'ip' 'mask' 'interface'
# Checking system ip
is_sys_ip_free
# Checking owner
if [ ! -z "$owner" ]; then
format_validation 'user'
is_user_valid "$owner"
fi
# Checking ip_status
if [ ! -z "$ip_status" ]; then
format_validation 'ip_status'
fi
# Checking ip_name
if [ ! -z "$ip_name" ] ; then
format_validation 'ip_name'
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get interface number
i_number=$(get_next_interface_number)
iface="$interface$i_number"
# 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'
# Adding ip
ifconfig "$iface" "$ip" netmask "$mask"
# Adding startup script
ip_add_startup
# Adding vesta ip
ip_add_vesta
# Importing main config
source $V_CONF/vesta.conf
# Adding namehosting support
namehost_ip_support
#----------------------------------------------------------#
# 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