Skip to content

Commit b978e72

Browse files
committed
Multiple changes for RHEL 7support
1 parent a719b6d commit b978e72

File tree

8 files changed

+50
-53
lines changed

8 files changed

+50
-53
lines changed

bin/v-add-sys-ip

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add system ip address
3-
# options: IP NETMASK [INTERFACE] [USER] [STATUS] [NAME] [NAT_IP]
3+
# options: IP NETMASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME] [NAT_IP]
44
#
55
# The function adds ip address into a system. It also creates rc scripts. You
66
# can specify ip name which will be used as root domain for temporary aliases.
@@ -34,7 +34,7 @@ source $VESTA/conf/vesta.conf
3434
# Verifications #
3535
#----------------------------------------------------------#
3636

37-
check_args '2' "$#" 'IP NETMASK [INTERFACE] [USER] [STATUS] [NAME] [NAT_IP]'
37+
check_args '2' "$#" 'IP NETMASK [INTERFACE] [USER] [STATUS] [NAME] [NATED_IP]'
3838
validate_format 'ip' 'netmask' 'interface' 'user' 'ip_status'
3939
is_ip_free
4040
is_object_valid 'user' 'USER' "$user"
@@ -50,18 +50,15 @@ fi
5050
#----------------------------------------------------------#
5151
# Action #
5252
#----------------------------------------------------------#
53-
54-
# Converting netmask to CIDR format and calculating broadcast address
53+
iface=$(get_ip_iface)
5554
cidr=$(convert_netmask $netmask)
5655
broadcast=$(get_broadcast $ip $netmask)
57-
iface=$(get_ip_iface)
5856

59-
sys_ip_check=$(/sbin/ip addr | grep "$ip/$cidr")
57+
sys_ip_check=$(/sbin/ip addr | grep "$ip")
6058
if [ -z "$sys_ip_check" ]; then
61-
62-
# Adding system ip
63-
/sbin/ip addr add $ip/$cidr broadcast $broadcast \
64-
dev $interface label $iface
59+
# Adding sys ip
60+
/sbin/ip addr add $ip/$cidr dev $interface \
61+
broadcast $broadcast label $iface
6562

6663
# Adding RHEL/CentOS/Fedora startup script
6764
if [ -e "/etc/redhat-release" ]; then
@@ -101,14 +98,19 @@ chmod 660 $VESTA/data/ips/$ip
10198
# WEB support
10299
if [ ! -z "$WEB_SYSTEM" ]; then
103100
web_conf="/etc/$WEB_SYSTEM/conf.d/$ip.conf"
101+
rm -f $web_conf
104102

105103
if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
106-
echo "NameVirtualHost $ip:$WEB_PORT" > $web_conf
104+
if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
105+
echo "NameVirtualHost $ip:$WEB_PORT" > $web_conf
106+
fi
107107
echo "Listen $ip:$WEB_PORT" >> $web_conf
108108
fi
109109

110110
if [ "$WEB_SSL" = 'mod_ssl' ]; then
111-
echo "NameVirtualHost $ip:$WEB_SSL_PORT" >> $web_conf
111+
if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
112+
echo "NameVirtualHost $ip:$WEB_SSL_PORT" >> $web_conf
113+
fi
112114
echo "Listen $ip:$WEB_SSL_PORT" >> $web_conf
113115
fi
114116
fi

bin/v-restart-cron

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ send_email_report() {
1919
email=$(echo "$email" | cut -f 2 -d "'")
2020
tmpfile=$(mktemp)
2121
subj="$(hostname): $CRON_SYSTEM restart failed"
22-
/etc/init.d/$CRON_SYSTEM configtest >> $tmpfile 2>&1
23-
/etc/init.d/$CRON_SYSTEM restart >> $tmpfile 2>&1
22+
service $CRON_SYSTEM configtest >> $tmpfile 2>&1
23+
service $CRON_SYSTEM restart >> $tmpfile 2>&1
2424
cat $tmpfile | $send_mail -s "$subj" $email
2525
rm -f $tmpfile
2626
}
@@ -45,11 +45,9 @@ if [ -z "$CRON_SYSTEM" ] || [ "$CRON_SYSTEM" = 'remote' ]; then
4545
fi
4646

4747
# Restart system
48-
if [ -e "/var/run/crond.pid" ]; then
49-
/etc/init.d/$CRON_SYSTEM reload >/dev/null 2>&1
50-
reload cron >/dev/null 2>&1
51-
else
52-
/etc/init.d/$CRON_SYSTEM restart >/dev/null 2>&1
48+
service $CRON_SYSTEM reload >/dev/null 2>&1
49+
if [ $? -ne 0 ]; then
50+
service $CRON_SYSTEM restart >/dev/null 2>&1
5351
if [ $? -ne 0 ]; then
5452
send_email_report
5553
exit $E_RESTART

bin/v-restart-dns

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ send_email_report() {
2626
tmpfile=$(mktemp)
2727
subj="$(hostname): $DNS_SYSTEM restart failed"
2828
named-checkconf $dns_conf >> $tmpfile 2>&1
29-
/etc/init.d/$DNS_SYSTEM restart >> $tmpfile 2>&1
29+
service $DNS_SYSTEM restart >> $tmpfile 2>&1
3030
cat $tmpfile | $send_mail -s "$subj" $email
3131
rm -f $tmpfile
3232
}
@@ -51,9 +51,9 @@ if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = 'remote' ] ; then
5151
fi
5252

5353
# Restart system
54-
/etc/init.d/$DNS_SYSTEM reload >/dev/null 2>&1
54+
service $DNS_SYSTEM reload >/dev/null 2>&1
5555
if [ $? -ne 0 ]; then
56-
/etc/init.d/$DNS_SYSTEM restart >/dev/null 2>&1
56+
service $DNS_SYSTEM restart >/dev/null 2>&1
5757
if [ $? -ne 0 ]; then
5858
send_email_report
5959
echo "Error: $DNS_SYSTEM restart failed"

