mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 04:50:47 -07:00
Multiple changes for RHEL 7support
This commit is contained in:
parent
a719b6d4d4
commit
b978e72977
8 changed files with 50 additions and 53 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: add system ip address
|
# 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
|
# 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.
|
# can specify ip name which will be used as root domain for temporary aliases.
|
||||||
|
@ -34,7 +34,7 @@ source $VESTA/conf/vesta.conf
|
||||||
# Verifications #
|
# 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'
|
validate_format 'ip' 'netmask' 'interface' 'user' 'ip_status'
|
||||||
is_ip_free
|
is_ip_free
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
@ -50,18 +50,15 @@ fi
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
iface=$(get_ip_iface)
|
||||||
# Converting netmask to CIDR format and calculating broadcast address
|
|
||||||
cidr=$(convert_netmask $netmask)
|
cidr=$(convert_netmask $netmask)
|
||||||
broadcast=$(get_broadcast $ip $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
|
if [ -z "$sys_ip_check" ]; then
|
||||||
|
# Adding sys ip
|
||||||
# Adding system ip
|
/sbin/ip addr add $ip/$cidr dev $interface \
|
||||||
/sbin/ip addr add $ip/$cidr broadcast $broadcast \
|
broadcast $broadcast label $iface
|
||||||
dev $interface label $iface
|
|
||||||
|
|
||||||
# Adding RHEL/CentOS/Fedora startup script
|
# Adding RHEL/CentOS/Fedora startup script
|
||||||
if [ -e "/etc/redhat-release" ]; then
|
if [ -e "/etc/redhat-release" ]; then
|
||||||
|
@ -101,14 +98,19 @@ chmod 660 $VESTA/data/ips/$ip
|
||||||
# WEB support
|
# WEB support
|
||||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||||
web_conf="/etc/$WEB_SYSTEM/conf.d/$ip.conf"
|
web_conf="/etc/$WEB_SYSTEM/conf.d/$ip.conf"
|
||||||
|
rm -f $web_conf
|
||||||
|
|
||||||
if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
|
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
|
echo "Listen $ip:$WEB_PORT" >> $web_conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$WEB_SSL" = 'mod_ssl' ]; then
|
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
|
echo "Listen $ip:$WEB_SSL_PORT" >> $web_conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -19,8 +19,8 @@ send_email_report() {
|
||||||
email=$(echo "$email" | cut -f 2 -d "'")
|
email=$(echo "$email" | cut -f 2 -d "'")
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
subj="$(hostname): $CRON_SYSTEM restart failed"
|
subj="$(hostname): $CRON_SYSTEM restart failed"
|
||||||
/etc/init.d/$CRON_SYSTEM configtest >> $tmpfile 2>&1
|
service $CRON_SYSTEM configtest >> $tmpfile 2>&1
|
||||||
/etc/init.d/$CRON_SYSTEM restart >> $tmpfile 2>&1
|
service $CRON_SYSTEM restart >> $tmpfile 2>&1
|
||||||
cat $tmpfile | $send_mail -s "$subj" $email
|
cat $tmpfile | $send_mail -s "$subj" $email
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,9 @@ if [ -z "$CRON_SYSTEM" ] || [ "$CRON_SYSTEM" = 'remote' ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart system
|
# Restart system
|
||||||
if [ -e "/var/run/crond.pid" ]; then
|
service $CRON_SYSTEM reload >/dev/null 2>&1
|
||||||
/etc/init.d/$CRON_SYSTEM reload >/dev/null 2>&1
|
if [ $? -ne 0 ]; then
|
||||||
reload cron >/dev/null 2>&1
|
service $CRON_SYSTEM restart >/dev/null 2>&1
|
||||||
else
|
|
||||||
/etc/init.d/$CRON_SYSTEM restart >/dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
send_email_report
|
send_email_report
|
||||||
exit $E_RESTART
|
exit $E_RESTART
|
||||||
|
|
|
@ -26,7 +26,7 @@ send_email_report() {
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
subj="$(hostname): $DNS_SYSTEM restart failed"
|
subj="$(hostname): $DNS_SYSTEM restart failed"
|
||||||
named-checkconf $dns_conf >> $tmpfile 2>&1
|
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
|
cat $tmpfile | $send_mail -s "$subj" $email
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,9 @@ if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = 'remote' ] ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart system
|
# Restart system
|
||||||
/etc/init.d/$DNS_SYSTEM reload >/dev/null 2>&1
|
service $DNS_SYSTEM reload >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
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
|
if [ $? -ne 0 ]; then
|
||||||
send_email_report
|
send_email_report
|
||||||
echo "Error: $DNS_SYSTEM restart failed"
|
echo "Error: $DNS_SYSTEM restart failed"
|
||||||
|
|
|
@ -19,8 +19,8 @@ send_email_report() {
|
||||||
email=$(echo "$email" | cut -f 2 -d "'")
|
email=$(echo "$email" | cut -f 2 -d "'")
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
subj="$(hostname): $FTP_SYSTEM restart failed"
|
subj="$(hostname): $FTP_SYSTEM restart failed"
|
||||||
/etc/init.d/$FTP_SYSTEM configtest >> $tmpfile 2>&1
|
service $FTP_SYSTEM configtest >> $tmpfile 2>&1
|
||||||
/etc/init.d/$FTP_SYSTEM restart >> $tmpfile 2>&1
|
service $FTP_SYSTEM restart >> $tmpfile 2>&1
|
||||||
cat $tmpfile | $send_mail -s "$subj" $email
|
cat $tmpfile | $send_mail -s "$subj" $email
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ send_email_report() {
|
||||||
email=$(echo "$email" | cut -f 2 -d "'")
|
email=$(echo "$email" | cut -f 2 -d "'")
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
subj="$(hostname): $MAIL_SYSTEM restart failed"
|
subj="$(hostname): $MAIL_SYSTEM restart failed"
|
||||||
/etc/init.d/$MAIL_SYSTEM configtest >> $tmpfile 2>&1
|
service $MAIL_SYSTEM configtest >> $tmpfile 2>&1
|
||||||
/etc/init.d/$MAIL_SYSTEM restart >> $tmpfile 2>&1
|
service $MAIL_SYSTEM restart >> $tmpfile 2>&1
|
||||||
cat $tmpfile | $send_mail -s "$subj" $email
|
cat $tmpfile | $send_mail -s "$subj" $email
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ send_email_report() {
|
||||||
email=$(echo "$email" | cut -f 2 -d "'")
|
email=$(echo "$email" | cut -f 2 -d "'")
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
subj="$(hostname): $PROXY_SYSTEM restart failed"
|
subj="$(hostname): $PROXY_SYSTEM restart failed"
|
||||||
/etc/init.d/$PROXY_SYSTEM configtest >> $tmpfile 2>&1
|
service $PROXY_SYSTEM configtest >> $tmpfile 2>&1
|
||||||
/etc/init.d/$PROXY_SYSTEM restart >> $tmpfile 2>&1
|
service $PROXY_SYSTEM restart >> $tmpfile 2>&1
|
||||||
cat $tmpfile | $send_mail -s "$subj" $email
|
cat $tmpfile | $send_mail -s "$subj" $email
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ if [ -z "$PROXY_SYSTEM" ] || [ "$PROXY_SYSTEM" = 'remote' ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart system
|
# Restart system
|
||||||
/etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1
|
service $PROXY_SYSTEM restart >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
send_email_report
|
send_email_report
|
||||||
echo "Error: $PROXY_SYSTEM restart failed"
|
echo "Error: $PROXY_SYSTEM restart failed"
|
||||||
|
|
|
@ -19,8 +19,8 @@ send_email_report() {
|
||||||
email=$(echo "$email" | cut -f 2 -d "'")
|
email=$(echo "$email" | cut -f 2 -d "'")
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
subj="$(hostname): $WEB_SYSTEM restart failed"
|
subj="$(hostname): $WEB_SYSTEM restart failed"
|
||||||
/etc/init.d/$WEB_SYSTEM configtest >> $tmpfile 2>&1
|
service $WEB_SYSTEM configtest >> $tmpfile 2>&1
|
||||||
/etc/init.d/$WEB_SYSTEM restart >> $tmpfile 2>&1
|
service $WEB_SYSTEM restart >> $tmpfile 2>&1
|
||||||
cat $tmpfile | $send_mail -s "$subj" $email
|
cat $tmpfile | $send_mail -s "$subj" $email
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
}
|
}
|
||||||
|
@ -44,27 +44,24 @@ if [ -z "$WEB_SYSTEM" ] || [ "$WEB_SYSTEM" = 'remote' ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
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 [ "$WEB_SYSTEM" == 'apache2' ]; then
|
||||||
if [ -e "/var/run/apache2.pid" ]; then
|
if [ ! -e "/var/run/apache2.pid" ]; then
|
||||||
/etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
|
rc=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
|
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
/etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
|
|
||||||
if [ "$?" -ne 0 ]; then
|
# Resart web system if reload didn't work
|
||||||
/etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
|
if [ "$rc" -ne 0 ]; then
|
||||||
if [ $? -ne 0 ]; then
|
service $WEB_SYSTEM restart >/dev/null 2>&1
|
||||||
send_email_report
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: $WEB_SYSTEM restart failed"
|
send_email_report
|
||||||
exit $E_RESTART
|
echo "Error: $WEB_SYSTEM restart failed"
|
||||||
fi
|
exit $E_RESTART
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,10 @@ fi
|
||||||
tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
|
tar -xzpf templates.tar.gz -C $VESTA/data/ templates/web
|
||||||
|
|
||||||
# Replace includes for apache2.4
|
# Replace includes for apache2.4
|
||||||
if [ "$os" = 'ubuntu' ]; then
|
if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
|
||||||
if [ ! -z "$(apache2 -v|grep 'Apache/2.4')" ]; then
|
if [ ! -z "$(/usr/sbin/apachectl -v | grep 'Apache/2.4')" ]; then
|
||||||
sed -i "s/Include /IncludeOptional /g" \
|
sed -i "s/Include /IncludeOptional /g" \
|
||||||
$VESTA/data/templates/web/apache2/*tpl
|
$VESTA/data/templates/web/$WEB_SYSTEM/*tpl
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue