-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdjango-recycled
107 lines (84 loc) · 2.01 KB
/
django-recycled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Quick and dirty django setup for testing
#
# This script installs django and configures it with sqlite
# Usage:
# mkdir test-dir
# cd test-dir
# bash -c "$(curl -fsSL https://raw.github.com/vinodpandey/scripts/master/django-recycled)" -s --django=1.5.0
# cd project
# python manage.py syncdb
#
# Firefox plugin for sqlite
# https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
#
# Portion of the code used from
# https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer
######################
# Required functions
######################
usage()
{
printf "%b" "
Usage
django-recycled --django=1.5.0
Dependency
Requires virtualenv-2.7
"
}
log() { printf "%b\n" "$*"; }
fail() { log "\nERROR: $*\n" ; exit 1 ; }
install_django()
{
echo "Installing Django $*"
pip install Django==$*
echo "Creating Django Project"
django-admin.py startproject project
if [[ $* == 1.5* ]]; then
echo "Updated database settings in settings.py"
sed -i".bak" -e "s/django.db.backends./django.db.backends.sqlite3/g" project/project/settings.py
sed -i".bak" -e "s/'NAME': ''/'NAME': 'database.sqlite'/g" project/project/settings.py
rm -rf project/project/settings.py.bak
fi
}
######################
if [[ "x$(virtualenv-2.7 --version)" = "x" ]]
then
fail "Could not find 'virtualenv-2.7' command, make sure it's available first before continuing installation."
fi
echo "Creating virtual environment"
virtualenv-2.7 --no-site-packages .
source bin/activate
# Parse CLI arguments.
if (($# < 1))
then
log "\nERROR: \nNo argument found!!"
usage
exit 1
fi
while (( $# > 0 ))
do
token="$1"
shift
case "$token" in
--django=*)
version="${token#--django=}"
if [[ $version == "" ]]
then
fail "--django must be followed by a version"
else
install_django "$version"
fi
;;
help|usage)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
echo "Done"
deactivate