mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-30 01:39:45 +03:00
improve install_os_dependencies.sh
This commit is contained in:
parent
939be90f44
commit
d5a8758ad8
|
@ -1,14 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
WORK_DIR="$(dirname "$0")"
|
WORK_DIR="$(dirname "$0")"
|
||||||
OS_REQUIREMENTS_FILENAME="$WORK_DIR/requirements.apt"
|
DISTRO_NAME=$(lsb_release -sc)
|
||||||
|
|
||||||
VER=$(lsb_release -sr)
|
OS_REQUIREMENTS_FILENAME="$WORK_DIR/requirements-$DISTRO_NAME.apt"
|
||||||
if [ "$VER" == "16.04" ]; then
|
|
||||||
OS_REQUIREMENTS_FILENAME="requirements.apt.xenial"
|
|
||||||
else
|
if [ "$DISTRO_NAME" != "xenial" ] && [ "$DISTRO_NAME" != "trusty" ]; then
|
||||||
OS_REQUIREMENTS_FILENAME="requirements.apt"
|
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
|
fi
|
||||||
|
|
||||||
# Handle call with wrong command
|
# Handle call with wrong command
|
||||||
function wrong_command()
|
function wrong_command()
|
||||||
{
|
{
|
||||||
|
@ -31,7 +34,7 @@ function usage_message()
|
||||||
|
|
||||||
# Read the requirements.apt file, and remove comments and blank lines
|
# Read the requirements.apt file, and remove comments and blank lines
|
||||||
function list_packages(){
|
function list_packages(){
|
||||||
grep -v "#" ${OS_REQUIREMENTS_FILENAME} | grep -v "^$";
|
grep -v "#" "${OS_REQUIREMENTS_FILENAME}" | grep -v "^$";
|
||||||
}
|
}
|
||||||
|
|
||||||
function install()
|
function install()
|
||||||
|
@ -53,7 +56,7 @@ function install_or_upgrade()
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
echo -e "\nYou must run this with root privilege" 2>&1
|
echo -e "\nYou must run this with root privilege" 2>&1
|
||||||
echo -e "Please do:\n" 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
|
echo -e "\n" 2>&1
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -84,5 +87,5 @@ case "$1" in
|
||||||
upgrade) install_or_upgrade "upgrade";;
|
upgrade) install_or_upgrade "upgrade";;
|
||||||
list) list_packages;;
|
list) list_packages;;
|
||||||
help) usage_message;;
|
help) usage_message;;
|
||||||
*) wrong_command $1;;
|
*) wrong_command "$1";;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue
Block a user