-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
executable file
·118 lines (97 loc) · 2.67 KB
/
setup.sh
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
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
function install_brew_dependancies {
for pkg in redis node; do
if brew list -1 | grep -q "^${pkg}\$"; then
echo "Package '$pkg' already installed"
else
echo "installing '$pkg'"
sudo -H -u nobody bash -c "brew install $pkg"
fi
done
}
function has_dependancy {
if [ -z "$1" ]; then
echo "please pass an argument."
else
if which ${1}; then
return 0
else
return 1
fi
fi
}
function macosx_install {
echo "installing system dependancies <MAC OSX>"
if has_dependancy "easy_install"; then
echo "Package easy_install already installed"
else
echo "installing python-setuptools"
curl https://bootstrap.pypa.io/ez_setup.py -o - | python > setup.log
fi
if has_dependancy "pip"; then
echo "Package pip already installed"
else
echo "installing pip"
easy_install pip >> setup.log
fi
echo "installing virtualenv"
pip install virtualenv >> setup.log
install_brew_dependancies
}
function debian_install {
echo "installing system dependancies <Linux> ..."
echo "installing pip"
apt-get install -y python-pip > setup.log
echo "installing python-setuptools"
apt-get install -y python-setuptools >> setup.log
echo "installing virtualenv"
sudo pip install virtualenv >> setup.log
echo "installing redis-server"
sudo apt-get install redis-server >> setup.log
}
function windows_install {
echo "Currently unsupported. Sorry."
}
function structure_app {
echo Creating virtualenv and restructuring app ...
cd ..
virtualenv --no-site-packages cshub_site_dev
. cshub_site_dev/bin/activate
cp -R cshub_site cshub_site_dev
cd cshub_site_dev/cshub_site
pip install https://wadofstuff.googlecode.com/files/wadofstuff-django-serializers-1.1.0.tar.gz
pip install -r requirements.txt
cp secrets_example.json secrets.json
mv secrets.json ../
mkdir ../logs
chgrp -R $SUDO_USER ../../cshub_site_dev
chown -R $SUDO_USER ../../cshub_site_dev
}
function next_steps_instructions {
echo "1. go in to the cshub_site_dev directory"
echo "2. . bin/activiate"
echo "3. ./manage.py syncdb"
echo "4. ./manage.py collectstatic -n"
echo "5. ./manage.py runserver"
}
if [ "$(uname)" == "Darwin" ]; then
# Do something under Mac OS X platform
if has_dependancy "brew"; then
macosx_install
else
echo "you need to install homebrew before continuing."
exit
fi
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# Do something under Linux platform
debian_install
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
# Do something under Windows NT platform
windows_install
exit
fi
structure_app
echo "DONE"
#syncdb
#collectstatic -n
#runserver