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 | |
Jens Harbott | 8d1b20b | 2018-11-22 13:17:01 +0000 | [diff] [blame] | 29 | # Ubuntu Repositories |
| 30 | #-------------------- |
Ian Wienand | 2e66778 | 2019-11-20 10:41:34 +1100 | [diff] [blame] | 31 | # Enable universe for bionic since it is missing when installing from ISO. |
Jens Harbott | 8d1b20b | 2018-11-22 13:17:01 +0000 | [diff] [blame] | 32 | function fixup_ubuntu { |
Ian Wienand | 2e66778 | 2019-11-20 10:41:34 +1100 | [diff] [blame] | 33 | if [[ "$DISTRO" != "bionic" ]]; then |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 34 | return |
| 35 | fi |
| 36 | |
Clark Boylan | c9a9e41 | 2017-03-29 10:28:55 -0700 | [diff] [blame] | 37 | # This pulls in apt-add-repository |
| 38 | install_package "software-properties-common" |
Jens Harbott | 8d1b20b | 2018-11-22 13:17:01 +0000 | [diff] [blame] | 39 | |
| 40 | # Enable universe |
| 41 | sudo add-apt-repository -y universe |
Dr. Jens Harbott | e18325c | 2020-01-22 05:54:06 +0000 | [diff] [blame] | 42 | |
| 43 | # Since pip10, pip will refuse to uninstall files from packages |
| 44 | # that were created with distutils (rather than more modern |
| 45 | # setuptools). This is because it technically doesn't have a |
| 46 | # manifest of what to remove. However, in most cases, simply |
| 47 | # overwriting works. So this hacks around those packages that |
| 48 | # have been dragged in by some other system dependency |
Carlos Camacho | 7611d3d | 2020-01-30 14:39:51 +0100 | [diff] [blame] | 49 | sudo rm -rf /usr/lib/python3/dist-packages/httplib2-*.egg-info |
| 50 | sudo rm -rf /usr/lib/python3/dist-packages/pyasn1_modules-*.egg-info |
| 51 | sudo rm -rf /usr/lib/python3/dist-packages/PyYAML-*.egg-info |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 52 | } |
Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 53 | |
| 54 | # Python Packages |
| 55 | # --------------- |
| 56 | |
Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 57 | # get_package_path python-package # in import notation |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 58 | function get_package_path { |
Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 59 | local package=$1 |
| 60 | echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])") |
| 61 | } |
| 62 | |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 63 | function fixup_fedora { |
| 64 | if ! is_fedora; then |
| 65 | return |
| 66 | fi |
Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 67 | # Disable selinux to avoid configuring to allow Apache access |
Gonéri Le Bouder | 394c11c | 2013-11-05 10:35:55 +0100 | [diff] [blame] | 68 | # to Horizon files (LP#1175444) |
Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 69 | if selinuxenabled; then |
| 70 | sudo setenforce 0 |
| 71 | fi |
Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 72 | |
Ian Wienand | e82bac0 | 2015-08-25 14:29:08 +1000 | [diff] [blame] | 73 | FORCE_FIREWALLD=$(trueorfalse False FORCE_FIREWALLD) |
Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 74 | if [[ $FORCE_FIREWALLD == "False" ]]; then |
Kashyap Chamarthy | 7c9df10 | 2015-01-02 18:39:29 +0100 | [diff] [blame] | 75 | # On Fedora 20 firewalld interacts badly with libvirt and |
Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 76 | # slows things down significantly (this issue was fixed in |
| 77 | # later fedoras). There was also an additional issue with |
| 78 | # firewalld hanging after install of libvirt with polkit [1]. |
| 79 | # firewalld also causes problems with neturon+ipv6 [2] |
| 80 | # |
| 81 | # Note we do the same as the RDO packages and stop & disable, |
| 82 | # rather than remove. This is because other packages might |
| 83 | # have the dependency [3][4]. |
| 84 | # |
| 85 | # [1] https://bugzilla.redhat.com/show_bug.cgi?id=1099031 |
| 86 | # [2] https://bugs.launchpad.net/neutron/+bug/1455303 |
| 87 | # [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] | 88 | # [4] https://docs.openstack.org/devstack/latest/guides/neutron.html |
Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 89 | if is_package_installed firewalld; then |
Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 90 | sudo systemctl disable firewalld |
Ben Nemec | 64b2ebc | 2015-06-05 12:22:36 -0500 | [diff] [blame] | 91 | # The iptables service files are no longer included by default, |
| 92 | # at least on a baremetal Fedora 21 Server install. |
| 93 | install_package iptables-services |
Ian Wienand | 3380a16 | 2015-05-15 13:12:02 +1000 | [diff] [blame] | 94 | sudo systemctl enable iptables |
| 95 | sudo systemctl stop firewalld |
| 96 | sudo systemctl start iptables |
Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 97 | fi |
| 98 | fi |
Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 99 | |
Kashyap Chamarthy | 90bc586 | 2015-12-01 18:04:40 +0100 | [diff] [blame] | 100 | if [[ "$os_VENDOR" == "Fedora" ]] && [[ "$os_RELEASE" -ge "22" ]]; then |
Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 101 | # requests ships vendored version of chardet/urllib3, but on |
| 102 | # fedora these are symlinked back to the primary versions to |
| 103 | # avoid duplication of code on disk. This is fine when |
| 104 | # maintainers keep things in sync, but since devstack takes |
| 105 | # over and installs later versions via pip we can end up with |
| 106 | # incompatible versions. |
| 107 | # |
| 108 | # The rpm package is not removed to preserve the dependent |
| 109 | # packages like cloud-init; rather we remove the symlinks and |
| 110 | # force a re-install of requests so the vendored versions it |
| 111 | # wants are present. |
| 112 | # |
| 113 | # Realted issues: |
| 114 | # https://bugs.launchpad.net/glance/+bug/1476770 |
| 115 | # https://bugzilla.redhat.com/show_bug.cgi?id=1253823 |
| 116 | |
Mark Hamzy | 746e72d | 2015-10-14 13:42:18 -0500 | [diff] [blame] | 117 | base_path=$(get_package_path requests)/packages |
Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 118 | if [ -L $base_path/chardet -o -L $base_path/urllib3 ]; then |
Mark Hamzy | 746e72d | 2015-10-14 13:42:18 -0500 | [diff] [blame] | 119 | sudo rm -f $base_path/{chardet,urllib3} |
Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 120 | # install requests with the bundled urllib3 to avoid conflicts |
| 121 | pip_install --upgrade --force-reinstall requests |
| 122 | fi |
Ian Wienand | f0dc93d | 2018-04-20 10:42:07 +1000 | [diff] [blame] | 123 | |
Attila Fazekas | c7e772c | 2015-09-01 15:18:57 +0200 | [diff] [blame] | 124 | fi |
Ian Wienand | f0dc93d | 2018-04-20 10:42:07 +1000 | [diff] [blame] | 125 | |
| 126 | # Since pip10, pip will refuse to uninstall files from packages |
| 127 | # that were created with distutils (rather than more modern |
| 128 | # setuptools). This is because it technically doesn't have a |
| 129 | # manifest of what to remove. However, in most cases, simply |
| 130 | # overwriting works. So this hacks around those packages that |
| 131 | # have been dragged in by some other system dependency |
| 132 | sudo rm -rf /usr/lib/python2.7/site-packages/enum34*.egg-info |
| 133 | sudo rm -rf /usr/lib/python2.7/site-packages/ipaddress*.egg-info |
| 134 | sudo rm -rf /usr/lib/python2.7/site-packages/ply-*.egg-info |
| 135 | sudo rm -rf /usr/lib/python2.7/site-packages/typing-*.egg-info |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 136 | } |
Vigneshvar.A.S | 834b804 | 2015-02-14 01:05:55 +0530 | [diff] [blame] | 137 | |
aojeagarcia | eb7d1ad | 2018-09-24 10:17:16 +0200 | [diff] [blame] | 138 | function fixup_suse { |
| 139 | if ! is_suse; then |
| 140 | return |
| 141 | fi |
| 142 | |
Adam Spiers | 6c7337e | 2019-08-07 14:34:56 +0100 | [diff] [blame] | 143 | # Deactivate and disable apparmor profiles in openSUSE and SLE |
| 144 | # distros to avoid issues with haproxy and dnsmasq. In newer |
| 145 | # releases, systemctl stop apparmor is actually a no-op, so we |
| 146 | # have to use aa-teardown to make sure we've deactivated the |
| 147 | # profiles: |
| 148 | # |
| 149 | # https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15/#fate-325343 |
| 150 | # https://gitlab.com/apparmor/apparmor/merge_requests/81 |
| 151 | # https://build.opensuse.org/package/view_file/openSUSE:Leap:15.2/apparmor/apparmor.service?expand=1 |
| 152 | if sudo systemctl is-active -q apparmor; then |
| 153 | sudo systemctl stop apparmor |
| 154 | fi |
| 155 | if [ -x /usr/sbin/aa-teardown ]; then |
aojeagarcia | eb7d1ad | 2018-09-24 10:17:16 +0200 | [diff] [blame] | 156 | sudo /usr/sbin/aa-teardown |
| 157 | fi |
Adam Spiers | 6c7337e | 2019-08-07 14:34:56 +0100 | [diff] [blame] | 158 | if sudo systemctl is-enabled -q apparmor; then |
| 159 | sudo systemctl disable apparmor |
| 160 | fi |
Colleen Murphy | 10f4409 | 2019-02-28 23:44:14 +0100 | [diff] [blame] | 161 | |
| 162 | # Since pip10, pip will refuse to uninstall files from packages |
| 163 | # that were created with distutils (rather than more modern |
| 164 | # setuptools). This is because it technically doesn't have a |
| 165 | # manifest of what to remove. However, in most cases, simply |
| 166 | # overwriting works. So this hacks around those packages that |
| 167 | # have been dragged in by some other system dependency |
| 168 | sudo rm -rf /usr/lib/python3.6/site-packages/ply-*.egg-info |
Colleen Murphy | 6eb2c59 | 2019-09-25 12:51:23 -0700 | [diff] [blame] | 169 | sudo rm -rf /usr/lib/python3.6/site-packages/six-*.egg-info |
Colleen Murphy | 497caf0 | 2020-04-03 10:14:07 -0700 | [diff] [blame] | 170 | |
| 171 | # Ensure trusted CA certificates are up to date |
| 172 | # See https://bugzilla.suse.com/show_bug.cgi?id=1154871 |
| 173 | # May be removed once a new opensuse-15 image is available in nodepool |
| 174 | sudo zypper up -y p11-kit ca-certificates-mozilla |
aojeagarcia | eb7d1ad | 2018-09-24 10:17:16 +0200 | [diff] [blame] | 175 | } |
| 176 | |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 177 | function fixup_all { |
Jens Harbott | 8d1b20b | 2018-11-22 13:17:01 +0000 | [diff] [blame] | 178 | fixup_ubuntu |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 179 | fixup_fedora |
aojeagarcia | eb7d1ad | 2018-09-24 10:17:16 +0200 | [diff] [blame] | 180 | fixup_suse |
IWAMOTO Toshihiro | 4d835e3 | 2018-02-05 16:57:41 +0900 | [diff] [blame] | 181 | } |