Răsfoiți Sursa

Multiple changes for RHEL 7support

Serghey Rodin 11 ani în urmă
părinte
comite
b978e72977
8 a modificat fișierele cu 50 adăugiri și 53 ștergeri
  1. 14 12
      bin/v-add-sys-ip
  2. 5 7
      bin/v-restart-cron
  3. 3 3
      bin/v-restart-dns
  4. 2 2
      bin/v-restart-ftp
  5. 2 2
      bin/v-restart-mail
  6. 3 3
      bin/v-restart-proxy
  7. 18 21
      bin/v-restart-web
  8. 3 3
      bin/v-update-web-templates

+ 14 - 12
bin/v-add-sys-ip

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: add system ip address
-# options: IP NETMASK [INTERFACE] [USER] [STATUS] [NAME] [NAT_IP]
+# options: IP NETMASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME] [NAT_IP]
 #
 # 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.
@@ -34,7 +34,7 @@ source $VESTA/conf/vesta.conf
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '2' "$#" 'IP NETMASK [INTERFACE] [USER] [STATUS] [NAME] [NAT_IP]'
+check_args '2' "$#" 'IP NETMASK [INTERFACE] [USER] [STATUS] [NAME] [NATED_IP]'
 validate_format 'ip' 'netmask' 'interface' 'user' 'ip_status'
 is_ip_free
 is_object_valid 'user' 'USER' "$user"
@@ -50,18 +50,15 @@ fi
 #----------------------------------------------------------#
 #                       Action                             #
 #----------------------------------------------------------#
-
-# Converting netmask to CIDR format and calculating broadcast address
+iface=$(get_ip_iface)
 cidr=$(convert_netmask $netmask)
 broadcast=$(get_broadcast $ip $netmask)
-iface=$(get_ip_iface)
 
-sys_ip_check=$(/sbin/ip addr | grep "$ip/$cidr")
+sys_ip_check=$(/sbin/ip addr | grep "$ip")
 if [ -z "$sys_ip_check" ]; then
-
-    # Adding system ip
-    /sbin/ip addr add $ip/$cidr broadcast $broadcast \
-        dev $interface label $iface
+    # Adding sys ip
+    /sbin/ip addr add $ip/$cidr dev $interface \
+        broadcast $broadcast label $iface
 
     # Adding RHEL/CentOS/Fedora startup script
     if [ -e "/etc/redhat-release" ]; then
@@ -101,14 +98,19 @@ chmod 660 $VESTA/data/ips/$ip
 # WEB support
 if [ ! -z "$WEB_SYSTEM" ]; then
     web_conf="/etc/$WEB_SYSTEM/conf.d/$ip.conf"
+    rm -f $web_conf
 
     if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
-        echo "NameVirtualHost $ip:$WEB_PORT" >  $web_conf
+        if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
+            echo "NameVirtualHost $ip:$WEB_PORT" >  $web_conf
+        fi
         echo "Listen $ip:$WEB_PORT" >> $web_conf
     fi
 
     if [ "$WEB_SSL" = 'mod_ssl' ]; then
-        echo "NameVirtualHost $ip:$WEB_SSL_PORT" >> $web_conf
+        if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
+            echo "NameVirtualHost $ip:$WEB_SSL_PORT" >> $web_conf
+        fi
         echo "Listen $ip:$WEB_SSL_PORT" >> $web_conf
     fi
 fi

+ 5 - 7
bin/v-restart-cron

@@ -19,8 +19,8 @@ send_email_report() {
     email=$(echo "$email" | cut -f 2 -d "'")
     tmpfile=$(mktemp)
     subj="$(hostname): $CRON_SYSTEM restart failed"
-    /etc/init.d/$CRON_SYSTEM configtest >> $tmpfile 2>&1
-    /etc/init.d/$CRON_SYSTEM restart >> $tmpfile 2>&1
+    service $CRON_SYSTEM configtest >> $tmpfile 2>&1
+    service $CRON_SYSTEM restart >> $tmpfile 2>&1
     cat $tmpfile | $send_mail -s "$subj" $email
     rm -f $tmpfile
 }
@@ -45,11 +45,9 @@ if [ -z "$CRON_SYSTEM" ] || [ "$CRON_SYSTEM" = 'remote' ]; then
 fi
 
 # Restart system
-if [ -e "/var/run/crond.pid" ]; then
-    /etc/init.d/$CRON_SYSTEM reload >/dev/null 2>&1
-    reload cron >/dev/null 2>&1
-else
-    /etc/init.d/$CRON_SYSTEM restart >/dev/null 2>&1
+service $CRON_SYSTEM reload >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+    service $CRON_SYSTEM restart >/dev/null 2>&1
     if [ $? -ne 0 ]; then
         send_email_report
         exit $E_RESTART

+ 3 - 3
bin/v-restart-dns

@@ -26,7 +26,7 @@ send_email_report() {
     tmpfile=$(mktemp)
     subj="$(hostname): $DNS_SYSTEM restart failed"
     named-checkconf $dns_conf >> $tmpfile 2>&1
-    /etc/init.d/$DNS_SYSTEM restart >> $tmpfile 2>&1
+    service $DNS_SYSTEM restart >> $tmpfile 2>&1
     cat $tmpfile | $send_mail -s "$subj" $email
     rm -f $tmpfile
 }
@@ -51,9 +51,9 @@ if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = 'remote' ] ; then
 fi
 
 # Restart system
