10000 Merge pull request #42 from dongweiming/add_scripts_for_platform · lcppcl/code@28947a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 28947a8

Browse files
committed
Merge pull request douban#42 from dongweiming/add_scripts_for_platform
Add centos/fedora && ubuntu/debian && gentoo install code scripts
2 parents e679f4b + 229e124 commit 28947a8

File tree

9 files changed

+262
-0
lines changed

9 files changed

+262
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ Dependency
1010
- Python 2.7+
1111
- pip >= 1.4.1
1212

13+
Quick Installation
14+
------------------
15+
Currently supports the following systems:
16+
17+
* gentoo
18+
* ubuntu/debian
19+
* centos/redhat/fedora
20+
* opensuse
21+
* archlinux
22+
23+
You only to excute:
24+
25+
```
26+
bash <(curl -s https://raw.github.com/douban/code/master/scripts/install_code.sh)
27+
```
28+
1329
Prepare
1430
-------
1531
- mysql # default port

scripts/archlinux.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
#Get generic function
4+
. common.sh
5+
6+
echo "Install needed package.This may take some time..."
7+
sudo pacman -S git gcc make python2-pip python2-virtualenv memcached git --noconfirm -q
8+
9+
echo "Install mysql..."
10+
sudo pacman -S mysql --noconfirm -q
11+
sudo systemctl start mysqld
12+
13+
echo "Setup memcached port to 11311..."
14+
sudo sed -i "s/memcached -l/memcached -p 11311 -l/" /usr/lib/systemd/system/memcached.service
15+
sudo systemctl start memcached
16+
17+
echo "Install libmemcached..."
18+
install_libmemcached
19+
20+
# Use virtualenv2
21+
sudo mv /usr/bin/virtualenv /usr/bin/virtualenv.bak
22+
sudo ln -s /usr/bin/virtualenv2 /usr/bin/virtualenv
23+
24+
echo "Install code..."
25+
install_code
26+
27+
echo "Start app..."
28+
start_app

scripts/centos.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
#Get generic function
4+
. common.sh
5+
6+
echo "Install needed package.This may take some time..."
7+
sudo yum install -y -q git python-virtualenv python-devel memcached gcc gcc-c++
8+
9+
echo "Install mysql..."
10+
sudo yum install mysql-server mysql
11+
sudo /etc/init.d/mysqld start
12+
13+
echo "Setup memcached port to 11311..."
14+
sudo sed -i "s/PORT=11211/PORT=11311/" /etc/init.d/memcached
15+
sudo /etc/init.d/memcached start
16+
17+
echo "Install libmemcached..."
18+
install_libmemcached
19+
20+
echo "Install code..."
21+
install_code
22+
23+
echo "Start app..."
24+
start_app

scripts/common.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#Modify sudo's impact time
2+
modify_sudo_time() {
3+
sudo sed -i 's/env_reset/env_reset, timestamp_timeout=240/g' /etc/sudoers
4+
}
5+
6+
install_libmemcached() {
7+
wget -c https://github.com/xtao/douban-patched/raw/master/libmemcached-douban-1.0.18.tar.gz
8+
tar zxf libmemcached-douban-1.0.18.tar.gz
9+
cd libmemcached-1.0.18
10+
./configure && make && sudo make install
11+
cd ..
12+
rm -rf python-libmemcached
13+
rm -rf libmemcached*
14+
sudo /sbin/ldconfig
15+
}
16+
17+
check_virtualenv() {
18+
which virtualenv > /dev/null 2>&1
19+
if [ $? != 0 ];then
20+
echo "Install virtualenv..."
21+
sudo pip install virtualenv
22+
fi
23+
}
24+
25+
setup_database() {
26+
read -p "Please input Mysql User(default is root):" user
27+
if [ "${user}" = "" ];then
28+
user="root"
29+
fi
30+
read -p "Please input Mysql ${user}'s password(default is ''):" passwd
31+
echo "drop database if exists valentine" | mysql --user=${user} --password=${passwd}
32+
echo "create database valentine" | mysql --user=${user} --password=${passwd}
33+
if [ $? -ne 0 ]; then
34+
exit 1
35+
fi
36+
(echo "use valentine"; cat vilya/databases/schema.sql) | mysql --user=${user} --password=${passwd}
37+
}
38+
39+
install_code() {
40+
git clone https://github.com/douban/code.git
41+
cd code
42+
echo "Setup database..."
43+
setup_database
44+
check_virtualenv
45+
virtualenv venv
46+
. venv/bin/activate
47+
pip install cython # should install first
48+
pip install -U setuptools # python-libmemcached require updated setuptools
49+
pip install "distribute==0.6.29" # Fixed install MySQL-python for #14
50+
pip install -r requirements.txt
51+
}
52+
53+
start_app() {
54+
gunicorn -w 2 -b 127.0.0.1:8000 app:app # web & git http daemon
55+
}

