| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #!/bin/bash
- # info: add system ip address
- # options: ip mask [interface] [user] [ip_status] [ip_name]
- #
- # The function adds ip address into a system. It also creates rc scripts. You
- # can specify ip name which will be used as root domain for temporary aliases.
- # For example, if you set a1.myhosting.com as name, each new domain created on
- # this ip will automaticaly receive alias $domain.a1.myhosting.com. Of course
- # you must have wildcard record *.a1.myhosting.com pointed to ip. This feature
- # is very handy when customer wants to test domain before dns migration.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument defenition
- ip=$1
- mask=$2
- interface="${3-eth0}"
- user="${4-vesta}"
- ip_status="${5-shared}"
- ip_name=$6
- # Importing variables
- source $VESTA/conf/vars.conf
- source $V_CONF/vesta.conf
- source $V_FUNC/shared.func
- source $V_FUNC/ip.func
- source $V_FUNC/domain.func # for namehosting
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- # Checking arg number
- check_args '2' "$#" 'ip mask [interface] [user] [ip_status] [ip_name]'
- # Checking argument format
- format_validation 'ip' 'mask' 'interface' 'user'
- # Checking system ip
- is_sys_ip_free
- # Checking user
- is_user_valid "$user"
- # 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
- /sbin/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
- increase_user_value "$user" '$IP_OWNED'
- # Adding task to the vesta pipe
- if [ "$web_restart" = 'yes' ]; then
- restart_schedule 'web'
- fi
- # Logging
- log_event 'system' "$V_EVENT"
- exit
|