Add is_fedora and exit_distro_not_supported functions
Between is_fedora, is_ubuntu and is_suse, we can make the code a bit
simpler to read. We also use exit_distro_not_supported to identify
places where we need implementation details for new distros.
As "/sbin/service --skip-redirect" is Fedora-specific, guard this with a
is_fedora test too.
Change-Id: Ic77c0697ed9be0dbb5df8e73da93463e76025f0c
diff --git a/lib/horizon b/lib/horizon
index 7321cbc..68337ab 100644
--- a/lib/horizon
+++ b/lib/horizon
@@ -81,19 +81,18 @@
sudo a2ensite horizon
# WSGI doesn't enable by default, enable it
sudo a2enmod wsgi
+ elif is_fedora; then
+ APACHE_NAME=httpd
+ APACHE_CONF=conf.d/horizon.conf
+ sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
+ elif is_suse; then
+ APACHE_NAME=apache2
+ APACHE_CONF=vhosts.d/horizon.conf
+ # Append wsgi to the list of modules to load
+ grep -q "^APACHE_MODULES=.*wsgi" /etc/sysconfig/apache2 ||
+ sudo sed '/^APACHE_MODULES=/s/^\(.*\)"$/\1 wsgi"/' -i /etc/sysconfig/apache2
else
- # Install httpd, which is NOPRIME'd
- if is_suse; then
- APACHE_NAME=apache2
- APACHE_CONF=vhosts.d/horizon.conf
- # Append wsgi to the list of modules to load
- grep -q "^APACHE_MODULES=.*wsgi" /etc/sysconfig/apache2 ||
- sudo sed '/^APACHE_MODULES=/s/^\(.*\)"$/\1 wsgi"/' -i /etc/sysconfig/apache2
- else
- APACHE_NAME=httpd
- APACHE_CONF=conf.d/horizon.conf
- sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
- fi
+ exit_distro_not_supported "apache configuration"
fi
# Configure apache to run horizon
@@ -113,11 +112,13 @@
if is_ubuntu; then
# Install apache2, which is NOPRIME'd
install_package apache2 libapache2-mod-wsgi
+ elif is_fedora; then
+ sudo rm -f /etc/httpd/conf.d/000-*
+ install_package httpd mod_wsgi
elif is_suse; then
install_package apache2 apache2-mod_wsgi
else
- sudo rm -f /etc/httpd/conf.d/000-*
- install_package httpd mod_wsgi
+ exit_distro_not_supported "apache installation"
fi
# NOTE(sdague) quantal changed the name of the node binary