install python 3.8 based on OS

#!/bin/bash

DISTRO=$(cat /etc/*-release | grep -w NAME | cut -d= -f2 | tr -d '"' | tr '[:upper:]' '[:lower:]')

if [[ "$DISTRO" =~ "centos linux" ]]; then
  echo "centos is detected"
  sudo yum install -yq python38
elif [[ "$DISTRO" =~ "amazon linux" ]]; then
  echo "amazon linux detected"
  sudo yum install -yq amazon-linux-extras
  sudo amazon-linux-extras enable python3.8
  sudo yum install -yq python3.8
elif [[ "$DISTRO" =~ "ubuntu" ]]; then
  echo "ubuntu detected"
  sudo apt install pyhton3 -yq
else
  echo "Neither centos nor amazon linux 2"
fi

Leave a comment

Blog at WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started