forked from xjyxh1/quickbox_setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickbox-setup
1238 lines (1144 loc) · 54.4 KB
/
quickbox-setup
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
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# [QuickBox Installation Script]
#
# GitHub: https://github.com/QuickBox/QuickBox
# Author: QuickBox.IO
# URL: https://plaza.quickbox.io
#
# QuickBox Copyright (C) 2017 QuickBox.io
# Licensed under GNU General Public License v3.0 GPL-3 (in short)
#
# You may copy, distribute and modify the software as long as you track
# changes/dates in source files. Any modifications to our software
# including (via compiler) GPL-licensed code must also be made available
# under the GPL along with build & install instructions.
#
#################################################################################
#Script Console Colors
black=$(tput setaf 0); red=$(tput setaf 1); green=$(tput setaf 2); yellow=$(tput setaf 3);
blue=$(tput setaf 4); magenta=$(tput setaf 5); cyan=$(tput setaf 6); white=$(tput setaf 7);
on_red=$(tput setab 1); on_green=$(tput setab 2); on_yellow=$(tput setab 3); on_blue=$(tput setab 4);
on_magenta=$(tput setab 5); on_cyan=$(tput setab 6); on_white=$(tput setab 7); bold=$(tput bold);
dim=$(tput dim); underline=$(tput smul); reset_underline=$(tput rmul); standout=$(tput smso);
reset_standout=$(tput rmso); normal=$(tput sgr0); alert=${white}${on_red}; title=${standout};
sub_title=${bold}${yellow}; repo_title=${black}${on_green}; message_title=${white}${on_magenta}
#################################################################################
function _string() { perl -le 'print map {(a..z,A..Z,0..9)[rand 62] } 0..pop' 15 ; }
#################################################################################
function _bashrc() {
cp ${local_setup}templates/bashrc.template /root/.bashrc
profile="/root/.profile"
if [ ! -f $profile ]; then
cp ${local_setup}templates/profile.template /root/.profile
fi
}
# intro function (1)
function _intro() {
DISTRO=$(lsb_release -is)
RELEASE=$(lsb_release -rs)
CODENAME=$(lsb_release -cs)
SETNAME=$(lsb_release -rc)
echo
echo
echo "[${repo_title}QuickBox${normal}] ${title} QuickBox Seedbox Installation ${normal} "
echo
echo " ${title} Heads Up! ${normal} "
echo " ${message_title} QuickBox works with the following ${normal} "
echo " ${message_title} Ubuntu 15.10 | 16.04 | 16.10 ${normal} "
echo " ${message_title} Debian 8 ${normal} "
echo
echo
echo "${green}Checking distribution ...${normal}"
if [ ! -x /usr/bin/lsb_release ]; then
echo "It looks like you are running $DISTRO, which is not supported by QuickBox."
echo "Exiting..."
exit 1
fi
echo "$(lsb_release -a)"
echo
if [[ ! "$DISTRO" =~ ("Ubuntu"|"Debian") ]]; then
echo "$DISTRO: ${alert} It looks like you are running $DISTRO, which is not supported by QuickBox ${normal} "
echo 'Exiting...'
exit 1
elif [[ ! "$CODENAME" =~ ("yakkety"|"xenial"|"wily"|"jessie") ]]; then
echo "Oh drats! You do not appear to be running a supported $DISTRO release."
echo "${bold}$SETNAME${normal}"
echo 'Exiting...'
exit 1
fi
}
# check if root function (2)
function _checkroot() {
if [[ $EUID != 0 ]]; then
echo 'This script must be run with root privileges.'
echo 'Exiting...'
exit 1
fi
echo "${green}Congrats! You're running as root. Let's continue${normal} ... "
echo
}
function _checkkernel() {
grsec=$(uname -a | grep -i grs)
if [[ -n $grsec ]]; then
echo -e "Your server is currently running with kernel version: $(uname -r)"
echo -e "Kernels with ${bold}grsec${normal} are not supported"
echo -ne "${bold}${yellow}Would you like QuickBox to install the distribution kernel?${normal} (Default: ${green}${bold}Y${normal}) "; read input
case $input in
[yY] | [yY][Ee][Ss] | "" ) kernel=yes; echo "Your distribution's default kernel will be installed. A reboot will be ${bold}required${normal}." ;;
[nN] | [nN][Oo] ) echo "Installer will not continue. Exiting ... "; exit 0 ;;
*) kernel=yes; echo "Your distribution's default kernel will be installed. A reboot will be ${bold}required${normal}." ;;
esac
if [[ $kernel == yes ]]; then
if [[ $DISTRO == Ubuntu ]]; then
apt-get install -q -y linux-image-generic >>"${OUTTO}" 2>&1
elif [[ $DISTRO == Debian ]]; then
arch=$(uname -m)
if [[ $arch =~ ("i686"|"i386") ]]; then
apt-get install -q -y linux-image-686 >>"${OUTTO}" 2>&1
elif [[ $arch == x86_64 ]]; then
apt-get install -q -y linux-image-amd64 >>"${OUTTO}" 2>&1
fi
fi
mv /etc/grub.d/06_OVHkernel /etc/grub.d/25_OVHkernel
update-grub >>"${OUTTO}" 2>&1
fi
fi
}
# check if create log function (3)
function _logcheck() {
echo -ne "${bold}${yellow}Do you wish to write to a log file?${normal} (Default: ${green}${bold}Y${normal}) "; read input
case $input in
[yY] | [yY][Ee][Ss] | "" ) OUTTO="/root/quickbox.$PPID.log";echo "${bold}Output is being sent to /root/quickbox.${magenta}$PPID${normal}${bold}.log${normal}" ;;
[nN] | [nN][Oo] ) OUTTO="/dev/null 2>&1";echo "${cyan}NO output will be logged${normal}" ;;
*) OUTTO="/root/quickbox.$PPID.log";echo "${bold}Output is being sent to /root/quickbox.${magenta}$PPID${normal}${bold}.log${normal}" ;;
esac
if [[ ! -d /root/tmp ]]; then
sed -i 's/noexec,//g' /etc/fstab
mount -o remount /tmp >>"${OUTTO}" 2>&1
fi
}
# setting system hostname function (7)
function _hostname() {
echo -ne "Please enter a hostname for this server (${bold}Hit ${standout}${green}ENTER${normal} to make no changes${normal}): " ; read input
if [[ -z $input ]]; then
echo "No hostname supplied, no changes made!!"
else
hostname ${input}
echo "${input}">/etc/hostname
echo "Hostname set to ${input}"
fi
echo
}
################################################################################
# RESERVED FOR LETS ENCRYPT SSL INSTALL FUNCTION #
################################################################################
function _askquota() {
echo -ne "${bold}${yellow}Do you wish to use user quotas?${normal} (Default: ${green}${bold}Y${normal}) "; read input
case $input in
[yY] | [yY][Ee][Ss] | "" ) quota="yes";echo "${bold}Quotas will be installed${normal}" ;;
[nN] | [nN][Oo] ) quota="no";echo "${cyan}Quotas will not be installed${normal}" ;;
*) quota="yes";echo "${bold}Quotas will be installed${normal}" ;;
esac
}
function _ask10g() {
echo -ne "${bold}${yellow}Is this a 10 gigabit server?${normal} (Default: ${green}${bold}N${normal}) "; read input
case $input in
[yY] | [yY][Ee][Ss] ) if [[ -d /install ]]; then cd /; else mkdir /install; fi;touch /install/.10g.lock;echo "${bold}The devs are officially jealous${normal}" ;;
[nN] | [nN][Oo] | "" ) echo "${cyan}Who can afford that stuff anyway?${normal}" ;;
*) echo "${cyan}Who can afford that stuff anyway?${normal}" ;;
esac
}
# primary partition question
function _askpartition() {
if [[ $quota == yes ]]; then
echo
echo "##################################################################################"
echo "#${bold} By default the QuickBox script will initiate a build using ${green}/${normal} ${bold}as the${normal}"
echo "#${bold} primary partition for mounting quotas.${normal}"
echo "#"
echo "#${bold} Some providers, such as OVH and SYS force ${green}/home${normal} ${bold}as the primary mount ${normal}"
echo "#${bold} on their server setups. So if you have an OVH or SYS server and have not"
echo "#${bold} modified your partitions, it is safe to choose option ${yellow}2)${normal} ${bold}below.${normal}"
echo "#"
echo "#${bold} If you are not sure:${normal}"
echo "#${bold} I have listed out your current partitions below. Your mountpoint will be"
echo "#${bold} listed as ${green}/home${normal} ${bold}or ${green}/${normal}${bold}. ${normal}"
echo "#"
echo "#${bold} Typically, the partition with the most space assigned is your default.${normal}"
echo "##################################################################################"
echo
lsblk
echo
echo -e "${bold}${yellow}1)${normal} / - ${green}root mount${normal}"
echo -e "${bold}${yellow}2)${normal} /home - ${green}home mount${normal}"
echo -ne "${bold}${yellow}What is your mount point for user quotas?${normal} (Default ${green}1${normal}): "; read version
case $version in
1 | "") primaryroot=root ;;
2) primaryroot=home ;;
*) primaryroot=root ;;
esac
echo "Using ${green}$primaryroot mount${normal} for quotas"
echo
fi
}
function _askcontinue() {
echo
echo "Press ${standout}${green}ENTER${normal} when you're ready to begin or ${standout}${red}Ctrl+Z${normal} to cancel" ;read input
echo
}
# This function blocks an insecure port 1900 that may lead to
# DDoS masked attacks. Only remove this function if you absolutely
# need port 1900. In most cases, this is a junk port.
function _ssdpblock() {
iptables -I INPUT 1 -p udp -m udp --dport 1900 -j DROP
}
# setting locale function (6)
function _locale() {
echo 'LANGUAGE="en_US.UTF-8"' >> /etc/default/locale
echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
if [[ -e /usr/sbin/locale-gen ]]; then locale-gen >>"${OUTTO}" 2>&1
else
apt-get -y update >>"${OUTTO}" 2>&1
apt-get install locales -y >>"${OUTTO}" 2>&1
locale-gen >>"${OUTTO}" 2>&1
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
fi
}
function _askservices() {
DISTRO=$(lsb_release -is)
RELEASE=$(lsb_release -rs)
CODENAME=$(lsb_release -cs)
SETNAME=$(lsb_release -rc)
echo "You are running $DISTRO $CODENAME"
echo "This distribution has support for systemd services. "
echo "Would you like to enable? (recommended) (Default: ${green}${bold}Y${normal})"; read input
case $input in
[yY] | [yY][Ee][Ss] | "" ) cron="no";echo "${bold}Using systemd for process management${normal}" ;;
[nN] | [nN][Oo] ) cron="yes";echo "${cyan}Cron will manage your processes${normal}" ;;
*) cron="no";echo "${bold}Using systemd for process management${normal}" ;;
esac
echo
}
# ask what rtorrent version (8)
function _askrtorrent() {
echo -e "1) rtorrent ${green}0.9.6${normal}"
echo -e "2) rtorrent ${green}0.9.4${normal}"
echo -e "3) rtorrent ${green}0.9.3${normal}"
echo -ne "${bold}${yellow}What version of rtorrent do you want?${normal} (Default ${green}1${normal}): "; read version
case $version in
1 | "") RTVERSION=0.9.6;LTORRENT=0.13.6 ;;
2) RTVERSION=0.9.4;LTORRENT=0.13.4 ;;
3) RTVERSION=0.9.3;LTORRENT=0.13.3 ;;
*) RTVERSION=0.9.6;LTORRENT=0.13.6 ;;
esac
echo "We will be using rtorrent-${green}$RTVERSION${normal}/libtorrent-${green}$LTORRENT${normal}"
echo
}
# ask deluge version (if wanted) (8.1)
function _askdeluge() {
echo -e "1) Deluge ${green}repo${normal} (fastest)"
echo -e "2) Deluge with ${green}libtorrent 1.0.9 (stable)${normal}"
echo -e "3) Deluge with ${green}libtorrent 1.1.1 (dev)${normal}"
echo -e "4) Do not install Deluge"
echo -ne "${bold}${yellow}What version of Deluge do you want?${normal} (Default ${green}1${normal}): "; read version
case $version in
1 | "") DELUGE=REPO ;;
2) DELUGE=1.0.9 ;;
3) DELUGE=1.1.1 ;;
4) DELUGE=NO ;;
*) DELUGE=REPO ;;
esac
echo "We will be using Deluge with Libtorrent ${DELUGE}"
echo
}
# adduser function (9)
function _adduser() {
theshell="/bin/bash";
echo "${bold}${yellow}Add a Master Account user to sudoers${normal}";
echo -n "Username: "; read user
username=$(echo "$user"|sed 's/.*/\L&/')
useradd "${username}" -m -G www-data -s "${theshell}"
echo -n "Password: (hit enter to generate a password) "; read 'password'
if [[ ! -z "${password}" ]]; then
echo "setting password to ${password}"
passwd=${password}
echo "${username}:${passwd}" | chpasswd >>"${OUTTO}" 2>&1
(echo -n "${username}:${REALM}:" && echo -n "${username}:${REALM}:${passwd}" | md5sum | awk '{print $1}' ) >> "${HTPASSWD}"
else
echo "setting password to ${genpass}"
passwd=${genpass}
echo "${username}:${passwd}" | chpasswd >>"${OUTTO}" 2>&1
(echo -n "${username}:${REALM}:" && echo -n "${username}:${REALM}:${passwd}" | md5sum | awk '{print $1}' ) >> "${HTPASSWD}"
fi
printf "${username}:${passwd}" > /root/"$username".info.db
echo
}
# install ffmpeg question (10)
function _askffmpeg() {
echo -ne "${bold}${yellow}Would you like to install ffmpeg? (Used for screenshots)${normal} [${green}y${normal}]es or [n]o: "; read responce
case $responce in
[yY] | [yY][Ee][Ss] | "" ) ffmpeg=yes ;;
[nN] | [nN][Oo] ) ffmpeg=no ;;
*) ffmpeg=yes ;;
esac
echo
}
# ban public trackers [iptables option] (11)
function _denyhosts() {
echo -ne "${bold}${yellow}Block Public Trackers?${normal}: [${green}y${normal}]es or [n]o: "; read responce
case $responce in
[yY] | [yY][Ee][Ss] | "")
echo "[ ${red}- Blocking public trackers -${normal} ]"
cp ${local_setup}templates/trackers.template /etc/trackers
cp ${local_setup}templates/denypublic.template /etc/cron.daily/denypublic
chmod +x /etc/cron.daily/denypublic
cat ${local_setup}templates/hostsTrackers.template >> /etc/hosts
;;
[nN] | [nN][Oo] ) echo "[ ${green}+ Allowing public trackers +${normal} ]"
;;
esac
}
# package and repo addition (silently add php7) _add respo sources_ (12)
function _repos() {
apt-get install -y software-properties-common >>"${OUTTO}" 2>&1
apt-get -y install lsb-release sudo >>"${OUTTO}" 2>&1
if [[ $DISTRO == Ubuntu ]]; then
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y >>"${OUTTO}" 2>&1;
fi
if [[ $DISTRO == Debian ]]; then
echo "deb http://packages.dotdeb.org $(lsb_release -sc) all" > /etc/apt/sources.list.d/dotdeb-php7-$(lsb_release -sc).list
echo "deb-src http://packages.dotdeb.org $(lsb_release -sc) all" >> /etc/apt/sources.list.d/dotdeb-php7-$(lsb_release -sc).list
wget -q https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg >> /dev/null 2>&1
fi
}
# package and repo addition (13) _update and upgrade_
function _updates() {
if [[ $DISTRO == Debian ]]; then
cp ${local_setup}templates/apt.sources/debian.template /etc/apt/sources.list
sed -i "s/RELEASE/${CODENAME}/g" /etc/apt/sources.list
apt-get --yes --force-yes update >>"${OUTTO}" 2>&1
yes '' | apt-get install --force-yes build-essential debian-archive-keyring \
python-software-properties >>"${OUTTO}" 2>&1
apt-get --yes --force-yes install deb-multimedia-keyring >>"${OUTTO}" 2>&1
else
cp ${local_setup}templates/apt.sources/ubuntu.template /etc/apt/sources.list
sed -i "s/RELEASE/${CODENAME}/g" /etc/apt/sources.list
apt-get -y update >>"${OUTTO}" 2>&1
apt-get -y -f install build-essential debian-archive-keyring \
python-software-properties >>"${OUTTO}" 2>&1
#apt-get -y -f --allow-unauthenticated install deb-multimedia-keyring >>"${OUTTO}" 2>&1
fi
if [[ $DISTRO == Debian ]]; then
export DEBIAN_FRONTEND=noninteractive
yes '' | apt-get update >>"${OUTTO}" 2>&1
apt-get -y purge samba samba-common >>"${OUTTO}" 2>&1
yes '' | apt-get upgrade >>"${OUTTO}" 2>&1
else
export DEBIAN_FRONTEND=noninteractive
apt-get -y update >>"${OUTTO}" 2>&1
apt-get -y purge samba samba-common >>"${OUTTO}" 2>&1
apt-get -y upgrade >>"${OUTTO}" 2>&1
fi
if [[ -e /etc/ssh/sshd_config ]]; then
echo "Port 4747" /etc/ssh/sshd_config >> /dev/null 2>&1
sed -i 's/Port 22/Port 4747/g' /etc/ssh/sshd_config
#sed -i 's/SendEnv LANG LC_*/#SendEnv LANG LC_*/g' /etc/ssh/ssh_config
#sed -i 's/AcceptEnv LANG LC_*/#AcceptEnv LANG LC_*/g' /etc/ssh/sshd_config
service ssh restart >>"${OUTTO}" 2>&1
fi
# Create the service lock file directory
if [[ -d /install ]]; then cd /; else mkdir /install; fi
if [[ -d /root/tmp ]]; then cd && rm -r tmp; fi
}
# package and repo addition (14) _install softwares and packages_
function _depends() {
if [[ $DISTRO == Debian ]]; then
yes '' | apt-get install --force-yes fail2ban bc ed sudo screen zip irssi unzip nano bwm-ng htop iotop \
dos2unix subversion dstat automake make mktorrent libtool libcppunit-dev libssl-dev \
pkg-config libxml2-dev libcurl3 libcurl4-openssl-dev libsigc++-2.0-dev \
apache2-utils autoconf cron curl libapache2-mod-fastcgi libapache2-mod-geoip \
libxslt-dev libncurses5-dev yasm pcregrep apache2 php-net-socket libapache2-mod-php7.0 \
php7.0-dev php7.0-geoip libgeoip-dev php7.0 php7.0-fpm php7.0-mbstring php7.0-mysql \
php7.0-curl php7.0-memcached memcached php7.0-gd php7.0-json php7.0-mcrypt php7.0-opcache \
php7.0-xml python3-lxml python-lxml fontconfig comerr-dev ca-certificates libfontconfig1-dev \
libdbd-mysql-perl libdbi-perl libfontconfig1 rar unrar mediainfo ifstat \
ttf-mscorefonts-installer checkinstall dtach cfv libarchive-zip-perl \
libnet-ssleay-perl ca-certificates-java libxslt1-dev \
libxslt1.1 libxml2 libffi-dev python-pip python-dev libhtml-parser-perl libxml-libxml-perl \
libjson-perl libjson-xs-perl libxml-libxslt-perl libapache2-mod-scgi \
vnstat vnstati openvpn >>"${OUTTO}" 2>&1
elif [[ $DISTRO == Ubuntu ]]; then
apt-get -y -f --allow-unauthenticated install build-essential debian-archive-keyring fail2ban bc sudo \
screen zip irssi unzip nano bwm-ng htop iotop git \
dos2unix subversion dstat automake make mktorrent libtool libcppunit-dev libssl-dev \
pkg-config libxml2-dev libcurl3 libcurl4-openssl-dev libsigc++-2.0-dev \
apache2-utils autoconf cron curl libapache2-mod-fastcgi libapache2-mod-geoip \
libxslt-dev libncurses5-dev yasm pcregrep apache2 php-net-socket \
libdbd-mysql-perl libdbi-perl php7.0 php7.0-fpm php7.0-mbstring php7.0-mysql \
php7.0-curl php-memcached memcached php7.0-gd php7.0-json php7.0-mcrypt php7.0-opcache \
php7.0-xml php7.0-zip fontconfig comerr-dev ca-certificates libfontconfig1-dev \
php7.0-geoip libfontconfig1 rar unrar mediainfo ifstat libapache2-mod-php7.0 \
python3-lxml python-lxml ttf-mscorefonts-installer checkinstall dtach cfv libarchive-zip-perl \
libnet-ssleay-perl openjdk-8-jre-headless openjdk-8-jre openjdk-8-jdk libxslt1-dev \
libxslt1.1 libxml2 libffi-dev python-pip python-dev libhtml-parser-perl libxml-libxml-perl \
libjson-perl libjson-xs-perl libxml-libxslt-perl libapache2-mod-scgi \
vnstat vnstati openvpn >>"${OUTTO}" 2>&1
fi
}
function _syscommands() {
mkdir -p /usr/local/bin/quickbox
cp -r ${local_packages}/. /usr/local/bin/quickbox
dos2unix $(find /usr/local/bin/quickbox -type f) >>"${OUTTO}" 2>&1;
chmod +x $(find /usr/local/bin/quickbox -type f) >>"${OUTTO}" 2>&1;
cp /usr/local/bin/quickbox/system/reload /usr/bin/reload
}
function _skel() {
if [[ -d /etc/skel ]]; then rm -r /etc/skel;fi
mkdir /etc/skel
cp -r ${local_setup}templates/skel/. /etc/skel
tar xzf ${local_setup}sources/rarlinux-x64-5.3.0.tar.gz -C ./
cp ./rar/*rar /usr/bin
cp ./rar/*rar /usr/sbin
rm -rf rarlinux*.tar.gz
rm -rf ./rar
wget -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz>>"${OUTTO}" 2>&1
mkdir -p /usr/share/GeoIP>>"${OUTTO}" 2>&1
rm -rf GeoLiteCity.dat.gz
mv GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat>>"${OUTTO}" 2>&1
(echo y;echo o conf prerequisites_policy follow;echo o conf commit)>/dev/null 2>&1|cpan Digest::SHA1 >>"${OUTTO}" 2>&1
(echo y;echo o conf prerequisites_policy follow;echo o conf commit)>/dev/null 2>&1|cpan Digest::SHA >>"${OUTTO}" 2>&1
if [[ $DELUGE != NO ]]; then
mkdir -p /etc/skel/.config/deluge/plugins/
cd /etc/skel/.config/deluge/plugins/
wget -q https://github.com/ratanakvlun/deluge-ltconfig/releases/download/v0.2.5.0/ltConfig-0.2.5.0-py2.7.egg
fi
}
function _qmount() {
# Setup mount points for Quotas
if [[ $quota == yes ]]; then
if [[ $DISTRO == Ubuntu ]]; then
if [[ ${primaryroot} == "root" ]]; then
sed -ie '/\/ / s/defaults/usrjquota=aquota.user,jqfmt=vfsv1,defaults/' /etc/fstab
sed -i 's/errors=remount-ro/usrjquota=aquota.user,jqfmt=vfsv1,errors=remount-ro/g' /etc/fstab
apt-get install -y linux-image-extra-virtual quota >>"${OUTTO}" 2>&1
mount -o remount / || mount -o remount /home >>"${OUTTO}" 2>&1
quotacheck -auMF vfsv1 >>"${OUTTO}" 2>&1
quotaon -uv / >>"${OUTTO}" 2>&1
service quota start >>"${OUTTO}" 2>&1
else
sed -ie '/\/home/ s/defaults/usrjquota=aquota.user,jqfmt=vfsv1,defaults/' /etc/fstab
sed -i 's/errors=remount-ro/usrjquota=aquota.user,jqfmt=vfsv1,errors=remount-ro/g' /etc/fstab
apt-get install -y linux-image-extra-virtual quota >>"${OUTTO}" 2>&1
mount -o remount /home >>"${OUTTO}" 2>&1
quotacheck -auMF vfsv1 >>"${OUTTO}" 2>&1
quotaon -uv /home >>"${OUTTO}" 2>&1
service quota start >>"${OUTTO}" 2>&1
fi
elif [[ $DISTRO == Debian ]]; then
if [[ ${primaryroot} == "root" ]]; then
sed -ie '/\/ / s/defaults/usrjquota=aquota.user,jqfmt=vfsv1,defaults/' /etc/fstab
sed -i 's/errors=remount-ro/usrjquota=aquota.user,jqfmt=vfsv1,errors=remount-ro/g' /etc/fstab
apt-get install -y quota >>"${OUTTO}" 2>&1
mount -o remount / || mount -o remount /home >>"${OUTTO}" 2>&1
quotacheck -auMF vfsv1 >>"${OUTTO}" 2>&1
quotaon -uv / >>"${OUTTO}" 2>&1
service quota start >>"${OUTTO}" 2>&1
else
sed -ie '/\/home/ s/defaults/usrjquota=aquota.user,jqfmt=vfsv1,defaults/' /etc/fstab
sed -i 's/errors=remount-ro/usrjquota=aquota.user,jqfmt=vfsv1,errors=remount-ro/g' /etc/fstab
apt-get install -y quota >>"${OUTTO}" 2>&1
mount -o remount /home >>"${OUTTO}" 2>&1
quotacheck -auMF vfsv1 >>"${OUTTO}" 2>&1
quotaon -uv /home >>"${OUTTO}" 2>&1
service quota start >>"${OUTTO}" 2>&1
fi
fi
touch /install/.quota.lock
fi
}
function _lshell() {
# Setup LShell configuration file
apt-get -y install lshell >> /dev/null 2>&1
cp ${local_setup}templates/lshell.conf.template /etc/lshell.conf
}
# build function for ffmpeg (17)
function _ffmpeg() {
if [[ ${ffmpeg} == "yes" ]]; then
MAXCPUS=$(echo "$(nproc) / 2"|bc)
if [[ $DISTRO == Ubuntu ]]; then
apt-get -y install x265 >>"${OUTTO}" 2>&1
elif [[ $DISTRO == Debian ]]; then
apt-get -y install -t jessie-backports x265 >>"${OUTTO}" 2>&1
fi
mkdir /root/tmp
cd /root/tmp
if [[ -d /root/tmp/ffmpeg ]]; then rm -rf ffmpeg;fi
git clone --depth 1 https://github.com/FFmpeg/FFmpeg.git ffmpeg >>"${OUTTO}" 2>&1
git clone git://github.com/yasm/yasm.git ffmpeg/yasm >>"${OUTTO}" 2>&1
git clone https://github.com/yixia/x264.git ffmpeg/x264 >>"${OUTTO}" 2>&1
############################################################################
## x265 needs to be manually compiled - there is no non-interactive option.
#git clone https://github.com/videolan/x265.git ffmpeg/x265 >>"${OUTTO}" 2>&1
############################################################################
####---- Github Mirror source ----####
#git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg >>"${OUTTO}" 2>&1
############################################################################
cd ffmpeg/yasm
./autogen.sh >>"${OUTTO}" 2>&1
./configure >>"${OUTTO}" 2>&1
make >>"${OUTTO}" 2>&1
make install >>"${OUTTO}" 2>&1
cd ../x264
./configure --enable-static --enable-shared >>"${OUTTO}" 2>&1
make >>"${OUTTO}" 2>&1
make install >>"${OUTTO}" 2>&1
ldconfig >>"${OUTTO}" 2>&1
############################################################################
## x265 needs to be manually compiled - there is no non-interactive option.
#cd ../x265/build/linux
#./make-Makefiles.bash >>"${OUTTO}" 2>&1
#make >>"${OUTTO}" 2>&1
#make install >>"${OUTTO}" 2>&1
#ldconfig >>"${OUTTO}" 2>&1
############################################################################
cd /root/tmp/ffmpeg
export FC_CONFIG_DIR=/etc/fonts
export FC_CONFIG_FILE=/etc/fonts/fonts.conf
./configure --enable-libfreetype --enable-filter=drawtext --enable-fontconfig --disable-asm --enable-libx264 --enable-gpl >>"${OUTTO}" 2>&1
make -j${MAXCPUS} >>"${OUTTO}" 2>&1
make install >>"${OUTTO}" 2>&1
cp /usr/local/bin/ffmpeg /usr/bin >>"${OUTTO}" 2>&1
cp /usr/local/bin/ffprobe /usr/bin >>"${OUTTO}" 2>&1
rm -rf /root/tmp/ffmpeg >>"${OUTTO}" 2>&1
fi
}
# function to enable sudo for www-data function (18)
function _apachesudo() {
rm /etc/sudoers
cp ${local_setup}templates/sudoers.template /etc/sudoers
#if [[ $sudoers == "yes" ]]; then
awk -v username=${username} '/^root/ && !x {print username " ALL=(ALL:ALL) NOPASSWD: ALL"; x=1} 1' /etc/sudoers > /tmp/sudoers;mv /tmp/sudoers /etc
echo -n "${username}" > /etc/apache2/master.txt
#fi
cd
}
# xmlrpc-c function (19)
function _xmlrpc() {
if [[ -d /root/tmp ]]; then rm -r tmp;fi
mkdir /root/tmp && cd /root/tmp
if [[ -d /root/tmp/xmlrpc-c ]]; then rm -rf xmlrpc-c;fi
cp -r ${local_setup}sources/xmlrpc-c_1-33-12/ .
cd xmlrpc-c_1-33-12
chmod +x configure
./configure --prefix=/usr --disable-cplusplus >>"${OUTTO}" 2>&1
make >>"${OUTTO}" 2>&1
chmod +x install-sh
make install >>"${OUTTO}" 2>&1
}
# libtorent function (20)
function _libtorrent() {
if [[ -d /root/tmp ]]; then rm -r tmp;fi
mkdir /root/tmp && cd /root/tmp
MAXCPUS=$(echo "$(nproc) / 2"|bc)
rm -rf xmlrpc-c >>"${OUTTO}" 2>&1
if [[ -e /root/tmp/libtorrent-${LTORRENT}.tar.gz ]]; then rm -rf libtorrent-${LTORRENT}.tar.gz;fi
cp ${local_setup}sources/libtorrent-${LTORRENT}.tar.gz .
tar -xzvf libtorrent-${LTORRENT}.tar.gz >>"${OUTTO}" 2>&1
cd libtorrent-${LTORRENT}
./autogen.sh >>"${OUTTO}" 2>&1
./configure --prefix=/usr >>"${OUTTO}" 2>&1
make -j${MAXCPUS} >>"${OUTTO}" 2>&1
make install >>"${OUTTO}" 2>&1
}
# rtorrent function (21)
function _rtorrent() {
if [[ -d /root/tmp ]]; then rm -r tmp;fi
mkdir /root/tmp && cd /root/tmp
MAXCPUS=$(echo "$(nproc) / 2"|bc)
rm -rf libtorrent-${LTORRENT}* >>"${OUTTO}" 2>&1
if [[ -e /root/tmp/libtorrent-${LTORRENT}.tar.gz ]]; then rm -rf libtorrent-${LTORRENT}.tar.gz;fi
cp ${local_setup}sources/rtorrent-${RTVERSION}.tar.gz .
tar -xzvf rtorrent-${RTVERSION}.tar.gz >>"${OUTTO}" 2>&1
cd rtorrent-${RTVERSION}
./autogen.sh >>"${OUTTO}" 2>&1
./configure --prefix=/usr --with-xmlrpc-c >>"${OUTTO}" 2>&1
make -j${MAXCPUS} >>"${OUTTO}" 2>&1
make install >>"${OUTTO}" 2>&1
cd /root/tmp
ldconfig >>"${OUTTO}" 2>&1
rm -rf /root/tmp/rtorrent-${RTVERSION}* >>"${OUTTO}" 2>&1
touch /install/.rtorrent.lock
}
# deluge function (xx)
function _deluge() {
if [[ $DELUGE == REPO ]]; then
apt-get -q -y update >>"${OUTTO}" 2>&1
apt-get -q -y install deluged deluge-web >>"${OUTTO}" 2>&1
systemctl stop deluged
update-rc.d deluged remove
rm /etc/init.d/deluged
elif [[ $DELUGE == 1.0.9 ]] || [[ $DELUGE == 1.1.1 ]]; then
if [[ $DELUGE == 1.0.9 ]]; then
LTRC=RC_1_0
elif [[ $DELUGE == 1.1.1 ]]; then
LTRC=RC_1_1
fi
apt-get -qy update >/dev/null 2>&1
LIST='build-essential checkinstall libboost-system-dev libboost-python-dev libssl-dev libgeoip-dev libboost-chrono-dev libboost-random-dev
python python-twisted python-openssl python-setuptools intltool python-xdg python-chardet geoip-database python-notify python-pygame
python-glade2 librsvg2-common xdg-utils python-mako'
for depend in $LIST; do
apt-get -qq -y install $depend >>"${OUTTO}" 2>&1
done
git clone -b ${LTRC} https://github.com/arvidn/libtorrent.git >>"${OUTTO}" 2>&1
git clone -b 1.3-stable git://deluge-torrent.org/deluge.git >>"${OUTTO}" 2>&1
cd libtorrent
./autotool.sh >>"${OUTTO}" 2>&1
./configure --enable-python-binding --with-lib-geoip --with-libiconv >>"${OUTTO}" 2>&1 >>"${OUTTO}" 2>&1
make -j$(nproc) >>"${OUTTO}" 2>&1
checkinstall -y --pkgversion=${DELUGE} >>"${OUTTO}" 2>&1
ldconfig
cd ..
cd deluge
python setup.py build >>"${OUTTO}" 2>&1
python setup.py install --install-layout=deb >>"${OUTTO}" 2>&1
python setup.py install_data >>"${OUTTO}" 2>&1
cd ..
rm -r {deluge,libtorrent}
fi
if [[ $DELUGE != NO ]]; then
n=$RANDOM
DPORT=$((n%59000+10024))
DWSALT=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
DWP=$(python ${local_packages}/system/deluge.Userpass.py ${passwd} ${DWSALT})
DUDID=$(python ${local_packages}/system/deluge.addHost.py)
# -- Secondary awk command -- #
#DPORT=$(awk -v min=59000 -v max=69024 'BEGIN{srand(); print int(min+rand()*(max-min+1))}')
DWPORT=$(shuf -i 10001-11000 -n 1)
mkdir -p /home/${username}/.config/deluge/plugins
if [[ ! -f /home/${username}/.config/deluge/plugins/ltConfig-0.2.5.0-py2.7.egg ]]; then
cd /home/${username}/.config/deluge/plugins/
wget -q https://github.com/ratanakvlun/deluge-ltconfig/releases/download/v0.2.5.0/ltConfig-0.2.5.0-py2.7.egg
fi
chmod 755 /home/${username}/.config
chmod 755 /home/${username}/.config/deluge
cp ${local_setup}templates/core.conf.template /home/${username}/.config/deluge/core.conf
cp ${local_setup}templates/web.conf.template /home/${username}/.config/deluge/web.conf
cp ${local_setup}templates/hostlist.conf.1.2.template /home/${username}/.config/deluge/hostlist.conf.1.2
sed -i "s/USERNAME/${username}/g" /home/${username}/.config/deluge/core.conf
sed -i "s/DPORT/${DPORT}/g" /home/${username}/.config/deluge/core.conf
sed -i "s/XX/${ip}/g" /home/${username}/.config/deluge/core.conf
sed -i "s/DWPORT/${DWPORT}/g" /home/${username}/.config/deluge/web.conf
sed -i "s/DWSALT/${DWSALT}/g" /home/${username}/.config/deluge/web.conf
sed -i "s/DWP/${DWP}/g" /home/${username}/.config/deluge/web.conf
sed -i "s/DUDID/${DUDID}/g" /home/${username}/.config/deluge/hostlist.conf.1.2
sed -i "s/DPORT/${DPORT}/g" /home/${username}/.config/deluge/hostlist.conf.1.2
sed -i "s/USERNAME/${username}/g" /home/${username}/.config/deluge/hostlist.conf.1.2
sed -i "s/PASSWD/${passwd}/g" /home/${username}/.config/deluge/hostlist.conf.1.2
echo "${username}:${passwd}:10" > /home/${username}/.config/deluge/auth
chmod 600 /home/${username}/.config/deluge/auth
chown -R ${username}.${username} /home/${username}/.config/
mkdir /home/${username}/dwatch
chown ${username}: /home/${username}/dwatch
mkdir -p /home/${username}/torrents/deluge
chown ${username}: /home/${username}/torrents/deluge
touch /install/.deluge.lock
fi
}
# scgi enable function (22-nixed)
# function _scgi() { ln -s /etc/apache2/mods-available/scgi.load /etc/apache2/mods-enabled/scgi.load >>"${OUTTO}" 2>&1 ; }
# mktorrent function (xx)
function _mktorrent() {
if [[ -d /root/tmp ]]; then rm -r tmp;fi
mkdir /root/tmp && cd /root/tmp
mktorrent_version=1.1
wget --quiet https://github.com/Rudde/mktorrent/archive/v$mktorrent_version.zip -O mktorrent.zip >>"${OUTTO}" 2>&1
unzip -o mktorrent.zip >>"${OUTTO}" 2>&1
cd mktorrent-1.1
make >>"${OUTTO}" 2>&1
make install >>"${OUTTO}" 2>&1
cd ..
rm -rf mktorrent-1.1 && rm -f mktorrent.zip
}
# function to install rutorrent (22)
function _rutorrent() {
cd /srv
if [[ -d /srv/rutorrent ]]; then rm -rf rutorrent;fi
mkdir rutorrent
cp -r ${local_rutorrent}/. rutorrent
}
function _rutorrent-plugins() {
cd /srv/rutorrent
if [[ -d /srv/rutorrent/plugins ]]; then rm -rf plugins;fi
mkdir plugins
cp -R ${local_rplugins}/. plugins
}
# function to install dashboard (23)
function _dashboard() {
cd && mkdir -p /srv/rutorrent/home
cp -r ${local_dashboard}/. /srv/rutorrent/home
touch /srv/rutorrent/home/db/output.log
}
# function to install dashboard (23)
function _fileindexer() {
cd /srv/rutorrent/home
wget --quiet https://release.larsjung.de/h5ai/h5ai-0.29.0.zip >>"${OUTTO}" 2>&1
unzip h5ai-0.29.0.zip >>"${OUTTO}" 2>&1
rm –rf h5ai-0.29.0.zip >>"${OUTTO}" 2>&1
chmod 775 -R _h5ai/private/cache && chmod 775 -R _h5ai/public/cache
apt -y install imagemagick >>"${OUTTO}" 2>&1
echo "#DirectoryIndex index.html index.php /_h5ai/public/index.php" >> /etc/apache2/apache2.conf
ln -s /home/${username}/torrents/rtorrent/ ${username}.rtorrent.downloads
ln -s /home/${username}/torrents/deluge/ ${username}.deluge.downloads
}
# function to configure apache (24)
function _apacheconf() {
cp ${local_setup}templates/aliases-seedbox.conf.template /etc/apache2/sites-enabled/aliases-seedbox.conf
sed -i "s/USERNAME/${username}/g" /etc/apache2/sites-enabled/aliases-seedbox.conf
a2enmod auth_digest >>"${OUTTO}" 2>&1
a2enmod ssl >>"${OUTTO}" 2>&1
a2enmod scgi >>"${OUTTO}" 2>&1
a2enmod rewrite >>"${OUTTO}" 2>&1
mv /etc/apache2/sites-enabled/000-default.conf /etc/apache2/ >>"${OUTTO}" 2>&1
cp ${local_setup}templates/default-ssl.conf.template /etc/apache2/sites-enabled/default-ssl.conf
sed -i "s/USERNAME/${username}/g" /etc/apache2/sites-enabled/default-ssl.conf
sed -i "s/\"REALM\"/\"${REALM}\"/g" /etc/apache2/sites-enabled/default-ssl.conf
sed -i "s/HTPASSWD/\/etc\/htpasswd/g" /etc/apache2/sites-enabled/default-ssl.conf
sed -i "s/PORT/${PORT}/g" /etc/apache2/sites-enabled/default-ssl.conf
sed -i "s/ServerTokens OS/ServerTokens Prod/g" /etc/apache2/conf-enabled/security.conf
sed -i "s/ServerSignature On/ServerSignature Off/g" /etc/apache2/conf-enabled/security.conf
cp ${local_setup}templates/fileshare.conf.template /etc/apache2/sites-enabled/fileshare.conf
sed -i.bak -e "s/post_max_size = 8M/post_max_size = 64M/" \
-e "s/upload_max_filesize = 2M/upload_max_filesize = 92M/" \
-e "s/expose_php = On/expose_php = Off/" \
-e "s/128M/768M/" \
-e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" \
-e "s/;opcache.enable=0/opcache.enable=1/" \
-e "s/;opcache.memory_consumption=64/opcache.memory_consumption=128/" \
-e "s/;opcache.max_accelerated_files=2000/opcache.max_accelerated_files=4000/" \
-e "s/;opcache.revalidate_freq=2/opcache.revalidate_freq=240/" /etc/php/7.0/fpm/php.ini
sed -i.bak -e "s/post_max_size = 8M/post_max_size = 64M/" \
-e "s/upload_max_filesize = 2M/upload_max_filesize = 92M/" \
-e "s/expose_php = On/expose_php = Off/" \
-e "s/memory_limit = 128M/memory_limit = 768M/" \
-e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" \
-e "s/;opcache.enable=0/opcache.enable=1/" \
-e "s/;opcache.memory_consumption=64/opcache.memory_consumption=128/" \
-e "s/;opcache.max_accelerated_files=2000/opcache.max_accelerated_files=4000/" \
-e "s/;opcache.revalidate_freq=2/opcache.revalidate_freq=240/" /etc/php/7.0/apache2/php.ini
# ensure opcache module is activated
phpenmod -v 7.0 opcache >>"${OUTTO}" 2>&1
# these modules are purely experimental
#a2enmod proxy_fcgi >>"${OUTTO}" 2>&1
#a2dismod mpm_prefork >>"${OUTTO}" 2>&1
#a2enmod mpm_worker >>"${OUTTO}" 2>&1
# ensure fastcgi module is activated
a2enmod actions >>"${OUTTO}" 2>&1
a2enmod fastcgi >>"${OUTTO}" 2>&1
a2enmod proxy_fcgi setenvif >>"${OUTTO}" 2>&1
a2enconf php7.0-fpm >>"${OUTTO}" 2>&1
#sed -i 's/memory_limit = 128M/memory_limit = 768M/g' /etc/php/7.0/apache2/php.ini
}
# function to configure first user config (25)
function _rconf() {
cp ${local_setup}templates/rtorrent.rc.template /home/${username}/.rtorrent.rc
mkdir -p /home/${username}/torrents/rtorrent
chown -R ${username}: /home/${username}/torrents
sed -i "s/USERNAME/${username}/g" /home/${username}/.rtorrent.rc
sed -i "s/XXX/${PORT}/g" /home/${username}/.rtorrent.rc
sed -i "s/YYY/${PORTEND}/g" /home/${username}/.rtorrent.rc
if [[ -f /install/.10g.lock ]]; then
sed -i "s/hrottle.max_peers.normal.set = 100/hrottle.max_peers.normal.set = 300/g" /home/${username}/.rtorrent.rc
sed -i "s/throttle.max_uploads.global.set = 100/throttle.max_uploads.global.set = 300/g" /home/${username}/.rtorrent.rc
fi
}
# function to set proper diskspace plugin (26)
function _plugins() {
cd "${rutorrent}plugins/"
if [[ ${primaryroot} == "root" ]]; then
rm -r ${rutorrent}plugins/diskspaceh
else
rm -r ${rutorrent}plugins/diskspace
fi
cp /srv/rutorrent/home/fileshare/.htaccess /srv/rutorrent/plugins/fileshare/
cd /srv/rutorrent/home/fileshare/
rm -rf share.php
ln -s ../../plugins/fileshare/share.php
cp ${local_setup}templates/rutorrent/plugins/fileshare/conf.php.template /srv/rutorrent/plugins/fileshare/conf.php
sed -i 's/homeDirectory/topDirectory/g' /srv/rutorrent/plugins/filemanager/flm.class.php
sed -i 's/homeDirectory/topDirectory/g' /srv/rutorrent/plugins/filemanager/settings.js.php
sed -i 's/showhidden: true,/showhidden: false,/g' "${rutorrent}plugins/filemanager/init.js"
chown -R www-data.www-data "${rutorrent}"
cd ${rutorrent}plugins/theme/themes/
git clone https://github.com/QuickBox/club-QuickBox club-QuickBox >>"${OUTTO}" 2>&1
chown -R www-data:www-data club-QuickBox
cd ${rutorrent}plugins
perl -pi -e "s/\$defaultTheme \= \"\"\;/\$defaultTheme \= \"club-QuickBox\"\;/g" ${rutorrent}plugins/theme/conf.php
rm -rf ${rutorrent}plugins/tracklabels/labels/nlb.png
# Needed for fileupload
# wget http://ftp.nl.debian.org/debian/pool/main/p/plowshare/plowshare4_2.1.3-1_all.deb -O plowshare4.deb >>"${OUTTO}" 2>&1
# wget http://ftp.nl.debian.org/debian/pool/main/p/plowshare/plowshare_2.1.3-1_all.deb -O plowshare.deb >>"${OUTTO}" 2>&1
apt-get -y install plowshare >>"${OUTTO}" 2>&1
dpkg -i plowshare*.deb >>"${OUTTO}" 2>&1
rm -rf plowshare*.deb >>"${OUTTO}" 2>&1
cd /root
mkdir -p /root/bin
git clone https://github.com/mcrapet/plowshare.git ~/.plowshare-source >>"${OUTTO}" 2>&1
cd ~/.plowshare-source >>"${OUTTO}" 2>&1
make install PREFIX=$HOME >>"${OUTTO}" 2>&1
cd && rm -rf .plowshare-source >>"${OUTTO}" 2>&1
apt-get -f install >>"${OUTTO}" 2>&1
mkdir -p /srv/rutorrent/conf/users/"${username}"/plugins/fileupload/
chmod 775 /srv/rutorrent/plugins/fileupload/scripts/upload
cp /srv/rutorrent/plugins/fileupload/conf.php /srv/rutorrent/conf/users/"${username}"/plugins/fileupload/conf.php
chown -R www-data: /srv/rutorrent/conf/users/"${username}"
# Set proper permissions to filemanager so it may execute commands
find /srv/rutorrent/plugins/filemanager/scripts -type f -exec chmod 755 {} \;
}
# function autodl to install autodl irssi scripts (27)
function _autodl() {
mkdir -p "/home/${username}/.irssi/scripts/autorun/" >>"${OUTTO}" 2>&1
cd "/home/${username}/.irssi/scripts/"
# Grab the most recent version of AutoDL-trackers
#curl -sL https://api.github.com/repos/autodl-community/autodl-trackers/releases/latest | grep -Po '(?<="browser_download_url": ")(.*-v[\d.]+.zip)' | xargs wget --quiet -O autodl-trackers.zip
#cd AutodlIrssi
#rm -rf trackers
#unzip /home/${username}/.irssi/scripts/autodl-trackers.zip -d /home/${username}/.irssi/scripts/AutodlIrssi/trackers
# Grab the most recent version of AutoDL
curl -sL http://git.io/vlcND | grep -Po '(?<="browser_download_url": ")(.*-v[\d.]+.zip)' | xargs wget --quiet -O autodl-irssi.zip
unzip -o autodl-irssi.zip >>"${OUTTO}" 2>&1
#cd "/home/${username}/.irssi/scripts/"
rm autodl-irssi.zip
#&& rm autodl-trackers.zip
cp autodl-irssi.pl autorun/
mkdir -p "/home/${username}/.autodl" >>"${OUTTO}" 2>&1
touch "/home/${username}/.autodl/autodl.cfg"
chown ${username}: /home/${username}/.autodl/autodl.cfg
touch /install/.autodlirssi.lock
cat >"/home/${username}/.autodl/autodl2.cfg"<<ADC
[options]
gui-server-port = ${AUTODLPORT}
gui-server-password = ${AUTODLPASSWORD}
ADC
chown -R "${username}.${username}" "/home/${username}/.irssi/"
chown -R "${username}.${username}" "/home/${username}"
}
# function to make dirs for first user (28)
function _makedirs() {
#mkdir /home/"${username}"/{torrents,.sessions,watch} >>"${OUTTO}" 2>&1
cp -r /etc/skel/. /home/"${username}"
chown -r "${username}".www-data /home/"${username}" >>"${OUTTO}" 2>&1 #/{torrents,.sessions,watch,.rtorrent.rc} >>"${OUTTO}" 2>&1
usermod -a -G www-data "${username}" >>"${OUTTO}" 2>&1
usermod -a -G "${username}" www-data >>"${OUTTO}" 2>&1
}
# function to make crontab .statup file (29)
#function _cronfile() {
# cp ${local_setup}templates/startup.template /home/${username}/.startup
# chmod 775 /home/${username}/.startup
# if [[ $DELUGE != NO ]]; then
# sed -i 's/DELUGEWEB_CLIENT=no/DELUGEWEB_CLIENT=yes/g' /home/${username}/.startup
# sed -i 's/DELUGED_CLIENT=no/DELUGED_CLIENT=yes/g' /home/${username}/.startup
#fi
#}
# function to configure first user config.php (30)
function _ruconf() {
mkdir -p ${rutorrent}conf/users/${username}/
cp ${local_setup}templates/rutorrent.users.config.template ${rutorrent}conf/users/${username}/config.php
chown -R www-data.www-data "${rutorrent}conf/users/" >>"${OUTTO}" 2>&1
if [[ ${primaryroot} == "root" ]]; then
sed -i "/diskuser/c\$diskuser = \"\/\";" /srv/rutorrent/conf/users/${username}/config.php
else
sed -i "/diskuser/c\$diskuser = \"\/home\";" /srv/rutorrent/conf/users/${username}/config.php
fi
sed -i "/quotaUser/c\$quotaUser = \"${username}\";" /srv/rutorrent/conf/users/${username}/config.php
sed -i "s/USERNAME/${username}/g" /srv/rutorrent/conf/users/${username}/config.php
sed -i "s/XXX/${PORT}/g" /srv/rutorrent/conf/users/${username}/config.php
sed -i "s/YYY/${AUTODLPORT}/g" /srv/rutorrent/conf/users/${username}/config.php
sed -i "s/ZZZ/\"${AUTODLPASSWORD}\"/g" /srv/rutorrent/conf/users/${username}/config.php
}
# function to install pure-ftpd (31)
function _installftpd() {
apt-get purge -y vsftpd pure-ftpd >>"${OUTTO}" 2>&1
apt-get autoremove >>"${OUTTO}" 2>&1
apt-get install -y pure-ftpd >>"${OUTTO}" 2>&1
}
# function to configure pure-ftpd (32)
function _ftpdconfig() {
cp ${local_setup}templates/openssl.cnf.template /root/.openssl.cnf
mkdir -p /etc/ssl/private/
openssl req -config /root/.openssl.cnf -x509 -nodes -days 7300 -newkey rsa:1024 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem >/dev/null 2>&1
#cp ${local_setup}templates/vsftpd.conf.template /etc/vsftpd.conf
echo "no" > /etc/pure-ftpd/conf/AllowAnonymousFXP
echo "ye" > /etc/pure-ftpd/conf/AllowUserFXP
echo "yes" > /etc/pure-ftpd/conf/AnonymousCantUpload
echo "no" > /etc/pure-ftpd/conf/AnonymousCanCreateDirs
echo "no" > /etc/pure-ftpd/conf/AnonymousOnly
echo "yes" > /etc/pure-ftpd/conf/AntiWarez
echo "5757" > /etc/pure-ftpd/conf/Bind
echo "yes" > /etc/pure-ftpd/conf/Daemonize
echo "no" > /etc/pure-ftpd/conf/DisplayDotFiles
echo "yes" > /etc/pure-ftpd/conf/DontResolve
echo "10" > /etc/pure-ftpd/conf/MaxClientsPerIP
echo "1000" > /etc/pure-ftpd/conf/MinUID
echo "yes" > /etc/pure-ftpd/conf/NoAnonymous
echo "yes" > /etc/pure-ftpd/conf/ProhibitDotFilesRead
echo "50000 50020" > /etc/pure-ftpd/conf/PassivePortRange
echo "yes" > /etc/pure-ftpd/conf/ProhibitDotFilesRead
echo "yes" > /etc/pure-ftpd/conf/UnixAuthentication
echo "2" > /etc/pure-ftpd/conf/TLS
}
# The following function makes necessary changes to Network and TZ settings needed for
# the proper functionality of the QuickBox Dashboard.
function _quickstats() {
# Dynamically adjust to use the servers active network adapter
printf "${IFACE}" > /srv/rutorrent/home/db/interface.txt
printf "${username}" > /srv/rutorrent/home/db/master.txt
# Use server timezone
cd /usr/share/zoneinfo
find * -type f -exec sh -c "diff -q /etc/localtime '{}' > /dev/null && echo {}" \; > ~/tz.txt
cd ~
LOCALE=en_GB.UTF-8
LANG=lang_en
sed -i "s/LOCALE/${locale}/g" /srv/rutorrent/home/inc/localize.php
sed -i "s/LANG/${lang}/g" /srv/rutorrent/home/inc/localize.php
#echo " date_default_timezone_set('$(cat tz.txt)');" >> /srv/rutorrent/home/widgets/config.php
#echo "" >> /srv/rutorrent/home/widgets/config.php
#echo "?>" >> /srv/rutorrent/home/widgets/config.php
if [[ ${primaryroot} == "home" ]]; then
cd /srv/rutorrent/home/widgets && rm disk_data.php
mv disk_datah.php disk_data.php
chown -R www-data:www-data /srv/rutorrent/home/widgets
else
rm /srv/rutorrent/home/widgets/disk_datah.php
fi
}
function _quickconsole() {
PUBLICIP=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}')
cat >/etc/profile<<EOF
echo " Welcome Back !"
echo " * Dashboard: https://${PUBLICIP}"
echo " * Support: https://plaza.quickbox.io"
echo " * Donate: https://quickbox.io/donate"