Fix Apache site config handling on Fedora

Allow enable/disable_apache_sites() on Fedora to gracefully fail if the
config is not present.  This is primarily an issue when the config from
a previous run is not completely cleaned out (unstack.sh vs clean.sh).

Make APACHE_CONFIG_DIR fully qualified and overrideable in local.conf.

Also fix Horizon's handling of its Apache config file to be removed
in clean.sh.

Change-Id: I78a5de579dd3b02fa2e4e7e00ac0aabe71b531ad
This commit is contained in:
Dean Troyer 2014-06-06 16:36:52 -05:00
parent afda4efb2c
commit 444a8d53ca
2 changed files with 19 additions and 9 deletions

View File

@ -31,13 +31,13 @@ APACHE_GROUP=${APACHE_GROUP:-$(id -gn $APACHE_USER)}
# Set up apache name and configuration directory
if is_ubuntu; then
APACHE_NAME=apache2
APACHE_CONF_DIR=sites-available
APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/sites-available}
elif is_fedora; then
APACHE_NAME=httpd
APACHE_CONF_DIR=conf.d
APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/conf.d}
elif is_suse; then
APACHE_NAME=apache2
APACHE_CONF_DIR=vhosts.d
APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/vhosts.d}
fi
# Functions
@ -108,14 +108,14 @@ function apache_site_config_for {
local apache_version=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/)
if [[ "$apache_version" =~ ^2\.2\. ]]; then
# Ubuntu 12.04 - Apache 2.2
echo /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}
echo $APACHE_CONF_DIR/${site}
else
# Ubuntu 14.04 - Apache 2.4
echo /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf
echo $APACHE_CONF_DIR/${site}.conf
fi
elif is_fedora; then
# fedora conf.d is only imported if it ends with .conf so this is approx the same
local enabled_site_file="/etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf"
local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
if [ -f $enabled_site_file ]; then
echo ${enabled_site_file}
else
@ -130,8 +130,11 @@ function enable_apache_site {
if is_ubuntu; then
sudo a2ensite ${site}
elif is_fedora; then
# fedora conf.d is only imported if it ends with .conf so this is approx the same
sudo mv /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf.disabled /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf
local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
# Do nothing if site already enabled or no site config exists
if [[ -f ${enabled_site_file}.disabled ]] && [[ ! -f ${enabled_site_file} ]]; then
sudo mv ${enabled_site_file}.disabled ${enabled_site_file}
fi
fi
}
@ -141,7 +144,11 @@ function disable_apache_site {
if is_ubuntu; then
sudo a2dissite ${site}
elif is_fedora; then
sudo mv /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf.disabled
local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
# Do nothing if no site config exists
if [[ -f ${enabled_site_file} ]]; then
sudo mv ${enabled_site_file} ${enabled_site_file}.disabled
fi
fi
}

View File

@ -75,6 +75,9 @@ function cleanup_horizon {
sudo rm /usr/bin/node
fi
fi
local horizon_conf=$(apache_site_config_for horizon)
sudo rm -f $horizon_conf
}
# configure_horizon() - Set config files, create data dirs, etc