pastafari2/scripts/system/install_python.sh
2022-10-26 12:57:06 +02:00

76 lines
1.6 KiB
Bash

#!/bin/bash
sleep 1
echo '{"error": 0, "status": 0, "progress": 0, "no_progress":0, "message": "Installing Python..."}'
sleep 1
# Get distro version using lsb_release
DISTRO=`( lsb_release -ds || cat /etc/*release || uname -om ) 2>/dev/null | head -n1`
if [[ $DISTRO =~ ^Debian ]]; then
sudo apt-get update
sudo apt-get -y install python3 python3-pip
elif [[ $DISTRO =~ ^NAME=\"Arch ]]; then
sudo pacman -Syu --noconfirm python python-pip
elif [[ $DISTRO =~ ^NAME=\"Rocky ]]; then
sudo dnf install -y python python-pip
#Install EPEL
dnf config-manager --set-enabled crb
sudo dnf install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
sudo dnf upgrade -y
else
echo "Sorry, Linux distro not supported"
exit 1;
fi
if [ $? -eq 0 ]; then
#echo "Installed python3 sucessfully if not error..."
echo '{"error": 0, "status": 0, "progress": 100, "no_progress":0, "message": "Installed python sucessfully..."}'
sleep 1
else
echo "Sorry, cannot install python..."
exit 1;
fi
echo '{"error": 0, "status": 0, "progress": 0, "no_progress":0, "message": "Installing distro package for python and detect distribution..."}'
sleep 1
sudo pip3 install distro
if [ $? -eq 0 ]; then
#echo "Installed python3 sucessfully if not error..."
echo '{"error": 0, "status": 0, "progress": 100, "no_progress":0, "message": "Installed distro python package sucessfully..."}'
sleep 1
else
echo "Sorry, cannot install distro python package..."
exit 1;
fi
sleep 1