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
53 lines (48 loc) · 1.48 KB
/
common.sh
File metadata and controls
53 lines (48 loc) · 1.48 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
#Modify sudo's impact time
modify_sudo_time() {
sudo sed -i 's/env_reset/env_reset, timestamp_timeout=240/g' /etc/sudoers
}
check_virtualenv() {
which virtualenv > /dev/null 2>&1
if [ $? != 0 ];then
echo "Install virtualenv..."
sudo pip install virtualenv
fi
virtualenv venv
. venv/bin/activate
}
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
test "$CODE_ENV" != "unset" && check_virtualenv
pip install cython # should install first
pip install -U setuptools
pip install -r requirements.txt
}
start_app() {
test "$CODE_ENV" != "unset" && gunicorn -w 2 -b 127.0.0.1:8000 app:app # web & git http daemon
}
install_beansdb() {
git clone https://github.com/douban/beansdb
cd beansdb
./autogen.sh
./configure && make && sudo make install
cd -
sudo mkdir /data/beansdb -p
beansdb -p 7900 -H /data/beansdb -T 0 -d
}