Nicer project start.
[fnpdjango.git] / bin / fnpdjango_bootstrap.sh
1 #!/bin/bash
2
3 PROJECT="$1"
4
5 # Make it a function, so that it works with `source`
6 start_project() {
7
8 DJANGO_REQ='Django>=1.4,<1.5'
9 VIRTUALENVWRAPPER_PATHS="
10     /etc/bash_completion.d/virtualenvwrapper
11     /usr/bin/virtualenvwrapper.sh
12     /usr/local/bin/virtualenvwrapper.sh
13 "
14
15 # Colorful output.
16 strong='\e[0;32m'
17 error='\e[1;31m'
18 normal='\e[0m'
19
20 echo "Create new Django project."
21 while [ -z "$PROJECT" ]
22 do
23     echo "Name of the project:"
24     read PROJECT
25 done
26 echo -e "Project: ${strong}${PROJECT}${normal}"
27
28 for venv in $VIRTUALENVWRAPPER_PATHS
29 do
30     if [ -e "$venv" ]
31     then
32         VIRTUALENVWRAPPER="$venv"
33         break
34     fi
35 done
36 if [ "$VIRTUALENVWRAPPER" ]
37 then
38     echo "virtualenvwrapper found at $VIRTUALENVWRAPPER."
39     source "$VIRTUALENVWRAPPER"
40 else
41     echo -e "${error}ERROR: virtualenvwrapper not found. Tried locations:${normal}"
42     echo "$VIRTUALENVWRAPPER_PATHS"
43     echo -e "${error}Install virtualenvwrapper or add the correct path to this script.${normal}"
44     echo "Aborting."
45     return
46 fi
47
48 echo -e "${strong}Creating virtualenv: $PROJECT...${normal}"
49 mkvirtualenv "$PROJECT"
50 echo -e "${strong}Installing Django...${normal}"
51 pip install "$DJANGO_REQ"
52
53 echo -e "${strong}Starting the project...${normal}"
54 django-admin.py startproject \
55     --template http://pypi.nowoczesnapolska.org.pl/bootstrap/project.tar.gz \
56     "$PROJECT"
57
58 cd "$PROJECT"
59 chmod +x manage.py
60 mv "$PROJECT"/localsettings.py.default "$PROJECT"/localsettings.py
61
62 echo -e "${strong}Installing requirements...${normal}"
63 pip install -r requirements.txt
64 echo -e "${strong}Installing developer requirements...${normal}"
65 pip install -r requirements-dev.txt
66 echo -e "${strong}Starting new git repository...${normal}"
67 git init
68
69 echo -e "${strong}What next?${normal}"
70 echo " * Work on your app, commit to git."
71 echo " * Review fabfile, use fab for deployment."
72
73
74 }
75 start_project