From d5a8758ad824ef3b17ea9950b174f6bb4d8e8c08 Mon Sep 17 00:00:00 2001 From: "Fabio C. Barrioneuvo da Luz" Date: Wed, 8 Jun 2016 00:11:08 -0300 Subject: [PATCH] improve install_os_dependencies.sh --- .../utility/install_os_dependencies.sh | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/{{cookiecutter.project_slug}}/utility/install_os_dependencies.sh b/{{cookiecutter.project_slug}}/utility/install_os_dependencies.sh index cc1fb2f07..39ce41745 100755 --- a/{{cookiecutter.project_slug}}/utility/install_os_dependencies.sh +++ b/{{cookiecutter.project_slug}}/utility/install_os_dependencies.sh @@ -1,14 +1,17 @@ #!/bin/bash WORK_DIR="$(dirname "$0")" -OS_REQUIREMENTS_FILENAME="$WORK_DIR/requirements.apt" +DISTRO_NAME=$(lsb_release -sc) -VER=$(lsb_release -sr) -if [ "$VER" == "16.04" ]; then - OS_REQUIREMENTS_FILENAME="requirements.apt.xenial" -else - OS_REQUIREMENTS_FILENAME="requirements.apt" +OS_REQUIREMENTS_FILENAME="$WORK_DIR/requirements-$DISTRO_NAME.apt" + + +if [ "$DISTRO_NAME" != "xenial" ] && [ "$DISTRO_NAME" != "trusty" ]; then + echo "Only the Ubuntu 14.04 (Trusty) and 16.04 (Xenial) is supported by this script"; + echo "You can see requirements-trusty.apt or requirements-xenial.apt file to help search the equivalent package in your system"; + exit 1; fi + # Handle call with wrong command function wrong_command() { @@ -31,7 +34,7 @@ function usage_message() # Read the requirements.apt file, and remove comments and blank lines function list_packages(){ - grep -v "#" ${OS_REQUIREMENTS_FILENAME} | grep -v "^$"; + grep -v "#" "${OS_REQUIREMENTS_FILENAME}" | grep -v "^$"; } function install() @@ -53,7 +56,7 @@ function install_or_upgrade() if [[ $EUID -ne 0 ]]; then echo -e "\nYou must run this with root privilege" 2>&1 echo -e "Please do:\n" 2>&1 - echo "sudo ./${0##*/} $PARAN" 2>&1 + echo "sudo ./$WORK_DIR/${0##*/} $PARAN" 2>&1 echo -e "\n" 2>&1 exit 1 @@ -84,5 +87,5 @@ case "$1" in upgrade) install_or_upgrade "upgrade";; list) list_packages;; help) usage_message;; - *) wrong_command $1;; + *) wrong_command "$1";; esac