mangle-shebangs.sh 689 Bytes
Newer Older
Max Beckett's avatar
Max Beckett committed
1
2
#!/bin/bash

3
RPM_SYSTEM_RELEASE_PATH=/etc/system-release
4
5
RHEL8_REGEX="Red Hat Enterprise Linux release 8"
FEDORA_REGEX="Fedora release"
Jurgen Verhasselt's avatar
Jurgen Verhasselt committed
6
CENTOS8_REGEX="CentOS Linux release 8"
Max Beckett's avatar
Max Beckett committed
7

Jurgen Verhasselt's avatar
Jurgen Verhasselt committed
8
# RHEL8, Fedora30+ and CentOS8 treat shebangs of the form "#!/usr/bin/env python" as errors
9
10
11
12
13
14
if [ -f $RPM_SYSTEM_RELEASE_PATH ] && [[ "$(cat $RPM_SYSTEM_RELEASE_PATH)" =~ $RHEL8_REGEX|$FEDORA_REGEX|$CENTOS8_REGEX ]]; then
    echo 'Correcting python executable'
    # Replace the first line in .py to "#!/usr/bin/env python3" no matter what it was before
    sed -i -e '1 s/^.*$/\#!\/usr\/bin\/env python3/' src/watchdog/__init__.py
    sed -i -e '1 s/^.*$/\#!\/usr\/bin\/env python3/' src/mount_efs/__init__.py
fi