-/etc/init.d/$DNS_SYSTEM reload >/dev/null 2>&1
+service $DNS_SYSTEM reload >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    /etc/init.d/$DNS_SYSTEM restart >/dev/null 2>&1
+    service $DNS_SYSTEM restart >/dev/null 2>&1
     if [ $? -ne 0 ]; then
         send_email_report
         echo "Error: $DNS_SYSTEM restart failed"

+ 2 - 2
bin/v-restart-ftp

@@ -19,8 +19,8 @@ send_email_report() {
     email=$(echo "$email" | cut -f 2 -d "'")
     tmpfile=$(mktemp)
     subj="$(hostname): $FTP_SYSTEM restart failed"
-    /etc/init.d/$FTP_SYSTEM configtest >> $tmpfile 2>&1
-    /etc/init.d/$FTP_SYSTEM restart >> $tmpfile 2>&1
+    service $FTP_SYSTEM configtest >> $tmpfile 2>&1
+    service $FTP_SYSTEM restart >> $tmpfile 2>&1
     cat $tmpfile | $send_mail -s "$subj" $email
     rm -f $tmpfile
 }

+ 2 - 2
bin/v-restart-mail

@@ -19,8 +19,8 @@ send_email_report() {
     email=$(echo "$email" | cut -f 2 -d "'")
     tmpfile=$(mktemp)
     subj="$(hostname): $MAIL_SYSTEM restart failed"
-    /etc/init.d/$MAIL_SYSTEM configtest >> $tmpfile 2>&1
-    /etc/init.d/$MAIL_SYSTEM restart >> $tmpfile 2>&1
+    service $MAIL_SYSTEM configtest >> $tmpfile 2>&1
+    service $MAIL_SYSTEM restart >> $tmpfile 2>&1
     cat $tmpfile | $send_mail -s "$subj" $email
     rm -f $tmpfile
 }

+ 3 - 3
bin/v-restart-proxy

@@ -19,8 +19,8 @@ send_email_report() {
     email=$(echo "$email" | cut -f 2 -d "'")
     tmpfile=$(mktemp)
     subj="$(hostname): $PROXY_SYSTEM restart failed"
-    /etc/init.d/$PROXY_SYSTEM configtest >> $tmpfile 2>&1
-    /etc/init.d/$PROXY_SYSTEM restart >> $tmpfile 2>&1
+    service $PROXY_SYSTEM configtest >> $tmpfile 2>&1
+    service $PROXY_SYSTEM restart >> $tmpfile 2>&1
     cat $tmpfile | $send_mail -s "$subj" $email
     rm -f $tmpfile
 }
@@ -45,7 +45,7 @@ if [ -z "$PROXY_SYSTEM" ] || [ "$PROXY_SYSTEM" = 'remote' ]; then
 fi
 
 # Restart system
-/etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1
+service $PROXY_SYSTEM restart >/dev/null 2>&1
 if [ $? -ne 0 ]; then
     send_email_report
     echo "Error: $PROXY_SYSTEM restart failed"

+ 18 - 21
bin/v-restart-web

@@ -19,8 +19,8 @@ send_email_report() {
     email=$(echo "$email" | cut -f 2 -d "'")
     tmpfile=$(mktemp)
     subj="$(hostname): $WEB_SYSTEM restart failed"
-    /etc/init.d/$WEB_SYSTEM configtest >> $tmpfile 2>&1
-    /etc/init.d/$WEB_SYSTEM restart >> $tmpfile 2>&1
+    service $WEB_SYSTEM configtest >> $tmpfile 2>&1
+    service $WEB_SYSTEM restart >> $tmpfile 2>&1
     cat $tmpfile | $send_mail -s "$subj" $email
     rm -f $tmpfile
 }
@@ -44,27 +44,24 @@ if [ -z "$WEB_SYSTEM" ] || [ "$WEB_SYSTEM" = 'remote' ]; then
     exit
 fi
 
-# Restart system
+# Reload web system
+service $WEB_SYSTEM reload >/dev/null 2>&1
+rc=$?
+
+# Workaround for Ubuntu 12.04
 if [ "$WEB_SYSTEM" == 'apache2' ]; then
-    if [ -e "/var/run/apache2.pid" ]; then
-        /etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
-    else
-        /etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
-        if [ $? -ne 0 ]; then
-            send_email_report
-            echo "Error: $WEB_SYSTEM restart failed"
-            exit $E_RESTART
-        fi
+    if [ ! -e "/var/run/apache2.pid" ]; then
+        rc=1
     fi
-else
-    /etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
-    if [ "$?" -ne 0 ]; then
-        /etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
-        if [ $? -ne 0 ]; then
-            send_email_report
-            echo "Error: $WEB_SYSTEM restart failed"
-            exit $E_RESTART
-        fi
+fi
+
+# Resart web system if reload didn't work
+if [ "$rc" -ne 0 ]; then
+    service $WEB_SYSTEM restart >/dev/null 2>&1
+    if [ $? -ne 0 ]; then
+        send_email_report
+        echo "Error: $WEB_SYSTEM restart failed"
+        exit $E_RESTART
     fi
 fi
 

+ 3 - 3
bin/v-update-web-templates

@@ -44,10 +44,10 @@ fi
 tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
 
 # Replace includes for apache2.4
-if [ "$os" = 'ubuntu' ]; then
-    if [ ! -z "$(apache2 -v|grep 'Apache/2.4')" ]; then
+if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
+    if [ ! -z "$(/usr/sbin/apachectl -v | grep 'Apache/2.4')" ]; then
         sed -i "s/Include /IncludeOptional /g" \
-            $VESTA/data/templates/web/apache2/*tpl
+            $VESTA/data/templates/web/$WEB_SYSTEM/*tpl
     fi
 fi