blob: cc5275fe45173d0823467c4d839fafaef0183b7f [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 Troyer04a35112014-08-15 14:03:52 -050020# If TOP_DIR is set we're being sourced rather than running stand-alone
21# 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 Troyer04a35112014-08-15 14:03:52 -050030 # Change dir to top of devstack
31 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# -------------------------
41# Reserve and prevent $KEYSTONE_AUTH_PORT and $KEYSTONE_AUTH_PORT_INT from
42# 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
Chmouel Boudjnah8fceb492014-10-02 20:58:20 +020050# only do the reserved ports when available, on some system (like containers)
51# where it's not exposed we are almost pretty sure these ports would be
52# exclusive for our devstack.
53if 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
62 # keystone specific ports. Duplicate reservations are merged into a single
63 # 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)
Kashyap Chamarthy7c9df102015-01-02 18:39:29 +0100112 if [[ ${DISTRO} =~ (f20) && $FORCE_FIREWALLD == "False" ]]; then
113 # On Fedora 20 firewalld interacts badly with libvirt and
Dean Troyer85ebb3a2014-08-19 10:54:59 -0500114 # slows things down significantly. However, for those cases
115 # where that combination is desired, allow this fix to be skipped.
116
117 # There was also an additional issue with firewalld hanging
118 # after install of libvirt with polkit. See
119 # https://bugzilla.redhat.com/show_bug.cgi?id=1099031
120 if is_package_installed firewalld; then
121 uninstall_package firewalld
122 fi
123 fi
124
Attila Fazekasd7967a42014-06-12 11:41:54 +0200125fi