mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 09:36:52 +03:00
refactored install_os_dependencies.sh
add .idea on .gitignore
This commit is contained in:
parent
0fbd6ccd72
commit
afb9f607e9
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@
|
|||
*.pyc
|
||||
local_settings.py
|
||||
repo_name
|
||||
.idea
|
||||
|
|
|
@ -1,20 +1,82 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
OS_REQUIREMENTS_FILENAME="requirements.apt"
|
||||
|
||||
# Handle call with wrong command
|
||||
function wrong_command()
|
||||
{
|
||||
echo "${0##*/} - unknown command: '${1}'"
|
||||
usage_message
|
||||
}
|
||||
|
||||
# Print help / script usage
|
||||
function usage_message()
|
||||
{
|
||||
echo "usage: ./${0##*/} <command>"
|
||||
echo "available commands are:"
|
||||
echo -e "\tlist\t\tPrint a list of all packages defined on ${OS_REQUIREMENTS_FILENAME} file"
|
||||
echo -e "\thelp\t\tPrint this help"
|
||||
echo -e "\n\tCommands that require superuser permission:"
|
||||
echo -e "\tinstall\t\tInstall packages defined on ${OS_REQUIREMENTS_FILENAME} file. Note: This\n\t\t\t does not upgrade the packages already installed for new\n\t\t\t versions, even if new version is available in the repository."
|
||||
echo -e "\tupgrade\t\tSame that install, but upgrate the already installed packages,\n\t\t\t if new version is available."
|
||||
|
||||
}
|
||||
|
||||
# Read the requirements.apt file, and remove comments and blank lines
|
||||
function list_packages(){
|
||||
cat ${OS_REQUIREMENTS_FILENAME} | grep -v "#" | grep -v "^$";
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
list_packages | xargs apt-get --no-upgrade install -y;
|
||||
}
|
||||
|
||||
function upgrade()
|
||||
{
|
||||
list_packages | xargs apt-get install -y;
|
||||
}
|
||||
|
||||
|
||||
function install_or_upgrade()
|
||||
{
|
||||
P=${1}
|
||||
PARAN=${P:-"install"}
|
||||
|
||||
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##*/}" 2>&1
|
||||
echo "sudo ./${0##*/} $PARAN" 2>&1
|
||||
echo -e "\n" 2>&1
|
||||
|
||||
exit 1
|
||||
else
|
||||
else
|
||||
|
||||
apt-get update
|
||||
|
||||
# Install the basic compilation dependencies and other required libraries of this project
|
||||
cat requirements.apt | grep -v "#" | xargs sudo apt-get install -y
|
||||
if [ "$PARAN" == "install" ]; then
|
||||
install;
|
||||
else
|
||||
upgrade;
|
||||
fi
|
||||
|
||||
# cleaning downloaded packages from apt-get cache
|
||||
apt-get clean
|
||||
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Handle command argument
|
||||
case "$1" in
|
||||
install) install_or_upgrade;;
|
||||
upgrade) install_or_upgrade "upgrade";;
|
||||
list) list_packages;;
|
||||
help) usage_message;;
|
||||
*) wrong_command $1;;
|
||||
esac
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user