40f6b9a0a82af35b39ec206f301cbdb1e26e0f7c
[fnpdjango.git] / bin / fnpdjango_bootstrap.sh
1 #!/bin/bash
2
3 DJANGO_REQ='django>=1.4,<1.5'
4 PROJECT="$1"
5 VIRTUALENVWRAPPER_PATHS="
6     /etc/bash_completion.d/virtualenvwrapper
7     /usr/bin/virtualenvwrapper.sh
8     /usr/local/bin/virtualenvwrapper.sh
9 "
10
11 # Colorful output.
12 strong='\e[0;32m'
13 normal='\e[0m'
14
15 if [ -z "$PROJECT" ]
16 then
17     echo "Usage:"
18     echo "    fnpdjango_bootstrap.sh <project_name>"
19     echo "or:"
20     echo "    wget <remote_path> -O-|bash /dev/stdin edumedfnpdjango_bootstrap.sh <project_name>"
21 fi
22
23
24 for venv in $VIRTUALENVWRAPPER_PATHS
25 do
26     if [ -e "$venv" ]
27     then
28         VIRTUALENVWRAPPER="$venv"
29         break
30     fi
31 done
32 if [ "$VIRTUALENVWRAPPER" ]
33 then
34     echo "virtualenvwrapper found at $VIRTUALENVWRAPPER."
35     source "$VIRTUALENVWRAPPER"
36 else
37     echo "ERROR: virtualenvwrapper not found. Tried locations:"
38     echo "$VIRTUALENVWRAPPER_PATHS"
39     echo "Install virtualenvwrapper or add the correct path to this script."
40     echo "Aborting."
41     exit
42 fi
43
44 echo -e "${strong}Creating virtualenv: $PROJECT...${normal}"
45 mkvirtualenv "$PROJECT"
46 echo -e "${strong}Installing Django...${normal}"
47 pip install "$DJANGO_REQ"
48
49 echo -e "${strong}Starting the project...${normal}"
50 django-admin.py startproject \
51     --template http://pypi.nowoczesnapolska.org.pl/bootstrap/project.tar.gz \
52     "$PROJECT"
53
54 cd "$PROJECT"
55 chmod +x manage.py
56 mv "$1"/localsettings.py.default "$PROJECT"/localsettings.py
57
58 echo -e "${strong}Installing requirements...${normal}"
59 pip install -r requirements.txt
60 echo -e "${strong}Installing developer requirements...${normal}"
61 pip install -r requirements-dev.txt
62 echo -e "${strong}Starting new git repository...${normal}"
63 git init
64