-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·160 lines (137 loc) · 5.77 KB
/
install.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
#su $user -c 'screen -dmS rtorrent rtorrent' lancer
###
# Mise en place des variables modifiables
TMP="/tmp/ezseed" # Répertoire temporaire
WEB="/var/www" # Répertoire web
RUTORRENT="/var/www/rutorrent" # Répertoire de rutorrent
POOLUSER="ezseedpool" # Nom de l'utilisateur qui lance le pool php
LIBTORRENT="https://github.com/rakshasa/libtorrent/archive/0.13.5.tar.gz" # Adresse de DL pour libtorrent
RTORRENT="https://github.com/rakshasa/rtorrent/archive/0.9.5.tar.gz" # Adresse de DL pour rtorrent
CONFIG_DIR="/usr/local/opt/ezseed"
###############################################################################
###############################################################################
############################### SCRIPT ##################################
######################### NE RIEN MODIFIER ##############################
###############################################################################
###############################################################################
# Mise en place des variables fixes
PLUGINS=($RUTORRENT/plugins)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WEBUSER=$(ps aux | grep $(netstat -tulpn | grep :80 | awk -F/ '{print $2}' | sed -e "s/ *$//" | sort -u) | cut -d ' ' -f 1 | sed '/root/d' | sort -u)
# Vérification du root
if [ "$(id -u)" != "0" ]; then
echo "This bash script needs a root account" 1>&2
exit 1
fi
if [ ! -d $TMP ]; then
mkdir -p $TMP
fi
# building tools
apt-get install -y apache2-utils automake build-essential buildtorrent curl ffmpeg git htop libcppunit-dev libcurl3 libcurl3-dev libcurl4-openssl-dev libncurses5 libncurses5-dev libsigc++-2.0-dev libterm-readline-gnu-perl libtool libxmlrpc-c3-dev php5-cgi php5-cli php5-curl php5-fpm php5-geoip pkg-config screen subversion unrar-free unzip
#### xmlrpc-c
#svn co http://svn.code.sf.net/p/xmlrpc-c/code/advanced xmlrpc-c
#cd xmlrpc-c
#./configure
#make
#make install
#cd ..
#rm -r xmlrpc-c
###############################################################################
############################# RUTOPRRENT ################################
###############################################################################
# Téléchargement de rutorrent (web)
if [ ! -d $WEB ]; then
mkdir -p $WEB
fi
svn checkout http://rutorrent.googlecode.com/svn/trunk/rutorrent/ $RUTORRENT
# Installation des plugins
# Plugins de bases
rm -R $PLUGINS
svn checkout http://rutorrent.googlecode.com/svn/trunk/plugins/ $PLUGINS
# Plugins logoff
svn co http://rutorrent-logoff.googlecode.com/svn/trunk/ $PLUGINS/logoff
# Plugins tadd-labels
wget -O $TMP/lbll-suite.tar.gz http://rutorrent-tadd-labels.googlecode.com/files/lbll-suite_0.8.1.tar.gz
tar -xzf $TMP/lbll-suite.tar.gz
rm $TMP/lbll-suite.tar.gz
mv $TMP/lbll* $PLUGINS
# Plugins mediainfo
wget -O $TMP/libzen.deb http://mediaarea.net/download/binary/libzen0/0.4.29/libzen0_0.4.29-1_amd64.Debian_7.0.deb
wget -O $TMP/libmediainfo.deb http://mediaarea.net/download/binary/libmediainfo0/0.7.65/libmediainfo0_0.7.65-1_amd64.Debian_7.0.deb
wget -O $TMP/mediainfo.deb http://mediaarea.net/download/binary/mediainfo/0.7.65/mediainfo_0.7.65-1_amd64.Debian_7.0.deb
dpkg -i $TMP/libzen.deb $TMP/libmediainfo.deb $TMP/mediainfo.deb
# Configuration de buildtorrent
sed -i ":useExternal: s:false:'buildtorrent':" $PLUGINS/create/conf.php
sed -i ":pathToCreatetorrent: s:= ':= '/usr/bin/buildtorrent:" $PLUGINS/create/conf.php
# Donner le répertoire rutorrent à l'utilisateur web
chown -R $WEBUSER:$WEBUSER $RUTORRENT
chmod -R 777 $RUTORRENT/share/users
###############################################################################
############################## RTORRENT #################################
###############################################################################
# Téléchargement des sources de rtorrent et libtorrent
cd $TMP
wget --no-check-certificate $LIBTORRENT
tar -xzf libtorrent*
wget --no-check-certificate $RTORRENT
tar -xzf rtorrent*
# libtorrent compilation
cd $TMP/libtorrent*
./autogen.sh
./configure
make && make install
# rtorrent compilation
cd $TMP/rtorrent*
./autogen.sh
#./configure --with-xmlrpc-c=/usr/local/bin/xmlrpc-c-config
./configure --with-xmlrpc-c
make && make install
# that.
ldconfig
# Nettoyage du répertoire tmp
rm -R $TMP/*
# Vérification de l'éxistance et création du fichier passwd
if [ ! -d $CONFIG_DIR ]; then
mkdir -p $CONFIG_DIR
fi
if [ ! -f $CONFIG_DIR/rutorrent_passwd ]; then
touch $CONFIG_DIR/rutorrent_passwd
fi
#ajout de l'environnement
echo "include /usr/local/bin" >> /etc/ld.so.conf
# Suppression des lignes include en doublon
(cat /etc/ld.so.conf | sort | uniq > /etc/ld.so.conf.tmp) && mv -f /etc/ld.so.conf.tmp /etc/ld.so.conf
ldconfig
###############################################################################
############################## POOL PHP #################################
###############################################################################
# Vérification de l'existance de l'utilisateur pour le pool et création si nécessaire
if [ "$(grep -e $POOLUSER /etc/passwd)" = "" ]; then
useradd -M -p `openssl passwd ezseed` $POOLUSER && adduser $WEBUSER $POOLUSER
fi
# Vérification de l'existance du fichier de config du pool et création si besoin
if [ ! -f /etc/php5/fpm/pool.d/$POOLUSER.conf ]; then
echo "# Nom du pool
[ezseed]
# Utilisateur et socket du pool
user = $POOLUSER
group = $POOLUSER
listen = /etc/phpcgi/php-cgi-ezseed.socket
# Paramètres du pool
pm = dynamic
pm.max_children = 4096
pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 128
pm.max_requests = 4096
chdir = /
" >> /etc/php5/fpm/pool.d/$POOLUSER.conf
fi
if [ ! -d /etc/phpcgi ]; then
mkdir /etc/phpcgi
fi
# Redémarrage de php5
service php5-fpm restart
chown www-data:www-data /etc/phpcgi/php-cgi-ezseed.socket
exit 0