forked from douban/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.sh
More file actions
59 lines (54 loc) · 1.79 KB
/
common.sh
File metadata and controls
59 lines (54 loc) · 1.79 KB
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
#Modify sudo's impact time
modify_sudo_time() {
sudo sed -i 's/env_reset/env_reset, timestamp_timeout=240/g' /etc/sudoers
}
install_libmemcached() {
#check libmemcached has installed
if [ ! -f /usr/local/bin/memping ] ; then
curl -L https://github.com/xtao/douban-patched/raw/master/libmemcached-douban-1.0.18.tar.gz |tar zx
cd libmemcached-1.0.18
./configure && make && sudo make install
cd ..
rm -rf libmemcached-1.0.18
echo "/usr/local/lib" | sudo tee -a /etc/ld.so.conf
sudo /sbin/ldconfig
fi
}
check_virtualenv() {
which virtualenv > /dev/null 2>&1
if [ $? != 0 ];then
echo "Install virtualenv..."
sudo pip install virtualenv
fi
}
setup_database() {
read -p "Please input Mysql User(default is root):" user
if [ "${user}" = "" ];then
user="root"
fi
read -p "Please input Mysql ${user}'s password(default is ''):" passwd
echo "drop database if exists valentine" | mysql --user=${user} --password=${passwd}
echo "create database valentine" | mysql --user=${user} --password=${passwd}
if [ $? -ne 0 ]; then
exit 1
fi
(echo "use valentine"; cat vilya/databases/schema.sql) | mysql --user=${user} --password=${passwd}
}
install_code() {
git clone https://github.com/douban/code.git
cd code
echo "Setup database..."
setup_database
check_virtualenv
virtualenv venv
. venv/bin/activate
pip install cython # should install first
pip install -U setuptools # python-libmemcached require updated setuptools
if [ -f /etc/arch-release ] ; then
pip install "distribute==0.6.29" # Fixed install MySQL-python on archlinux for #14
fi
pip install -r requirements.txt
}
start_app() {
gunicorn -w 2 -b 127.0.0.1:8000 app:app # web & git http daemon
}