Skip to content

Commit

Permalink
Fail early if eatmydata is not installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardomurri committed May 7, 2019
1 parent 74479fe commit 031fc62
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions elasticluster/share/playbooks/files/install-py2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ if ! [ -x "$python" ]; then
apt-get update
do_or_die apt-get install -y python2.7 python-simplejson
;;
[Rr]ed[Hh]at)
[Rr]ed[Hh]at|[Cc]entos)
case "$ver" in
7*) do_or_die yum install -y python2 python2-simplejson ;;
6*) do_or_die yum install -y python2 python-simplejson ;;
Expand All @@ -156,12 +156,18 @@ fi
# eatmydata support
real_python=$(expr "$python" : '\(.*\)+eatmydata')
if [ -n "$real_python" ]; then
use_eatmydata=yes
else
real_python="$python"
fi

if [ "$use_eatmydata" = 'yes' ]; then
# install `libeatmydata.so` and the `eatmydata` command
case "$os" in
[Dd]ebian|[Uu]buntu)
apt-get install -y eatmydata
;;
[Rr]ed[Hh]at)
[Rr]ed[Hh]at|[Cc]entos)
case "$ver" in
7*)
sudo yum install -y yum-plugin-copr
Expand Down Expand Up @@ -195,14 +201,17 @@ __EOF__
exec /usr/bin/eatmydata -- '$real_python' "\$@"
__EOF__
chmod a+rx "$python"
else
real_python="$python"
fi

# cross check that Python exists
if ! test -x "$real_python"; then
die $EX_SOFTWARE "Python interpreter '$real_python' not found, even after installation. Aborting."
fi
if [ "$use_eatmydata" = 'yes' ]; then
if ! test -x /usr/bin/eatmydata; then
die $EX_SOFTWARE "Binary wrapper '/usr/bin/eatmydata' not found, even after installation. Aborting."
fi
fi

# output Python version and exit successfully
echo "Displaying installed Python version ..."
Expand Down

0 comments on commit 031fc62

Please sign in to comment.