Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 1 | #!/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 |
Attila Fazekas | 1f316be | 2015-01-26 16:39:57 +0100 | [diff] [blame] | 8 | |
Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 9 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 10 | # If ``TOP_DIR`` is set we're being sourced rather than running stand-alone |
Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 11 | # or in a sub-shell |
| 12 | if [[ -z "$TOP_DIR" ]]; then |
| 13 | set -o errexit |
| 14 | set -o xtrace |
Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 15 | |
Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 16 | # Keep track of the current directory |
| 17 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) |
| 18 | TOP_DIR=$(cd $TOOLS_DIR/..; pwd) |
Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 19 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 20 | # Change dir to top of DevStack |
Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 21 | cd $TOP_DIR |
Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 22 | |
Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 23 | # Import common functions |
| 24 | source $TOP_DIR/functions |
Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 25 | |
Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 26 | FILES=$TOP_DIR/files |
| 27 | fi |
Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 28 | |
Abhishek Kekane | f8dbfd3 | 2020-07-06 18:42:30 +0000 | [diff] [blame] | 29 | # Keystone Port Reservation |
| 30 | # ------------------------- |
| 31 | # Reserve and prevent ``KEYSTONE_AUTH_PORT`` and ``KEYSTONE_AUTH_PORT_INT`` from |
| 32 | # being used as ephemeral ports by the system. The default(s) are 35357 and |
| 33 | # 35358 which are in the Linux defined ephemeral port range (in disagreement |
| 34 | # with the IANA ephemeral port range). This is a workaround for bug #1253482 |
| 35 | # where Keystone will try and bind to the port and the port will already be |
| 36 | # in use as an ephemeral port by another process. This places an explicit |
| 37 | # exception into the Kernel for the Keystone AUTH ports. |
| 38 | function fixup_keystone { |
| 39 | keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358} |
| 40 | |
| 41 | # Only do the reserved ports when available, on some system (like containers) |
| 42 | # where it's not exposed we are almost pretty sure these ports would be |
| 43 | # exclusive for our DevStack. |
| 44 | if sysctl net.ipv4.ip_local_reserved_ports >/dev/null 2>&1; then |
| 45 | # Get any currently reserved ports, strip off leading whitespace |
| 46 | reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //') |
| 47 | |
| 48 | if [[ -z "${reserved_ports}" ]]; then |
| 49 | # If there are no currently reserved ports, reserve the keystone ports |
| 50 | sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports} |
| 51 | else |
| 52 | # If there are currently reserved ports, keep those and also reserve the |
| 53 | # Keystone specific ports. Duplicate reservations are merged into a single |
| 54 | # reservation (or range) automatically by the kernel. |
| 55 | sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports} |
| 56 | fi |
| 57 | else |
| 58 | echo_summary "WARNING: unable to reserve keystone ports" |
| 59 | fi |
| 60 | } |
| 61 | |
Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 62 | # Python Packages |
| 63 | # --------------- |
| 64 | |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 65 | function fixup_fedora { |
| 66 | if ! is_fedora; then |
| 67 | return |
| 68 | fi |
Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 69 | # Disable selinux to avoid configuring to allow Apache access |
Gonéri Le Bouder | 394c11c | 2013-11-05 10:35:55 +0100 | [diff] [blame] | 70 | # to Horizon files (LP#1175444) |
Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 71 | if selinuxenabled; then |
| 72 | sudo setenforce 0 |
| 73 | fi |
Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 74 | |
Ian Wienand | e82bac0 | 2015-08-25 14:29:08 +1000 | [diff] [blame] | 75 | FORCE_FIREWALLD=$(trueorfalse False FORCE_FIREWALLD) |
Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 76 | if [[ $FORCE_FIREWALLD == "False" ]]; then |
Kashyap Chamarthy | 7c9df10 | 2015-01-02 18:39:29 +0100 | [diff] [blame] | 77 | # On Fedora 20 firewalld interacts badly with libvirt and |
Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 78 | # slows things down significantly (this issue was fixed in |
| 79 | # later fedoras). There was also an additional issue with |
| 80 | # firewalld hanging after install of libvirt with polkit [1]. |
| 81 | # firewalld also causes problems with neturon+ipv6 [2] |
| 82 | # |
| 83 | # Note we do the same as the RDO packages and stop & disable, |
| 84 | # rather than remove. This is because other packages might |
| 85 | # have the dependency [3][4]. |
| 86 | # |
| 87 | # [1] https://bugzilla.redhat.com/show_bug.cgi?id=1099031 |
| 88 | # [2] https://bugs.launchpad.net/neutron/+bug/1455303 |
| 89 | # [3] https://github.com/redhat-openstack/openstack-puppet-modules/blob/master/firewall/manifests/linux/redhat.pp |
Takashi NATSUME | fa00777 | 2017-07-22 08:59:43 +0900 | [diff] [blame] | 90 | # [4] https://docs.openstack.org/devstack/latest/guides/neutron.html |
Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 91 | if is_package_installed firewalld; then |
Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 92 | sudo systemctl disable firewalld |
Ben Nemec | 64b2ebc | 2015-06-05 12:22:36 -0500 | [diff] [blame] | 93 | # The iptables service files are no longer included by default, |
| 94 | # at least on a baremetal Fedora 21 Server install. |
| 95 | install_package iptables-services |
Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 96 | sudo systemctl enable iptables |
| 97 | sudo systemctl stop firewalld |
| 98 | sudo systemctl start iptables |
Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 99 | fi |
| 100 | fi |
Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 101 | |
Ian Wienand | f0dc93d | 2018-04-20 10:42:07 +1000 | [diff] [blame] | 102 | # Since pip10, pip will refuse to uninstall files from packages |
| 103 | # that were created with distutils (rather than more modern |
| 104 | # setuptools). This is because it technically doesn't have a |
| 105 | # manifest of what to remove. However, in most cases, simply |
| 106 | # overwriting works. So this hacks around those packages that |
| 107 | # have been dragged in by some other system dependency |
Carlos Goncalves | b9fe9c7 | 2020-08-20 14:42:55 +0200 | [diff] [blame] | 108 | sudo rm -rf /usr/lib64/python3*/site-packages/PyYAML-*.egg-info |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 109 | } |
Vigneshvar.A.S | 834b804 | 2015-02-14 01:05:55 +0530 | [diff] [blame] | 110 | |
aojeagarcia | eb7d1ad | 2018-09-24 10:17:16 +0200 | [diff] [blame] | 111 | function fixup_suse { |
| 112 | if ! is_suse; then |
| 113 | return |
| 114 | fi |
| 115 | |
Adam Spiers | 6c7337e | 2019-08-07 14:34:56 +0100 | [diff] [blame] | 116 | # Deactivate and disable apparmor profiles in openSUSE and SLE |
| 117 | # distros to avoid issues with haproxy and dnsmasq. In newer |
| 118 | # releases, systemctl stop apparmor is actually a no-op, so we |
| 119 | # have to use aa-teardown to make sure we've deactivated the |
| 120 | # profiles: |
| 121 | # |
| 122 | # https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15/#fate-325343 |
| 123 | # https://gitlab.com/apparmor/apparmor/merge_requests/81 |
| 124 | # https://build.opensuse.org/package/view_file/openSUSE:Leap:15.2/apparmor/apparmor.service?expand=1 |
| 125 | if sudo systemctl is-active -q apparmor; then |
| 126 | sudo systemctl stop apparmor |
| 127 | fi |
| 128 | if [ -x /usr/sbin/aa-teardown ]; then |
aojeagarcia | eb7d1ad | 2018-09-24 10:17:16 +0200 | [diff] [blame] | 129 | sudo /usr/sbin/aa-teardown |
| 130 | fi |
Adam Spiers | 6c7337e | 2019-08-07 14:34:56 +0100 | [diff] [blame] | 131 | if sudo systemctl is-enabled -q apparmor; then |
| 132 | sudo systemctl disable apparmor |
| 133 | fi |
Colleen Murphy | 10f4409 | 2019-02-28 23:44:14 +0100 | [diff] [blame] | 134 | |
| 135 | # Since pip10, pip will refuse to uninstall files from packages |
| 136 | # that were created with distutils (rather than more modern |
| 137 | # setuptools). This is because it technically doesn't have a |
| 138 | # manifest of what to remove. However, in most cases, simply |
| 139 | # overwriting works. So this hacks around those packages that |
| 140 | # have been dragged in by some other system dependency |
| 141 | sudo rm -rf /usr/lib/python3.6/site-packages/ply-*.egg-info |
Colleen Murphy | 6eb2c59 | 2019-09-25 12:51:23 -0700 | [diff] [blame] | 142 | sudo rm -rf /usr/lib/python3.6/site-packages/six-*.egg-info |
Colleen Murphy | 497caf0 | 2020-04-03 10:14:07 -0700 | [diff] [blame] | 143 | |
| 144 | # Ensure trusted CA certificates are up to date |
| 145 | # See https://bugzilla.suse.com/show_bug.cgi?id=1154871 |
| 146 | # May be removed once a new opensuse-15 image is available in nodepool |
| 147 | sudo zypper up -y p11-kit ca-certificates-mozilla |
aojeagarcia | eb7d1ad | 2018-09-24 10:17:16 +0200 | [diff] [blame] | 148 | } |
| 149 | |
Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 150 | function fixup_ovn_centos { |
| 151 | if [[ $os_VENDOR != "CentOS" ]]; then |
| 152 | return |
| 153 | fi |
| 154 | # OVN packages are part of this release for CentOS |
| 155 | yum_install centos-release-openstack-victoria |
| 156 | } |
| 157 | |
Ian Wienand | 6b9a564 | 2021-07-28 11:19:57 +1000 | [diff] [blame^] | 158 | function fixup_ubuntu { |
| 159 | if ! is_ubuntu; then |
| 160 | return |
| 161 | fi |
| 162 | |
| 163 | # Since pip10, pip will refuse to uninstall files from packages |
| 164 | # that were created with distutils (rather than more modern |
| 165 | # setuptools). This is because it technically doesn't have a |
| 166 | # manifest of what to remove. However, in most cases, simply |
| 167 | # overwriting works. So this hacks around those packages that |
| 168 | # have been dragged in by some other system dependency |
| 169 | sudo rm -rf /usr/lib/python3/dist-packages/PyYAML-*.egg-info |
| 170 | } |
| 171 | |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 172 | function fixup_all { |
Abhishek Kekane | f8dbfd3 | 2020-07-06 18:42:30 +0000 | [diff] [blame] | 173 | fixup_keystone |
Ian Wienand | 6b9a564 | 2021-07-28 11:19:57 +1000 | [diff] [blame^] | 174 | fixup_ubuntu |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 175 | fixup_fedora |
aojeagarcia | eb7d1ad | 2018-09-24 10:17:16 +0200 | [diff] [blame] | 176 | fixup_suse |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 177 | } |