scripts/fedora.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
#Get generic function
4+
. common.sh
5+
6+
echo "Install needed package.This may take some time..."
7+
sudo yum install -y -q git python-virtualenv python-devel memcached gcc gcc-c++
8+
9+
echo "Install mysql..."
10+
sudo yum install mysql-server mysql
11+
#fedora only this method
12+
sudo service mysqld start
13+
14+
echo "Setup memcached port to 11311..."
15+
sudo sed -i "s/PORT=11211/PORT=11311/" /etc/sysconfig/memcached
16+
sudo service memcached restart
17+
18+
echo "Install libmemcached..."
19+
install_libmemcached
20+
21+
echo "Install code..."
22+
install_code
23+
24+
echo "Start app..."
25+
start_app

scripts/gentoo.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
# Use ebegin
4+
if [ -e /lib/rc/bin/ebegin ];then
5+
echo=/lib/rc/bin/ebegin
6+
end="/lib/rc/bin/eend $?"
7+
else
8+
echo=echo
9+
end=echo
10+
fi
11+
#Get generic function
12+
. common.sh
13+
14+
$echo "eselect python 2.7"
15+
sudo eselect python set 1
16+
$end
17+
18+
$echo "Install needed package.This may take some time..."
19+
sudo emerge git dev-python/pip dev-python/virtualenv memcached -q
20+
$end
21+
22+
$echo "Install mysql..."
23+
sudo emerge mysql -q
24+
sudo /usr/bin/mysql_install_db
25+
sudo /etc/init.d/mysql start
26+
$end
27+
28+
$echo "Setup memcached port to 11311..."
29+
sudo sed -i 's/PORT=\"11211\"/PORT=\"11311\"/g' /etc/conf.d/memcached
30+
sudo /etc/init.d/memcached restart
31+
$end
32+
33+
$echo "Install libmemcached..."
34+
install_libmemcached
35+
$end
36+
37+
$echo "Install code..."
38+
install_code
39+
$end
40+
41+
$echo "Start app..."
42+
start_app

scripts/install_code.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
url='https://raw.github.com/douban/code/master/scripts'
4+
5+
if [ -f /etc/fedora-release ] ; then
6+
file="$url/fedora.sh"
7+
elif [ -f /etc/redhat-release ] ; then
8+
file="$url/centos.sh"
9+
elif [ -f /etc/SuSE-release ] ; then
10+
file="$url/opensuse.sh"
11+
elif [ -f /etc/debian_version ] ; then
12+
file="$url/ubuntu.sh"
13+
elif [ -f /etc/gentoo-release ] ; then
14+
file="$url/gentoo.sh"
15+
elif [ -f /etc/arch-release ] ; then
16+
file="$url/archlinux.sh"
17+
else
18+
echo "Not yet support the system!"
19+
exit 1
20+
fi
21+
22+
curl -O "$url/common.sh"
23+
bash <(curl -s $file)
24+
rm common.sh -f

scripts/opensuse.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
#Get generic function
4+
. common.sh
5+
6+
echo "Install needed package.This may take some time..."
7+
sudo zypper -nq install gcc gcc-c++ python-pip python-virtualenv git memcached python-devel make
8+
9+
echo "Install mysql..."
10+
# After 12.3 mysql is mariadb
11+
sudo zypper -nq install mysql libmysqlclient-devel
12+
sudo /sbin/service mysql start
13+
14+
echo "Setup memcached port to 11311..."
15+
sudo sed -i 's/MEMCACHED_PARAMS=\"/MEMCACHED_PARAMS=\"-p 11311 /' /etc/sysconfig/memcached
16+
sudo /etc/init.d/memcached restart
17+
18+
echo "Install libmemcached..."
19+
install_libmemcached
20+
21+
echo "Install code..."
22+
install_code
23+
24+
echo "Start app..."
25+
start_app

scripts/ubuntu.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
#Get generic function
4+
. common.sh
5+
6+
echo "Install needed package.This may take some time..."
7+
sudo apt-get install build-essential g++ git python-pip python-virtualenv python-dev memcached -yq
8+
9+
echo "Install mysql..."
10+
sudo apt-get install mysql-client mysql-server libmysqlclient-dev -yq
11+
12+
echo "Setup memcached port to 11311..."
13+
sudo sed -i "s/11211/11311/g" /etc/memcached.conf
14+
sudo /etc/init.d/memcached restart
15+
16+
echo "Install libmemcached..."
17+
install_libmemcached
18+
19+
echo "Install code..."
20+
install_code
21+
22+
echo "Start app..."
23+
start_app

0 commit comments

Comments
 (0)
0