-
Notifications
You must be signed in to change notification settings - Fork 44
/
bonobox.sh
executable file
·764 lines (630 loc) · 23.4 KB
/
bonobox.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
#!/bin/bash -i
#
# Script d'installation ruTorrent / Nginx
# Auteur : Ex_Rat
#
# Nécessite Debian 10/11 - 64 bits & un serveur fraîchement installé
#
# Multi-utilisateurs
# Inclus VsFTPd (ftp & ftps sur le port 21), Fail2ban (avec conf nginx, ftp & ssh)
#
# Tiré du tutoriel de mondedie.fr disponible ici:
# https://mondedie.fr/d/10831-tuto-installer-rutorrent-sur-debian-10-nginx-php-fpm
#
# Merci aux contributeurs: Sophie, Spectre, Hardware, Zarev, SirGato, MiguelSam, Hierra, mog54.
#
# Installation:
#
# su - ou sudo su -
# apt-get update && apt-get upgrade -y
# apt-get install git-core -y
#
# cd /tmp
# git clone https://github.com/exrat/rutorrent-bonobox
# cd rutorrent-bonobox
# chmod a+x bonobox.sh && ./bonobox.sh
#
# Pour gérer vos utilisateurs ultérieurement, il vous suffit de relancer le script
#
# Disclaimer
# Ce script est proposé à des fins d'expérimentation uniquement,
# le téléchargement d’oeuvre copyrightées est illégal.
#
# Merci de vous conformer à la législation en vigueur en fonction de vos pays respectifs
# en faisant vos tests sur des fichiers libres de droits.
#
# This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
# includes
INCLUDES="includes"
# shellcheck source=/dev/null
. "$INCLUDES"/cmd.sh
# shellcheck source=/dev/null
. "$INCLUDES"/variables.sh
# shellcheck source=/dev/null
. "$INCLUDES"/langues.sh
# shellcheck source=/dev/null
. "$INCLUDES"/functions.sh
# contrôle droits utilisateur & OS
FONCCONTROL
FONCBASHRC
# contrôle installation
if [ ! -f "$NGINXENABLE"/rutorrent.conf ]; then
# contröle wget
if [ ! -f "$CMDWGET" ]; then
"$CMDAPTGET" install -y wget &>/dev/null
fi
# log de l'installation
exec > >("$CMDTEE" "/tmp/install.log") 2>&1
# liste users en arguments
TESTARG=$("$CMDECHO" "$ARG" | "$CMDTR" -s ' ' '\n' | "$CMDGREP" :)
if [ ! -z "$TESTARG" ]; then
"$CMDECHO" "$ARG" | "$CMDTR" -s ' ' '\n' | "$CMDGREP" : > "$ARGFILE"
fi
####################################
# lancement installation ruTorrent #
####################################
# message d'accueil
"$CMDCLEAR"
"$CMDECHO" ""; set "102"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"; "$CMDECHO" ""
# shellcheck source=/dev/null
. "$INCLUDES"/logo.sh
if [ ! -s "$ARGFILE" ]; then
"$CMDECHO" ""
FONCUSER # demande nom user
"$CMDECHO" ""
FONCPASS # demande mot de passe
else
FONCARG
fi
PORT=5001
# installation vsftpd
if [ -z "$ARGFTP" ]; then
"$CMDECHO" ""; set "128"; FONCTXT "$1"; "$CMDECHO" -n -e "${CGREEN}$TXT1 ${CEND}"
read -r SERVFTP
else
if [ "$ARGFTP" = "ftp-off" ]; then
SERVFTP="n"
else
SERVFTP="y"
fi
fi
# récupération 5% root sur /home ou /home/user si présent
FSHOME=$("$CMDDF" -h | "$CMDGREP" /home | "$CMDCUT" -c 6-9)
if [ "$FSHOME" = "" ]; then
"$CMDECHO"
else
"$CMDTUNE2FS" -m 0 /dev/"$FSHOME" &> /dev/null
"$CMDMOUNT" -o remount /home &> /dev/null
fi
FONCFSUSER "$USER"
# variable passe nginx
PASSNGINX=${USERPWD}
# ajout utilisateur
"$CMDUSERADD" -M -s /bin/bash "$USER"
# création mot de passe utilisateur
"$CMDECHO" "${USER}:${USERPWD}" | "$CMDCHPASSWD"
# anti-bug /home/user déjà existant
"$CMDMKDIR" -p /home/"$USER"
"$CMDCHOWN" -R "$USER":"$USER" /home/"$USER"
# variable utilisateur majuscule
USERMAJ=$("$CMDECHO" "$USER" | "$CMDTR" "[:lower:]" "[:upper:]")
# récupération ip serveur
FONCIP
# récupération threads & sécu -j illimité
THREAD=$("$CMDGREP" -c processor < /proc/cpuinfo)
if [ "$THREAD" = "" ]; then
THREAD=1
fi
# ajout dépôts
# shellcheck source=/dev/null
. "$INCLUDES"/deb.sh
# bind9 & dhcp
if [ ! -d /etc/bind ]; then
"$CMDRM" /etc/init.d/bind9 &> /dev/null
"$CMDAPTGET" install -y bind9
fi
if [ -f /etc/dhcp/dhclient.conf ]; then
"$CMDSED" -i "s/#prepend domain-name-servers 127.0.0.1;/prepend domain-name-servers 127.0.0.1;/g;" /etc/dhcp/dhclient.conf
fi
"$CMDCP" -f "$FILES"/bind/named.conf.options /etc/bind/named.conf.options
"$CMDSED" -i '/127.0.0.1/d' /etc/resolv.conf # pour éviter doublon
"$CMDECHO" "nameserver 127.0.0.1" >> /etc/resolv.conf
FONCSERVICE restart bind9
# installation des paquets
"$CMDAPTGET" update && "$CMDAPTGET" upgrade -y
"$CMDECHO" ""; set "132" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
"$CMDAPTGET" install -y \
apache2-utils \
apt-utils \
aptitude \
automake \
build-essential \
ccze \
curl \
dnsutils \
fail2ban \
ffmpeg \
gawk \
htop \
libarchive-zip-perl \
libcppunit-dev \
libcurl4-openssl-dev \
libjson-perl \
libjson-xs-perl \
libmms0 \
libncurses5-dev \
libncursesw5-dev \
libsigc++-2.0-dev \
libsox-fmt-all \
libsox-fmt-mp3 \
libssl-dev \
libtool \
libwww-perl \
mediainfo \
mktorrent \
nano \
nginx \
ntp \
ntpdate \
openssl \
pastebinit \
"$PHPNAME" \
"$PHPNAME"-bcmath \
"$PHPNAME"-cli \
"$PHPNAME"-common \
"$PHPNAME"-curl \
"$PHPNAME"-fpm \
"$PHPNAME"-json \
"$PHPNAME"-mbstring \
"$PHPNAME"-opcache \
"$PHPNAME"-readline \
"$PHPNAME"-xml \
"$PHPNAME"-zip \
php-geoip \
pkg-config \
psmisc \
pv \
python3-pip \
python3-venv \
rar \
screen \
sox \
subversion \
unrar \
unzip \
vim \
whois \
zip \
zlib1g-dev
if [[ "$VERSION" = 10.* ]]; then
"$CMDAPTGET" install -y \
libtinyxml2-6a
elif [[ "$VERSION" = 11.* ]]; then
"$CMDAPTGET" install -y \
libtinyxml2-8 \
python-is-python2
fi
"$CMDECHO" ""; set "136" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# génération clé 2048 bits
"$CMDOPENSSL" dhparam -out dhparams.pem 2048 >/dev/null 2>&1 &
# création fichiers couleurs nano
"$CMDCP" -f "$FILES"/nano/ini.nanorc /usr/share/nano/ini.nanorc
"$CMDCP" -f "$FILES"/nano/conf.nanorc /usr/share/nano/conf.nanorc
"$CMDCP" -f "$FILES"/nano/xorg.nanorc /usr/share/nano/xorg.nanorc
# configuration nano
"$CMDCAT" <<- EOF >> /etc/nanorc
## Config Files (.ini)
include "/usr/share/nano/ini.nanorc"
## Config Files (.conf)
include "/usr/share/nano/conf.nanorc"
## Xorg.conf
include "/usr/share/nano/xorg.nanorc"
EOF
"$CMDECHO" ""; set "138" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# configuration ntp & réglage heure fr
if [ "$GENLANG" = "fr" ]; then
"$CMDECHO" "Europe/Paris" > /etc/timezone
"$CMDCP" -f /usr/share/zoneinfo/Europe/Paris /etc/localtime
"$CMDSED" -i "s/server 0/#server 0/g;" /etc/ntp.conf
"$CMDSED" -i "s/server 1/#server 1/g;" /etc/ntp.conf
"$CMDSED" -i "s/server 2/#server 2/g;" /etc/ntp.conf
"$CMDSED" -i "s/server 3/#server 3/g;" /etc/ntp.conf
"$CMDCAT" <<- EOF >> /etc/ntp.conf
server 0.fr.pool.ntp.org
server 1.fr.pool.ntp.org
server 2.fr.pool.ntp.org
server 3.fr.pool.ntp.org
EOF
"$CMDNTPDATE" -d 0.fr.pool.ntp.org
fi
# installation xmlrpc libtorrent rtorrent
cd /tmp || exit
"$CMDGIT" clone --progress https://github.com/mirror/xmlrpc-c.git
cd xmlrpc-c/stable || exit
./configure #--disable-cplusplus
"$CMDMAKE" -j "$THREAD"
"$CMDMAKE" install
"$CMDECHO" ""; set "140" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# clone rtorrent et libtorrent
cd /tmp || exit
"$CMDGIT" clone --progress https://github.com/rakshasa/libtorrent.git
"$CMDGIT" clone --progress https://github.com/rakshasa/rtorrent.git
# compilation libtorrent
cd libtorrent || exit
"$CMDGIT" checkout "$LIBTORRENT"
./autogen.sh
./configure --disable-debug
"$CMDMAKE" -j "$THREAD"
"$CMDMAKE" install
"$CMDECHO" ""; set "142" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1 $LIBTORRENT${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# compilation rtorrent
cd ../rtorrent || exit
"$CMDGIT" checkout "$RTORRENT"
./autogen.sh
./configure --with-xmlrpc-c --with-ncurses --disable-debug
"$CMDMAKE" -j "$THREAD"
"$CMDMAKE" install
"$CMDLDCONFIG"
"$CMDECHO" ""; set "144" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1 $RTORRENT${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# création des dossiers
"$CMDSU" "$USER" -c ""$CMDMKDIR" -p ~/watch ~/torrents ~/.session ~/.backup-session"
# création dossier scripts perso
"$CMDMKDIR" "$SCRIPT"
# création accueil serveur
"$CMDMKDIR" -p "$NGINXWEB"
"$CMDCP" -R "$BONOBOX"/base "$NGINXBASE"
# téléchargement et déplacement de rutorrent
"$CMDGIT" clone --progress https://github.com/Novik/ruTorrent.git "$RUTORRENT"
"$CMDECHO" ""; set "146" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# installation des plugins - thank Micdu70 ;)
cd /tmp || exit
"$CMDGIT" clone --progress https://github.com/exrat/rutorrent-plugins-pack
for PLUGINS in 'addzip' 'chat' 'filemanager' 'filemanager-share' 'toggle_details_button' 'geoip2' 'lbll-suite' 'logoff' 'nfo' 'pausewebui' 'ratiocolor' 'titlebar' 'trackerstatus'; do
"$CMDCP" -R /tmp/rutorrent-plugins-pack/"$PLUGINS" "$RUPLUGINS"/
done
# installation cloudscraper pour _cloudflare
"$CMDPIP" install setuptools --upgrade
"$CMDPIP" install cloudscraper
# configuration geoip2
cd "$RUPLUGINS"/geoip2/database || exit
for DATABASE in *.tar.gz; do
"$CMDTAR" xzfv "$DATABASE"
done
"$CMDRM" -R GeoLite2-City.mmdb.tar.gz GeoLite2-Country.mmdb.tar.gz
# configuration filemanager
"$CMDCP" -f "$FILES"/rutorrent/filemanager.conf "$RUPLUGINS"/filemanager/conf.php
"$CMDSED" -i "s|@RAR@|$CMDRAR|g;" "$RUPLUGINS"/filemanager/conf.php
"$CMDSED" -i "s|@ZIP@|$CMDZIP|g;" "$RUPLUGINS"/filemanager/conf.php
"$CMDSED" -i "s|@UNZIP@|$CMDUNZIP|g;" "$RUPLUGINS"/filemanager/conf.php
"$CMDSED" -i "s|@TAR@|$CMDTAR|g;" "$RUPLUGINS"/filemanager/conf.php
#"$CMDSED" -i "s|@GZIP@|$CMDGZIP|g;" "$RUPLUGINS"/filemanager/conf.php
#"$CMDSED" -i "s|@BZIP2@|$CMDBZIP2|g;" "$RUPLUGINS"/filemanager/conf.php
# configuration filemanager-share
"$CMDCP" -f "$FILES"/rutorrent/filemanager-share.conf "$RUPLUGINS"/filemanager-share/conf.php
"$CMDSED" -i "s/@IP@/$IP/g;" "$RUPLUGINS"/filemanager-share/conf.php
"$CMDCHOWN" -R "$WDATA" "$RUPLUGINS"/filemanager-share
"$CMDLN" -s "$RUPLUGINS"/filemanager-share/share.php "$NGINXBASE"/share.php
# configuration create
# shellcheck disable=SC2154
"$CMDSED" -i "s#$useExternal = false;#$useExternal = 'mktorrent';#" "$RUPLUGINS"/create/conf.php
# shellcheck disable=SC2154
"$CMDSED" -i "s#$pathToCreatetorrent = '';#$pathToCreatetorrent = '/usr/bin/mktorrent';#" "$RUPLUGINS"/create/conf.php
# configuration logoff
"$CMDSED" -i "s/user1,user2,user3/$USER/g;" "$RUPLUGINS"/logoff/conf.php
# variable minutes aléatoire crontab geoip2
MAXIMUM=58
MINIMUM=1
UPGEOIP=$((MINIMUM+RANDOM*(1+MAXIMUM-MINIMUM)/32767))
cd "$SCRIPT" || exit
for COPY in 'updateGeoIP.sh' 'backup-session.sh'; do
"$CMDCP" -f "$FILES"/scripts/"$COPY" "$SCRIPT"/"$COPY"
"$CMDCHMOD" a+x "$COPY"
done
FONCBAKSESSION
# ajout thèmes
"$CMDRM" -R "${RUPLUGINS:?}"/theme/themes/Blue
"$CMDCP" -R "$BONOBOX"/theme/ru/Blue "$RUPLUGINS"/theme/themes/Blue
"$CMDCP" -R "$BONOBOX"/theme/ru/SpiritOfBonobo "$RUPLUGINS"/theme/themes/SpiritOfBonobo
"$CMDGIT" clone --progress https://github.com/themightykitten/ruTorrent-MaterialDesign.git "$RUPLUGINS"/theme/themes/MaterialDesign
# configuration thème
"$CMDSED" -i "s/defaultTheme = \"\"/defaultTheme = \"SpiritOfBonobo\"/g;" "$RUPLUGINS"/theme/conf.php
"$CMDECHO" ""; set "148" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# liens symboliques et permissions
"$CMDLDCONFIG"
"$CMDCHOWN" -R "$WDATA" "$RUTORRENT"
"$CMDCHMOD" -R 777 "$RUPLUGINS"/filemanager/scripts
"$CMDCHOWN" -R "$WDATA" "$NGINXBASE"
# configuration php
"$CMDSED" -i "s/2M/10M/g;" "$PHPPATH"/fpm/php.ini
"$CMDSED" -i "s/8M/10M/g;" "$PHPPATH"/fpm/php.ini
"$CMDSED" -i "s/expose_php = On/expose_php = Off/g;" "$PHPPATH"/fpm/php.ini
if [ "$GENLANG" = "fr" ]; then
"$CMDSED" -i "s/^;date.timezone =/date.timezone = Europe\/Paris/g;" "$PHPPATH"/fpm/php.ini
"$CMDSED" -i "s/^;date.timezone =/date.timezone = Europe\/Paris/g;" "$PHPPATH"/cli/php.ini
else
"$CMDSED" -i "s/^;date.timezone =/date.timezone = UTC/g;" "$PHPPATH"/fpm/php.ini
"$CMDSED" -i "s/^;date.timezone =/date.timezone = UTC/g;" "$PHPPATH"/cli/php.ini
fi
"$CMDSED" -i "s/^;listen.owner = www-data/listen.owner = www-data/g;" "$PHPPATH"/fpm/pool.d/www.conf
"$CMDSED" -i "s/^;listen.group = www-data/listen.group = www-data/g;" "$PHPPATH"/fpm/pool.d/www.conf
"$CMDSED" -i "s/^;listen.mode = 0660/listen.mode = 0660/g;" "$PHPPATH"/fpm/pool.d/www.conf
"$CMDECHO" "php_admin_value[error_reporting] = E_ALL & ~E_WARNING" >> "$PHPPATH"/fpm/pool.d/www.conf
FONCSERVICE restart "$PHPNAME"-fpm
"$CMDECHO" ""; set "150" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
"$CMDMKDIR" -p "$NGINXPASS" "$NGINXSSL"
"$CMDTOUCH" "$NGINXPASS"/rutorrent_passwd
"$CMDCHMOD" 640 "$NGINXPASS"/rutorrent_passwd
# configuration serveur web
"$CMDMKDIR" "$NGINXENABLE"
"$CMDCP" -f "$FILES"/nginx/nginx.conf "$NGINX"/nginx.conf
for CONF in 'log_rutorrent.conf' 'ciphers.conf' 'cache.conf' 'php.conf'; do
"$CMDCP" -f "$FILES"/nginx/"$CONF" "$NGINXCONFD"/"$CONF"
done
"$CMDSED" -i "s|@PHPSOCK@|$PHPSOCK|g;" "$NGINXCONFD"/php.conf
"$CMDCP" -f "$FILES"/rutorrent/rutorrent.conf "$NGINXENABLE"/rutorrent.conf
for VAR in "${!NGINXCONFD@}" "${!NGINXBASE@}" "${!NGINXSSL@}" "${!NGINXPASS@}" "${!NGINXWEB@}" "${!USER@}"; do
"$CMDSED" -i "s|@${VAR}@|${!VAR}|g;" "$NGINXENABLE"/rutorrent.conf
done
"$CMDECHO" ""; set "152" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# configuration ssl
"$CMDOPENSSL" req -new -x509 -days 3658 -nodes -newkey rsa:2048 -out "$NGINXSSL"/server.crt -keyout "$NGINXSSL"/server.key <<- EOF
KP
North Korea
Pyongyang
wtf
wtf ltd
wtf.org
EOF
"$CMDRM" -R "${NGINXWEB:?}"/html &> /dev/null
"$CMDRM" "$NGINXENABLE"/default &> /dev/null
# logrotate
"$CMDCP" -f "$FILES"/nginx/logrotate /etc/logrotate.d/nginx
# configuration ssh
"$CMDSED" -i "s/Subsystem[[:blank:]]sftp[[:blank:]]\/usr\/lib\/openssh\/sftp-server/Subsystem sftp internal-sftp/g;" /etc/ssh/sshd_config
"$CMDSED" -i "s/UsePAM/#UsePAM/g;" /etc/ssh/sshd_config
# chroot user
"$CMDCAT" <<- EOF >> /etc/ssh/sshd_config
Match User $USER
ChrootDirectory /home/$USER
EOF
# configuration .rtorrent.rc
FONCTORRENTRC "$USER" "$PORT" "$RUTORRENT"
# torrent welcome
"$CMDCP" -f "$FILES"/rutorrent/Welcome.To.Bonobox.nfo /home/"$USER"/torrents/Welcome.To.Bonobox.nfo
"$CMDCP" -f "$FILES"/rutorrent/Welcome.To.Bonobox.torrent /home/"$USER"/watch/Welcome.To.Bonobox.torrent
# permissions
"$CMDCHOWN" -R "$USER":"$USER" /home/"$USER"
"$CMDCHOWN" root:"$USER" /home/"$USER"
"$CMDCHMOD" 755 /home/"$USER"
FONCSERVICE restart ssh
"$CMDECHO" ""; set "166" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# configuration user rutorrent.conf
FONCRTCONF "$USERMAJ" "$PORT" "$USER"
# config.php
"$CMDMKDIR" "$RUCONFUSER"/"$USER"
FONCPHPCONF "$USER" "$PORT" "$USERMAJ"
# plugins.ini
"$CMDCP" -f "$FILES"/rutorrent/plugins.ini "$RUCONFUSER"/"$USER"/plugins.ini
# script rtorrent
FONCSCRIPTRT "$USER"
FONCSERVICE start "$USER"-rtorrent
# mise en place crontab
"$CMDCRONTAB" -l > rtorrentdem
"$CMDCAT" <<- EOF >> rtorrentdem
#$UPGEOIP 2 9 * * $CMDBASH $SCRIPT/updateGeoIP.sh > /dev/null 2>&1
0 5 * * * $CMDBASH $SCRIPT/backup-session.sh > /dev/null 2>&1
EOF
"$CMDCRONTAB" rtorrentdem
"$CMDRM" rtorrentdem
# htpasswd
FONCHTPASSWD "$USER"
"$CMDECHO" ""; set "168" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
# configuration fail2ban
"$CMDCP" -f "$FILES"/fail2ban/nginx-auth.conf /etc/fail2ban/filter.d/nginx-auth.conf
"$CMDCP" -f "$FILES"/fail2ban/nginx-badbots.conf /etc/fail2ban/filter.d/nginx-badbots.conf
"$CMDCP" -f /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
"$CMDSED" -i "/ssh/,+6d" /etc/fail2ban/jail.local
"$CMDCAT" <<- EOF >> /etc/fail2ban/jail.local
[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
banaction = iptables-multiport
maxretry = 5
[nginx-auth]
enabled = true
port = http,https
filter = nginx-auth
logpath = /var/log/nginx/*error.log
banaction = iptables-multiport
maxretry = 10
[nginx-badbots]
enabled = true
port = http,https
filter = nginx-badbots
logpath = /var/log/nginx/*access.log
banaction = iptables-multiport
maxretry = 5
EOF
FONCSERVICE restart fail2ban
# installation vsftpd
if FONCYES "$SERVFTP"; then
"$CMDAPTGET" install -y vsftpd
"$CMDCP" -f "$FILES"/vsftpd/vsftpd.conf /etc/vsftpd.conf
# récupèration certificats nginx
"$CMDCP" -f "$NGINXSSL"/server.crt /etc/ssl/private/vsftpd.cert.pem
"$CMDCP" -f "$NGINXSSL"/server.key /etc/ssl/private/vsftpd.key.pem
"$CMDTOUCH" /etc/vsftpd.chroot_list
"$CMDTOUCH" /var/log/vsftpd.log
"$CMDCHMOD" 600 /var/log/vsftpd.log
FONCSERVICE restart vsftpd
"$CMDSED" -i "/vsftpd/,+10d" /etc/fail2ban/jail.local
"$CMDCAT" <<- EOF >> /etc/fail2ban/jail.local
[vsftpd]
enabled = true
port = ftp,ftp-data,ftps,ftps-data
filter = vsftpd
logpath = /var/log/vsftpd.log
banaction = iptables-multiport
# or overwrite it in jails.local to be
# logpath = /var/log/auth.log
# if you want to rely on PAM failed login attempts
# vsftpd's failregex should match both of those formats
maxretry = 5
EOF
FONCSERVICE restart fail2ban
"$CMDECHO" ""; set "172" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
fi
# déplacement clé 2048 bits
"$CMDCP" -f /tmp/dhparams.pem "$NGINXSSL"/dhparams.pem
"$CMDCHMOD" 600 "$NGINXSSL"/dhparams.pem
FONCSERVICE restart nginx
# contrôle clé 2048 bits
if [ ! -f "$NGINXSSL"/dhparams.pem ]; then
"$CMDKILL" -HUP "$("$CMDPGREP" -x openssl)"
"$CMDECHO" ""; set "174"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
set "176"; FONCTXT "$1"; "$CMDECHO" -e "${CRED}$TXT1${CEND}"; "$CMDECHO" ""
cd "$NGINXSSL" || exit
"$CMDOPENSSL" dhparam -out dhparams.pem 2048
"$CMDCHMOD" 600 dhparams.pem
FONCSERVICE restart nginx
"$CMDECHO" ""; set "178" "134"; FONCTXT "$1" "$2"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}${CGREEN}$TXT2${CEND}"; "$CMDECHO" ""
fi
# log users
"$CMDECHO" "$HISTOLOG.log">> "$RUTORRENT"/"$HISTOLOG".log
"$CMDECHO" "userlog">> "$RUTORRENT"/"$HISTOLOG".log
"$CMDSED" -i "s/userlog/$USER:5001/g;" "$RUTORRENT"/"$HISTOLOG".log
set "180"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
if [ ! -f "$ARGFILE" ]; then
"$CMDECHO" ""; set "182"; FONCTXT "$1"; "$CMDECHO" -e "${CGREEN}$TXT1${CEND}"
set "184"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND} ${CYELLOW}$USER${CEND}"
set "186"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND} ${CYELLOW}${PASSNGINX}${CEND}"
set "188"; FONCTXT "$1"; "$CMDECHO" -e "${CGREEN}$TXT1${CEND}"; "$CMDECHO" ""
fi
# ajout utilisateur supplémentaire
while :; do
if [ ! -f "$ARGFILE" ]; then
set "190"; FONCTXT "$1"; "$CMDECHO" -n -e "${CGREEN}$TXT1 ${CEND}"
read -r REPONSE
else
if [ -s "$ARGFILE" ]; then
REPONSE="y"
else
REPONSE="n"
fi
fi
if FONCNO "$REPONSE"; then
# fin d'installation
"$CMDECHO" ""; set "192"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
CLEANPASS="$("$CMDGREP" 182 "$BONOBOX"/lang/"$GENLANG".lang | "$CMDCUT" -c5- | "$CMDSED" "s/.$//")"
"$CMDSED" -i "/$CLEANPASS/,+4d" /tmp/install.log
"$CMDCP" -f /tmp/install.log "$RUTORRENT"/install.log
"$CMDPV" -f "$RUTORRENT"/install.log | "$CMDCCZE" -h > "$RUTORRENT"/install.html
"$CMDTRUE" > /var/log/nginx/rutorrent-error.log
if [ -z "$ARGREBOOT" ]; then
"$CMDECHO" ""; set "194"; FONCTXT "$1"; "$CMDECHO" -n -e "${CGREEN}$TXT1 ${CEND}"
read -r REBOOT
else
if [ "$ARGREBOOT" = "reboot-off" ]; then
break
else
"$CMDSYSTEMCTL" reboot
break
fi
fi
if FONCNO "$REBOOT"; then
"$CMDECHO" ""; set "196"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
"$CMDECHO" -e "${CYELLOW}https://$IP/rutorrent/install.html${CEND}"
"$CMDECHO" ""; set "200"; FONCTXT "$1"; "$CMDECHO" -e "${CRED}$TXT1${CEND}"
"$CMDECHO" ""; set "202"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
"$CMDECHO" -e "${CYELLOW}https://$IP/rutorrent/${CEND}"
"$CMDECHO" ""; "$CMDECHO" ""; set "210"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
"$CMDECHO" -e "${CBLUE} Ex_Rat - http://mondedie.fr${CEND}"; "$CMDECHO" ""
break
fi
if FONCYES "$REBOOT"; then
"$CMDECHO" ""; set "196"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
"$CMDECHO" -e "${CYELLOW}https://$IP/rutorrent/install.html${CEND}"
"$CMDECHO" ""; set "202"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
"$CMDECHO" -e "${CYELLOW}https://$IP/rutorrent/${CEND}"
"$CMDECHO" ""; "$CMDECHO" ""; set "210"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"
"$CMDECHO" -e "${CBLUE} Ex_Rat - http://mondedie.fr${CEND}"; "$CMDECHO" ""
"$CMDSYSTEMCTL" reboot
break
fi
fi
if FONCYES "$REPONSE"; then
if [ ! -s "$ARGFILE" ]; then
"$CMDECHO" ""
FONCUSER # demande nom user
"$CMDECHO" ""
FONCPASS # demande mot de passe
else
FONCARG
fi
# récupération 5% root sur /home/user si présent
FONCFSUSER "$USER"
# variable passe nginx
PASSNGINX=${USERPWD}
# ajout utilisateur
"$CMDUSERADD" -M -s /bin/bash "$USER"
# création mot de passe utilisateur
"$CMDECHO" "${USER}:${USERPWD}" | "$CMDCHPASSWD"
# anti-bug /home/user déjà existant
"$CMDMKDIR" -p /home/"$USER"
"$CMDCHOWN" -R "$USER":"$USER" /home/"$USER"
# variable utilisateur majuscule
USERMAJ=$("$CMDECHO" "$USER" | "$CMDTR" "[:lower:]" "[:upper:]")
# création de dossier
"$CMDSU" "$USER" -c ""$CMDMKDIR" -p ~/watch ~/torrents ~/.session ~/.backup-session"
# calcul port
FONCPORT
# configuration .rtorrent.rc
FONCTORRENTRC "$USER" "$PORT" "$RUTORRENT"
# configuration user rutorrent.conf
"$CMDSED" -i '$d' "$NGINXENABLE"/rutorrent.conf
FONCRTCONF "$USERMAJ" "$PORT" "$USER"
# configuration script bakup .session
FONCBAKSESSION
# config.php
"$CMDMKDIR" "$RUCONFUSER"/"$USER"
FONCPHPCONF "$USER" "$PORT" "$USERMAJ"
# chroot user supplèmentaire
"$CMDCAT" <<- EOF >> /etc/ssh/sshd_config
Match User $USER
ChrootDirectory /home/$USER
EOF
FONCSERVICE restart ssh
# plugins.ini
"$CMDCP" -f "$FILES"/rutorrent/plugins.ini "$RUCONFUSER"/"$USER"/plugins.ini
# permissions
"$CMDCHOWN" -R "$WDATA" "$RUTORRENT"
"$CMDCHOWN" -R "$USER":"$USER" /home/"$USER"
"$CMDCHOWN" root:"$USER" /home/"$USER"
"$CMDCHMOD" 755 /home/"$USER"
# script rtorrent
FONCSCRIPTRT "$USER"
FONCSERVICE start "$USER"-rtorrent
# htpasswd
FONCHTPASSWD "$USER"
FONCSERVICE restart nginx
# log users
"$CMDECHO" "userlog">> "$RUTORRENT"/"$HISTOLOG".log
"$CMDSED" -i "s/userlog/$USER:$PORT/g;" "$RUTORRENT"/"$HISTOLOG".log
if [ ! -f "$ARGFILE" ]; then
"$CMDECHO" ""; set "218"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND}"; "$CMDECHO" ""
set "182"; FONCTXT "$1"; "$CMDECHO" -e "${CGREEN}$TXT1${CEND}"
set "184"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND} ${CYELLOW}$USER${CEND}"
set "186"; FONCTXT "$1"; "$CMDECHO" -e "${CBLUE}$TXT1${CEND} ${CYELLOW}${PASSNGINX}${CEND}"
set "188"; FONCTXT "$1"; "$CMDECHO" -e "${CGREEN}$TXT1${CEND}"; "$CMDECHO" ""
fi
fi
done
else
# lancement lancement gestion des utilisateurs
"$CMDCHMOD" +x ./gestion-users.sh
# shellcheck source=/dev/null
source ./gestion-users.sh
fi