Skip to content

Commit 8cfbf71

Browse files
committed
new ip declaration for apache
1 parent 17539c2 commit 8cfbf71

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

bin/v-add-sys-ip

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ip=${1// /}
1919
mask=$2
2020
interface="${3-eth0}"
2121
user="${4-admin}"
22-
ip_status="${5-shared}" # status can be dedicated
22+
ip_status="${5-shared}"
2323
ip_name=$6
2424
nat_ip=$7
2525

@@ -53,16 +53,29 @@ fi
5353
get_ip_iface
5454
sys_ip_check=$(/sbin/ifconfig | grep "addr:$ip ")
5555
if [ -z "$sys_ip_check" ]; then
56+
# Adding sys ip
5657
/sbin/ifconfig "$iface" "$ip" netmask "$mask"
5758

58-
# Adding startup script
59-
sys_ip="# Added by vesta"
60-
sys_ip="$sys_ip\nDEVICE=$iface"
61-
sys_ip="$sys_ip\nBOOTPROTO=static"
62-
sys_ip="$sys_ip\nONBOOT=yes"
63-
sys_ip="$sys_ip\nIPADDR=$ip"
64-
sys_ip="$sys_ip\nNETMASK=$mask"
65-
echo -e $sys_ip > /etc/sysconfig/network-scripts/ifcfg-$iface
59+
# Adding RHEL/CentOS/Fedora startup script
60+
if [ -e "/etc/redhat-release" ]; then
61+
sys_ip="# Added by vesta"
62+
sys_ip="$sys_ip\nDEVICE=$iface"
63+
sys_ip="$sys_ip\nBOOTPROTO=static"
64+
sys_ip="$sys_ip\nONBOOT=yes"
65+
sys_ip="$sys_ip\nIPADDR=$ip"
66+
sys_ip="$sys_ip\nNETMASK=$mask"
67+
echo -e $sys_ip > /etc/sysconfig/network-scripts/ifcfg-$iface
68+
fi
69+
70+
# Adding Debian/Ubuntu startup script
71+
if [ -e "/etc/debian_version" ]; then
72+
sys_ip="# Added by vesta"
73+
sys_ip="$sys_ip\nauto $iface"
74+
sys_ip="$sys_ip\niface $iface inet static"
75+
sys_ip="$sys_ip\naddress $ip"
76+
sys_ip="$sys_ip\netmask $mask"
77+
echo -e $sys_ip >> /etc/network/interfaces
78+
fi
6679
fi
6780

6881
# Adding vesta ip
@@ -79,19 +92,18 @@ DATE='$DATE'" > $VESTA/data/ips/$ip
7992
chmod 660 $VESTA/data/ips/$ip
8093

8194
# WEB support
82-
web_conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
83-
if [ "$WEB_SYSTEM" = 'httpd' ]; then
84-
conf_ins='1'
85-
conf_line=$(grep -n NameVirtual $web_conf | tail -n1 | cut -f1 -d:)
86-
if [ ! -z "$conf_line" ]; then
87-
conf_ins=$((conf_line + 1))
95+
if [ ! -z "$WEB_SYSTEM" ]; then
96+
web_conf="/etc/$WEB_SYSTEM/conf.d/$ip.conf"
97+
98+
if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
99+
echo "NameVirtualHost $ip:$WEB_PORT" > $web_conf
100+
echo "Listen $ip:$WEB_PORT" >> $web_conf
88101
fi
102+
89103
if [ "$WEB_SSL" = 'mod_ssl' ]; then
90-
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $web_conf
91-
sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $web_conf
104+
echo "NameVirtualHost $ip:$WEB_SSL_PORT" >> $web_conf
105+
echo "Listen $ip:$WEB_SSL_PORT" >> $web_conf
92106
fi
93-
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $web_conf
94-
sed -i "$conf_ins i Listen $ip:$WEB_PORT" $web_conf
95107
fi
96108

97109
# Proxy support
@@ -102,11 +114,20 @@ if [ ! -z "$PROXY_SYSTEM" ]; then
102114
-e "s/%proxy_port%/$PROXY_PORT/g" \
103115
> /etc/$PROXY_SYSTEM/conf.d/$ip.conf
104116

117+
# mod_extract_forwarded
105118
fw_conf="/etc/$WEB_SYSTEM/conf.d/mod_extract_forwarded.conf"
106119
if [ -e "$fw_conf" ]; then
107120
ips=$(grep 'MEFaccept ' $fw_conf | grep -v '#' | head -n1)
108121
sed -i "s/$ips/$ips $ip/g" $fw_conf
109122
fi
123+
124+
# mod_rpaf
125+
rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
126+
if [ -e "$rpaf_conf" ]; then
127+
rpaf_str=$(grep RPAFproxy_ips $rpaf_conf)
128+
rpaf_str="$rpaf_str $ip"
129+
sed -i "s/.*RPAFproxy_ips.*/$rpaf_str/" $rpaf_conf
130+
fi
110131
fi
111132

112133

0 commit comments

Comments
 (0)