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