From d07df7b92c1ebf464428a8fce02499c3fcb21ed4 Mon Sep 17 00:00:00 2001 From: theodosisathanasakis Date: Sat, 5 Jan 2019 13:19:43 +0200 Subject: [PATCH 1/4] Supports Debian/Ubuntu, Arch, Fedora,CentOS/RHEL and OpenSUSE based distos --- install_packages.sh | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) mode change 100644 => 100755 install_packages.sh diff --git a/install_packages.sh b/install_packages.sh old mode 100644 new mode 100755 index cd6eb25d..4afdb661 --- a/install_packages.sh +++ b/install_packages.sh @@ -1,11 +1,39 @@ #!/bin/bash -# install python3 if not exist -sudo apt-get install python3 +# Determine which is the default package manager +APT=$(which apt) +PACMAN=$(which pacman) +DNF=$(which dnf) +YUM=$(which yum) +ZYPPER=$(which zypper) + +# install python3 and pip3 if not exist +if [ ${#APT} -gt 0 ]; then + sudo apt-get install python3 + sudo apt-get install python3-pip +elif [ ${#PACMAN} -gt 0 ]; then + echo bla + sudo pacman -S python3 + sudo pacman -S python3-pip +elif [ ${#DNF} -gt 0 ]; then + sudo dnf install python3 + sudo dnf install python3-pip +elif [ ${#YUM} -gt 0 ]; then + sudo yum install python3 + sudo yum install python3-pip +elif [ ${#ZYPPER} -gt 0 ]; then + sudo zypper install python3 + sudo zypper install python3-pip +else + echo "Unknown packge manager. Download one of the following:" + echo " apt, pacman, dnf, yum or zypper" + echo "" + echo "or use README.md for instructions." + exit 1 +fi + # install the all the necessery packages and requirements -sudo apt-get install python3-pip sudo pip3 install --upgrade setuptools sudo pip3 install -r requirements.txt - From 36a61ffd5748fb907040440eadaaaeb9de7091a1 Mon Sep 17 00:00:00 2001 From: theodosisathanasakis Date: Sat, 5 Jan 2019 13:22:45 +0200 Subject: [PATCH 2/4] Supports Debian/Ubuntu, Arch, Fedora, CentOS/RHEL and OpenSUSE based distos --- install_packages.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install_packages.sh b/install_packages.sh index 4afdb661..1acb29d8 100755 --- a/install_packages.sh +++ b/install_packages.sh @@ -12,7 +12,6 @@ if [ ${#APT} -gt 0 ]; then sudo apt-get install python3 sudo apt-get install python3-pip elif [ ${#PACMAN} -gt 0 ]; then - echo bla sudo pacman -S python3 sudo pacman -S python3-pip elif [ ${#DNF} -gt 0 ]; then From 4e037f6397ce719ade9b6c0e97a52e293c536c3e Mon Sep 17 00:00:00 2001 From: theodosisathanasakis Date: Sat, 5 Jan 2019 16:40:33 +0200 Subject: [PATCH 3/4] packge to package --- install_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_packages.sh b/install_packages.sh index 1acb29d8..cbcb5638 100755 --- a/install_packages.sh +++ b/install_packages.sh @@ -24,7 +24,7 @@ elif [ ${#ZYPPER} -gt 0 ]; then sudo zypper install python3 sudo zypper install python3-pip else - echo "Unknown packge manager. Download one of the following:" + echo "Unknown package manager. Download one of the following:" echo " apt, pacman, dnf, yum or zypper" echo "" echo "or use README.md for instructions." From d113991f4503919cfadde3fac022cc46db1d9d82 Mon Sep 17 00:00:00 2001 From: theodosisathanasakis Date: Sat, 5 Jan 2019 22:23:59 +0200 Subject: [PATCH 4/4] Choice between globally or locally download of dependencies --- install_packages.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/install_packages.sh b/install_packages.sh index cbcb5638..e444571f 100755 --- a/install_packages.sh +++ b/install_packages.sh @@ -31,8 +31,21 @@ else exit 1 fi - + # install the all the necessery packages and requirements -sudo pip3 install --upgrade setuptools -sudo pip3 install -r requirements.txt +echo '' +echo '' +while true; do + echo 'Do you want dependencies to be installed globally (or locally) [Y/n]?' + read ans + if [[ ${#ans} -eq 0 || $ans = "Y" || $ans = "y" ]]; then + sudo pip3 install --upgrade setuptools + sudo pip3 install -r requirements.txt + elif [[ $ans = "N" || $ans = "n" ]]; then + sudo pip3 install --user --upgrade setuptools + sudo pip3 install --user -r requirements.txt + fi + + [[ ${#ans} -eq 0 || $ans = "Y" || $ans = "y" || $ans = "N" || $ans = "n" ]] && break; +done