Browse code

Fix swift httpd on fedora

Implements a fedora equivalent of ubuntu's sites-enabled and moves
enabling of mod_wsgi to the installation period so that it doesn't have
to be handled in a platform dependant way later.

Fixes: bug 1226363
Change-Id: I85325179f1792d985b0375572abfe8c8a82fecc3

Jamie Lennox authored on 2013/09/17 11:07:48
Showing 3 changed files
... ...
@@ -6,6 +6,8 @@
6 6
 # is_apache_enabled_service
7 7
 # install_apache_wsgi
8 8
 # config_apache_wsgi
9
+# enable_apache_site
10
+# disable_apache_site
9 11
 # start_apache_server
10 12
 # stop_apache_server
11 13
 # restart_apache_server
... ...
@@ -57,16 +59,41 @@ function install_apache_wsgi() {
57 57
     if is_ubuntu; then
58 58
         # Install apache2, which is NOPRIME'd
59 59
         install_package apache2 libapache2-mod-wsgi
60
+        # WSGI isn't enabled by default, enable it
61
+        sudo a2enmod wsgi
60 62
     elif is_fedora; then
61 63
         sudo rm -f /etc/httpd/conf.d/000-*
62 64
         install_package httpd mod_wsgi
63 65
     elif is_suse; then
64 66
         install_package apache2 apache2-mod_wsgi
67
+        # WSGI isn't enabled by default, enable it
68
+        sudo a2enmod wsgi
65 69
     else
66 70
         exit_distro_not_supported "apache installation"
67 71
     fi
68 72
 }
69 73
 
74
+# enable_apache_site() - Enable a particular apache site
75
+function enable_apache_site() {
76
+    local site=$@
77
+    if is_ubuntu; then
78
+        sudo a2ensite ${site}
79
+    elif is_fedora; then
80
+        # fedora conf.d is only imported if it ends with .conf so this is approx the same
81
+        sudo mv /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site} /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf
82
+    fi
83
+}
84
+
85
+# disable_apache_site() - Disable a particular apache site
86
+function disable_apache_site() {
87
+    local site=$@
88
+    if is_ubuntu; then
89
+        sudo a2dissite ${site}
90
+    elif is_fedora; then
91
+        sudo mv /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}
92
+    fi
93
+}
94
+
70 95
 # start_apache_server() - Start running apache server
71 96
 function start_apache_server() {
72 97
     start_service $APACHE_NAME
... ...
@@ -123,8 +123,6 @@ function init_horizon() {
123 123
         # Be a good citizen and use the distro tools here
124 124
         sudo touch $horizon_conf
125 125
         sudo a2ensite horizon.conf
126
-        # WSGI isn't enabled by default, enable it
127
-        sudo a2enmod wsgi
128 126
     elif is_fedora; then
129 127
         if [[ "$os_RELEASE" -ge "18" ]]; then
130 128
             # fedora 18 has Require all denied  in its httpd.conf
... ...
@@ -132,9 +130,6 @@ function init_horizon() {
132 132
             HORIZON_REQUIRE='Require all granted'
133 133
         fi
134 134
         sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
135
-    elif is_suse; then
136
-        # WSGI isn't enabled by default, enable it
137
-        sudo a2enmod wsgi
138 135
     else
139 136
         exit_distro_not_supported "apache configuration"
140 137
     fi
... ...
@@ -115,11 +115,11 @@ function cleanup_swift() {
115 115
 # _cleanup_swift_apache_wsgi() - Remove wsgi files, disable and remove apache vhost file
116 116
 function _cleanup_swift_apache_wsgi() {
117 117
     sudo rm -f $SWIFT_APACHE_WSGI_DIR/*.wsgi
118
-    ! is_fedora && sudo a2dissite proxy-server
118
+    disable_apache_site proxy-server
119 119
     for node_number in ${SWIFT_REPLICAS_SEQ}; do
120 120
         for type in object container account; do
121 121
             site_name=${type}-server-${node_number}
122
-            ! is_fedora && sudo a2dissite ${site_name}
122
+            disable_apache_site ${site_name}
123 123
             sudo rm -f /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site_name}
124 124
         done
125 125
     done
... ...
@@ -140,13 +140,13 @@ function _config_swift_apache_wsgi() {
140 140
         s/%APACHE_NAME%/${APACHE_NAME}/g;
141 141
         s/%USER%/${STACK_USER}/g;
142 142
     " -i ${apache_vhost_dir}/proxy-server
143
+    enable_apache_site proxy-server
143 144
 
144 145
     sudo cp ${SWIFT_DIR}/examples/wsgi/proxy-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/proxy-server.wsgi
145 146
     sudo sed -e "
146 147
         /^#/d;/^$/d;
147 148
         s/%SERVICECONF%/proxy-server.conf/g;
148 149
     " -i ${SWIFT_APACHE_WSGI_DIR}/proxy-server.wsgi
149
-    ! is_fedora && sudo a2ensite proxy-server
150 150
 
151 151
     # copy apache vhost file and set name and port
152 152
     for node_number in ${SWIFT_REPLICAS_SEQ}; do
... ...
@@ -161,7 +161,7 @@ function _config_swift_apache_wsgi() {
161 161
             s/%APACHE_NAME%/${APACHE_NAME}/g;
162 162
             s/%USER%/${STACK_USER}/g;
163 163
         " -i ${apache_vhost_dir}/object-server-${node_number}
164
-        ! is_fedora && sudo a2ensite object-server-${node_number}
164
+        enable_apache_site object-server-${node_number}
165 165
 
166 166
         sudo cp ${SWIFT_DIR}/examples/wsgi/object-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/object-server-${node_number}.wsgi
167 167
         sudo sed -e "
... ...
@@ -177,7 +177,7 @@ function _config_swift_apache_wsgi() {
177 177
             s/%APACHE_NAME%/${APACHE_NAME}/g;
178 178
             s/%USER%/${STACK_USER}/g;
179 179
         " -i ${apache_vhost_dir}/container-server-${node_number}
180
-        ! is_fedora && sudo a2ensite container-server-${node_number}
180
+        enable_apache_site container-server-${node_number}
181 181
 
182 182
         sudo cp ${SWIFT_DIR}/examples/wsgi/container-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/container-server-${node_number}.wsgi
183 183
         sudo sed -e "
... ...
@@ -193,18 +193,14 @@ function _config_swift_apache_wsgi() {
193 193
             s/%APACHE_NAME%/${APACHE_NAME}/g;
194 194
             s/%USER%/${STACK_USER}/g;
195 195
         " -i ${apache_vhost_dir}/account-server-${node_number}
196
-        ! is_fedora && sudo a2ensite account-server-${node_number}
196
+        enable_apache_site account-server-${node_number}
197 197
 
198 198
         sudo cp ${SWIFT_DIR}/examples/wsgi/account-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/account-server-${node_number}.wsgi
199 199
         sudo sed -e "
200 200
              /^#/d;/^$/d;
201 201
             s/%SERVICECONF%/account-server\/${node_number}.conf/g;
202 202
         " -i ${SWIFT_APACHE_WSGI_DIR}/account-server-${node_number}.wsgi
203
-
204 203
     done
205
-
206
-    # WSGI isn't enabled by default, enable it
207
-    ! is_fedora && sudo a2enmod wsgi
208 204
 }
209 205
 
210 206
 # configure_swift() - Set config files, create data dirs and loop image