bin/v-restart-ftp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ send_email_report() {
1919
email=$(echo "$email" | cut -f 2 -d "'")
2020
tmpfile=$(mktemp)
2121
subj="$(hostname): $FTP_SYSTEM restart failed"
22-
/etc/init.d/$FTP_SYSTEM configtest >> $tmpfile 2>&1
23-
/etc/init.d/$FTP_SYSTEM restart >> $tmpfile 2>&1
22+
service $FTP_SYSTEM configtest >> $tmpfile 2>&1
23+
service $FTP_SYSTEM restart >> $tmpfile 2>&1
2424
cat $tmpfile | $send_mail -s "$subj" $email
2525
rm -f $tmpfile
2626
}

bin/v-restart-mail

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ send_email_report() {
1919
email=$(echo "$email" | cut -f 2 -d "'")
2020
tmpfile=$(mktemp)
2121
subj="$(hostname): $MAIL_SYSTEM restart failed"
22-
/etc/init.d/$MAIL_SYSTEM configtest >> $tmpfile 2>&1
23-
/etc/init.d/$MAIL_SYSTEM restart >> $tmpfile 2>&1
22+
service $MAIL_SYSTEM configtest >> $tmpfile 2>&1
23+
service $MAIL_SYSTEM restart >> $tmpfile 2>&1
2424
cat $tmpfile | $send_mail -s "$subj" $email
2525
rm -f $tmpfile
2626
}

bin/v-restart-proxy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ send_email_report() {
1919
email=$(echo "$email" | cut -f 2 -d "'")
2020
tmpfile=$(mktemp)
2121
subj="$(hostname): $PROXY_SYSTEM restart failed"
22-
/etc/init.d/$PROXY_SYSTEM configtest >> $tmpfile 2>&1
23-
/etc/init.d/$PROXY_SYSTEM restart >> $tmpfile 2>&1
22+
service $PROXY_SYSTEM configtest >> $tmpfile 2>&1
23+
service $PROXY_SYSTEM restart >> $tmpfile 2>&1
2424
cat $tmpfile | $send_mail -s "$subj" $email
2525
rm -f $tmpfile
2626
}
@@ -45,7 +45,7 @@ if [ -z "$PROXY_SYSTEM" ] || [ "$PROXY_SYSTEM" = 'remote' ]; then
4545
fi
4646

4747
# Restart system
48-
/etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1
48+
service $PROXY_SYSTEM restart >/dev/null 2>&1
4949
if [ $? -ne 0 ]; then
5050
send_email_report
5151
echo "Error: $PROXY_SYSTEM restart failed"

bin/v-restart-web

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ send_email_report() {
1919
email=$(echo "$email" | cut -f 2 -d "'")
2020
tmpfile=$(mktemp)
2121
subj="$(hostname): $WEB_SYSTEM restart failed"
22-
/etc/init.d/$WEB_SYSTEM configtest >> $tmpfile 2>&1
23-
/etc/init.d/$WEB_SYSTEM restart >> $tmpfile 2>&1
22+
service $WEB_SYSTEM configtest >> $tmpfile 2>&1
23+
service $WEB_SYSTEM restart >> $tmpfile 2>&1
2424
cat $tmpfile | $send_mail -s "$subj" $email
2525
rm -f $tmpfile
2626
}
@@ -44,27 +44,24 @@ if [ -z "$WEB_SYSTEM" ] || [ "$WEB_SYSTEM" = 'remote' ]; then
4444
exit
4545
fi
4646

47-
# Restart system
47+
# Reload web system
48+
service $WEB_SYSTEM reload >/dev/null 2>&1
49+
rc=$?
50+
51+
# Workaround for Ubuntu 12.04
4852
if [ "$WEB_SYSTEM" == 'apache2' ]; then
49-
if [ -e "/var/run/apache2.pid" ]; then
50-
/etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
51-
else
52-
/etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
53-
if [ $? -ne 0 ]; then
54-
send_email_report
55-
echo "Error: $WEB_SYSTEM restart failed"
56-
exit $E_RESTART
57-
fi
53+
if [ ! -e "/var/run/apache2.pid" ]; then
54+
rc=1
5855
fi
59-
else
60-
/etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
61-
if [ "$?" -ne 0 ]; then
62-
/etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
63-
if [ $? -ne 0 ]; then
64-
send_email_report
65-
echo "Error: $WEB_SYSTEM restart failed"
66-
exit $E_RESTART
67-
fi
56+
fi
57+
58+
# Resart web system if reload didn't work
59+
if [ "$rc" -ne 0 ]; then
60+
service $WEB_SYSTEM restart >/dev/null 2>&1
61+
if [ $? -ne 0 ]; then
62+
send_email_report
63+
echo "Error: $WEB_SYSTEM restart failed"
64+
exit $E_RESTART
6865
fi
6966
fi
7067

bin/v-update-web-templates

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ fi
4444
tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
4545

4646
# Replace includes for apache2.4
47-
if [ "$os" = 'ubuntu' ]; then
48-
if [ ! -z "$(apache2 -v|grep 'Apache/2.4')" ]; then
47+
if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
48+
if [ ! -z "$(/usr/sbin/apachectl -v | grep 'Apache/2.4')" ]; then
4949
sed -i "s/Include /IncludeOptional /g" \
50-
$VESTA/data/templates/web/apache2/*tpl
50+
$VESTA/data/templates/web/$WEB_SYSTEM/*tpl
5151
fi
5252
fi
5353

0 commit comments

Comments
 (0)