blob: a601cf2f67b221b738a2eda6f8e7cafbaa8fd614 [file] [log] [blame]
Dean Troyer9acc12a2013-08-09 15:09:31 -05001#!/usr/bin/env bash
2
3# **fixup_stuff.sh**
4
5# fixup_stuff.sh
6#
7# All distro and package specific hacks go in here
Adam Spierscb961592013-10-05 12:11:07 +01008#
Dean Troyer9acc12a2013-08-09 15:09:31 -05009# - prettytable 0.7.2 permissions are 600 in the package and
10# pip 1.4 doesn't fix it (1.3 did)
Adam Spierscb961592013-10-05 12:11:07 +010011#
Dean Troyer9acc12a2013-08-09 15:09:31 -050012# - httplib2 0.8 permissions are 600 in the package and
13# pip 1.4 doesn't fix it (1.3 did)
Adam Spierscb961592013-10-05 12:11:07 +010014#
Attila Fazekas1f316be2015-01-26 16:39:57 +010015# - Fedora:
Dean Troyer49ba2242013-08-09 19:51:20 -050016# - set selinux not enforcing
Attila Fazekas1f316be2015-01-26 16:39:57 +010017# - uninstall firewalld (f20 only)
18
Dean Troyer49ba2242013-08-09 19:51:20 -050019
Dean Troyerdc97cb72015-03-28 08:20:50 -050020# If ``TOP_DIR`` is set we're being sourced rather than running stand-alone
Dean Troyer04a35112014-08-15 14:03:52 -050021# or in a sub-shell
22if [[ -z "$TOP_DIR" ]]; then
23 set -o errexit
24 set -o xtrace
Dean Troyer9acc12a2013-08-09 15:09:31 -050025
Dean Troyer04a35112014-08-15 14:03:52 -050026 # Keep track of the current directory
27 TOOLS_DIR=$(cd $(dirname "$0") && pwd)
28 TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
Dean Troyer9acc12a2013-08-09 15:09:31 -050029
Dean Troyerdc97cb72015-03-28 08:20:50 -050030 # Change dir to top of DevStack
Dean Troyer04a35112014-08-15 14:03:52 -050031 cd $TOP_DIR
Dean Troyer9acc12a2013-08-09 15:09:31 -050032
Dean Troyer04a35112014-08-15 14:03:52 -050033 # Import common functions
34 source $TOP_DIR/functions
Dean Troyer9acc12a2013-08-09 15:09:31 -050035
Dean Troyer04a35112014-08-15 14:03:52 -050036 FILES=$TOP_DIR/files
37fi
Dean Troyer9acc12a2013-08-09 15:09:31 -050038
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070039# Keystone Port Reservation
40# -------------------------
Dean Troyerdc97cb72015-03-28 08:20:50 -050041# Reserve and prevent ``KEYSTONE_AUTH_PORT`` and ``KEYSTONE_AUTH_PORT_INT`` from
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070042# being used as ephemeral ports by the system. The default(s) are 35357 and
43# 35358 which are in the Linux defined ephemeral port range (in disagreement
44# with the IANA ephemeral port range). This is a workaround for bug #1253482
45# where Keystone will try and bind to the port and the port will already be
46# in use as an ephemeral port by another process. This places an explicit
47# exception into the Kernel for the Keystone AUTH ports.
48keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358}
49
Dean Troyerdc97cb72015-03-28 08:20:50 -050050# Only do the reserved ports when available, on some system (like containers)
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020051# where it's not exposed we are almost pretty sure these ports would be
Dean Troyerdc97cb72015-03-28 08:20:50 -050052# exclusive for our DevStack.
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020053if sysctl net.ipv4.ip_local_reserved_ports >/dev/null 2>&1; then
54 # Get any currently reserved ports, strip off leading whitespace
55 reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //')
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070056
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020057 if [[ -z "${reserved_ports}" ]]; then
58 # If there are no currently reserved ports, reserve the keystone ports
59 sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports}
60 else
61 # If there are currently reserved ports, keep those and also reserve the
Dean Troyerdc97cb72015-03-28 08:20:50 -050062 # Keystone specific ports. Duplicate reservations are merged into a single
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020063 # reservation (or range) automatically by the kernel.
64 sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports}
65 fi
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070066else
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020067 echo_summary "WARNING: unable to reserve keystone ports"
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070068fi
69
Dean Troyer49ba2242013-08-09 19:51:20 -050070
71# Python Packages
72# ---------------
73
Dean Troyer65f1af62013-10-16 12:10:13 -050074# get_package_path python-package # in import notation
Ian Wienandaee18c72014-02-21 15:35:08 +110075function get_package_path {
Dean Troyer65f1af62013-10-16 12:10:13 -050076 local package=$1
77 echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])")
78}
79
80
Dean Troyer9acc12a2013-08-09 15:09:31 -050081# Pre-install affected packages so we can fix the permissions
Dean Troyer65f1af62013-10-16 12:10:13 -050082# These can go away once we are confident that pip 1.4.1+ is available everywhere
83
84# Fix prettytable 0.7.2 permissions
85# Don't specify --upgrade so we use the existing package if present
Jeremy Stanley6ec66bb2014-12-22 17:17:51 +000086pip_install 'prettytable>=0.7'
Dean Troyer65f1af62013-10-16 12:10:13 -050087PACKAGE_DIR=$(get_package_path prettytable)
88# Only fix version 0.7.2
89dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*)
90if [[ -d $dir ]]; then
91 sudo chmod +r $dir/*
92fi
93
94# Fix httplib2 0.8 permissions
95# Don't specify --upgrade so we use the existing package if present
Aaron Rosen1e4551d2013-09-16 13:58:08 -070096pip_install httplib2
Dean Troyer65f1af62013-10-16 12:10:13 -050097PACKAGE_DIR=$(get_package_path httplib2)
98# Only fix version 0.8
99dir=$(echo $PACKAGE_DIR-0.8*)
100if [[ -d $dir ]]; then
101 sudo chmod +r $dir/*
102fi
Dean Troyer49ba2242013-08-09 19:51:20 -0500103
Attila Fazekasd7967a42014-06-12 11:41:54 +0200104if is_fedora; then
Dean Troyer49ba2242013-08-09 19:51:20 -0500105 # Disable selinux to avoid configuring to allow Apache access
Gonéri Le Bouder394c11c2013-11-05 10:35:55 +0100106 # to Horizon files (LP#1175444)
Dean Troyer49ba2242013-08-09 19:51:20 -0500107 if selinuxenabled; then
108 sudo setenforce 0
109 fi
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500110
111 FORCE_FIREWALLD=$(trueorfalse False $FORCE_FIREWALLD)
Ian Wienand3380a162015-05-15 13:12:02 +1000112 if [[ $FORCE_FIREWALLD == "False" ]]; then
Kashyap Chamarthy7c9df102015-01-02 18:39:29 +0100113 # On Fedora 20 firewalld interacts badly with libvirt and
Ian Wienand3380a162015-05-15 13:12:02 +1000114 # slows things down significantly (this issue was fixed in
115 # later fedoras). There was also an additional issue with
116 # firewalld hanging after install of libvirt with polkit [1].
117 # firewalld also causes problems with neturon+ipv6 [2]
118 #
119 # Note we do the same as the RDO packages and stop & disable,
120 # rather than remove. This is because other packages might
121 # have the dependency [3][4].
122 #
123 # [1] https://bugzilla.redhat.com/show_bug.cgi?id=1099031
124 # [2] https://bugs.launchpad.net/neutron/+bug/1455303
125 # [3] https://github.com/redhat-openstack/openstack-puppet-modules/blob/master/firewall/manifests/linux/redhat.pp
126 # [4] http://docs.openstack.org/developer/devstack/guides/neutron.html
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500127 if is_package_installed firewalld; then
Ian Wienand3380a162015-05-15 13:12:02 +1000128 sudo systemctl disable firewalld
Ben Nemec64b2ebc2015-06-05 12:22:36 -0500129 # The iptables service files are no longer included by default,
130 # at least on a baremetal Fedora 21 Server install.
131 install_package iptables-services
Ian Wienand3380a162015-05-15 13:12:02 +1000132 sudo systemctl enable iptables
133 sudo systemctl stop firewalld
134 sudo systemctl start iptables
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500135 fi
136 fi
Attila Fazekasc7e772c2015-09-01 15:18:57 +0200137
138 if [[ "$os_RELEASE" -ge "21" ]]; then
139 # requests ships vendored version of chardet/urllib3, but on
140 # fedora these are symlinked back to the primary versions to
141 # avoid duplication of code on disk. This is fine when
142 # maintainers keep things in sync, but since devstack takes
143 # over and installs later versions via pip we can end up with
144 # incompatible versions.
145 #
146 # The rpm package is not removed to preserve the dependent
147 # packages like cloud-init; rather we remove the symlinks and
148 # force a re-install of requests so the vendored versions it
149 # wants are present.
150 #
151 # Realted issues:
152 # https://bugs.launchpad.net/glance/+bug/1476770
153 # https://bugzilla.redhat.com/show_bug.cgi?id=1253823
154
155 base_path=/usr/lib/python2.7/site-packages/requests/packages
156 if [ -L $base_path/chardet -o -L $base_path/urllib3 ]; then
157 sudo rm -f /usr/lib/python2.7/site-packages/requests/packages/{chardet,urllib3}
158 # install requests with the bundled urllib3 to avoid conflicts
159 pip_install --upgrade --force-reinstall requests
160 fi
161 fi
Attila Fazekasd7967a42014-06-12 11:41:54 +0200162fi
Vigneshvar.A.S834b8042015-02-14 01:05:55 +0530163
164# The version of pip(1.5.4) supported by python-virtualenv(1.11.4) has
165# connection issues under proxy, hence uninstalling python-virtualenv package
166# and installing the latest version using pip.
167uninstall_package python-virtualenv
168pip_install -U virtualenv