forked from Kerwood/Rtorrent-Auto-Install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rtorrent-Auto-Install-1.1.0-Raspbian-Wheezy-Nginx
1790 lines (1636 loc) · 62.6 KB
/
Rtorrent-Auto-Install-1.1.0-Raspbian-Wheezy-Nginx
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
# PLEASE DO NOT SET ANY OF THE VARIABLES, THEY WILL BE POPULATED IN THE MENU
clear
# Formatting variables
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2)
LBLUE=$(tput setaf 6)
RED=$(tput setaf 1)
PURPLE=$(tput setaf 5)
# NOTICE: Change rtorrent, libtorrent, rutorrent versions when update are available
RTORRENT_VERSION="0.9.6"
LIBTORRENT_VERSION="0.13.6"
RUTORRENT_VERSION="3.6"
# Used for choose what version of xmlrpc is installed
XMLRPC_VERSION=""
# Used for select best CFLAGS under compiling stage
# CFLAGS for the rpi B and B+
# Need to tested before use it on production systems
# CFLAGS="-march=armv6 -mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math -pipe -O3"
# maybe this is more specific for the hardware, but only work on gcc 4.9+
# CFLAGS="-march=armv6zk -mcpu=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -ffast-math -pipe -O3"
# CFLAGS for the rpi 2
# cause have a different SoC and need to be tested a lot
# before make it 'stable' and 'secure' this flags
# On the official raspberry forum say that can be used -O4 optimization, anyway -O3 is just enough for now
# Because NEON floating point don't follow (for now) entirely the IEEE standard
# need to be added with '-mfpu=neon-vpfv4' this flags '-funsafe-math-optimizations'
# More info at https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html - search for NEON instruction
# CFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -funsafe-math-optimizations -O3"
# Another flags for RPI2 can be this
# CFLAGS="-march=armv7-a -mfpu=vfpv4 -mfloat-abi=hard -funsafe-math-optimizations -O3"
# is less specific cause use '-march=armv7-a' instead of '-mtune=cortex-a7' and not use
# NEON floating point but just the basic version '-mfpu=vpfuv4', anyway for now is recommend to use
# '-funsafe-math-optimizations' with the '-mfpu=vpfuv4' or '-mfpu=neon-vpfv4'
COMPILE_FLAGS=""
# RPI version showed on the installation menu
RPI_VERSION=""
# The system user rtorrent is going to run as
RTORRENT_USER=""
# The user that is going to log into rutorrent (htaccess)
WEB_USER=""
# Array with webusers including their hashed paswords
WEB_USER_ARRAY=()
# Used for switch temp dirs to new one
NEW_DIR=""
# Temporary install folder for compiling
TEMP_INSTALL_DIR="/tmp"
# Temporary download folder for plugins
TEMP_PLUGIN_DIR="/tmp/rutorrentPlugins"
# Variable to understand what is needed for make a plugin work
PLUGIN_NEEDS=""
# Array of downloaded plugins
PLUGIN_ARRAY=()
# rTorrent users home dir
RTORRENT_HOME_DIR=""
# Function to check if running user is root
function CHECK_ROOT {
if [[ "$(id -u)" != "0" ]]; then
echo "Error! You must be a root user to run this script,\n please use any root user to continue." 1>&2
exit 1
fi
}
# Check rpi version for use the right compile flags and for show your version on main menu
# All the revision number is taken from the page for raspberry on elinux.org wiki and from raspberrypi-spy blog
# http://elinux.org/RPi_HardwareHistory#Board_Revision_History
# http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/
function CHECK_RPI_VERSION {
# This is for detect more board, like Banana Pi and similar
HW_FAMILY_SOC="$(grep Hardware /proc/cpuinfo | cut -d " " -f 2)"
# This is for found the revision for mini boards
HW_SOC_REVISION="$(grep Revision /proc/cpuinfo | cut -d " " -f 2)"
if [[ $HW_FAMILY_SOC == "BCM2708" ]]; then
if [[ $HW_SOC_REVISION == "0002" || $HW_SOC_REVISION == "0003" ]]; then
RASPBERRY_VERSION="B rev. 1.0 - 256MB RAM"
COMPILE_FLAGS=1
elif [[ $HW_SOC_REVISION == "0004" || $HW_SOC_REVISION == "0005" || $HW_SOC_REVISION == "0006" ]]; then
RASPBERRY_VERSION="B rev. 2.0 - 256MB RAM"
COMPILE_FLAGS=1
elif [[ $HW_SOC_REVISION == "0007" || $HW_SOC_REVISION == "0008" || $HW_SOC_REVISION == "0009" ]]; then
RASPBERRY_VERSION="A rev. 2.0 - 256MB RAM"
COMPILE_FLAGS=1
elif [[ $HW_SOC_REVISION == "000d" || $HW_SOC_REVISION == "000e" || $HW_SOC_REVISION == "000f" ]]; then
RASPBERRY_VERSION="B rev. 2.0 - 512MB RAM"
COMPILE_FLAGS=1
elif [[ $HW_SOC_REVISION == "0010" ]]; then
RASPBERRY_VERSION="B+ rev. 1.0 - 512MB RAM"
COMPILE_FLAGS=1
elif [[ $HW_SOC_REVISION == "0012" ]]; then
RASPBERRY_VERSION="A+ rev. 1.0 - 256MB RAM"
COMPILE_FLAGS=1
fi
elif [[ $HW_FAMILY_SOC == "BCM2709" ]]; then
if [[ $HW_SOC_REVISION == "a01041" || $HW_SOC_REVISION == "a21041" ]]; then
RASPBERRY_VERSION="2 B - 1GB RAM"
COMPILE_FLAGS=2
fi
else
RASPBERRY_VERSION="Unknown"
COMPILE_FLAGS=0
fi
}
# License
function LICENSE {
clear
echo "${BOLD}--------------------------------------------------------------------------------"
echo " THE BEER-WARE LICENSE (Revision 42):"
echo " <[email protected]> wrote this script. As long as you retain this notice you"
echo " can do whatever you want with this stuff. If we meet some day, and you think"
echo " this stuff is worth it, you can buy me a beer in return."
echo
echo " - ${LBLUE}Patrick Kerwood @ LinuxBloggen.dk${NORMAL}"
echo "${BOLD}--------------------------------------------------------------------------------${NORMAL}"
echo
read -p " Press any key to continue..." -n 1
}
# Check if apache2 is installed and remove or disable it
function CHECK_APACHE_INST {
count=0
while [ $count -eq 0 ]; do
APACHE_CHECK="$(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed")"
if [[ $APACHE2_CHECK -eq 1 ]; then
echo -e " Apache2 is installed on this system, for avoid errors is required to unistall it\n or just remove the service from start at boot."
echo
read -p " Do you want to remove the service from start at boot? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
service apache2 stop >> /dev/null
update-rc.d -f apache2 remove >> /dev/null
clear
echo " Apache2 service is removed from init.d"
echo " ${BOLD}This step is completely optional and not required for continue${NORMAL}"
echo
read -p " Do you want to complete uninstall apache2 and related packages? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
count=1
clear
apt-get -y purge apache2
apt-get -y autoremove
elif [[ $REPLY =~ [Nn]$ ]]; then
count=1
else
error="${RED} Can't understand your choise!${NORMAL}"
fi
elif [[ $REPLY =~ [Nn]$ ]]; then
count=1
else
error="${RED} Can't understand your choise!${NORMAL}"
fi
else
count=1
fi
done
}
# Checks for apache2-utils and unzip if it's installed. It's needed to make the WebUI user/s
function WEB_USER_UTILS {
count=0
while [ $count -eq 0 ]; do
AP_UT_CHECK="$(dpkg-query -W -f='${Status}' apache2-utils 2>/dev/null | grep -c "ok installed")"
UNZIP_CHECK="$(dpkg-query -W -f='${Status}' unzip 2>/dev/null | grep -c "ok installed")"
HEADER
if [[ $AP_UT_CHECK -ne 1 && $UNZIP_CHECK -ne 1 ]]; then
echo " Both packages \"apache2-utils\" and \"unzip\" is not installed and is needed for continue."
echo -e $error
unset error
read -p " Do you want to continue? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
clear
apt-get -y install apache2-utils unzip
count=1
elif [[ $REPLY =~ [Nn]$ ]]; then
exit
else
error="${RED} Can't understand your choise!${NORMAL}"
fi
elif [[ $AP_UT_CHECK -ne 1 ]]; then
echo " Package \"apache2-utils\" is not installed and is needed for continue."
echo -e $error
unset error
read -p " Do you want to continue? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
clear
apt-get -y install apache2-utils
count=1
elif [[ $REPLY =~ [Nn]$ ]]; then
exit
else
error="${RED} Can't understand your choise!${NORMAL}"
fi
elif [[ $UNZIP_CHECK -ne 1 ]]; then
echo " Package \"unzip\" is not installed and is needed for continue."
echo -e $error
unset error
read -p " Do you want to continue? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
clear
apt-get -y install unzip
count=1
elif [[ $REPLY =~ [Nn]$ ]]; then
exit
else
error="${RED} Can't understand your choise!${NORMAL}"
fi
else
count=1
fi
done
}
# Function to check or change your plugins folders
function CHECK_PLUGINS_FOLDER {
echo " Please enter the path to your rutorrent plugins folder."
echo -n " Leave blank for default [/var/www/rutorrent/plugins]: "
read DIR
if [[ -z $DIR ]]; then
PLUGINS_DIR="/var/www/rutorrent/plugins"
else
count=0
while [ $count -eq 0 ]; do
if [[ ! -d $DIR ]]; then
echo
echo -e "${RED} Error! This folder not exits.${NORMAL}"
echo
echo " It's possible to create it."
read -p " Do you want to create $DIR folder ?" -n 1
if [[ $REPLY =~ [Yy]$ ]]; then
count=1
mkdir -vp $DIR
PLUGINS_DIR="$DIR"
elif [[ $REPLY =~ [Nn]$ ]]; then
count=1
CHECK_PLUGINS_FOLDER
else
count=0
error="${RED} Can't understand your choice !${NORMAL}"
fi
fi
done
fi
}
# Function to set the system user, rtorrent is going to run as
function SET_RTORRENT_USER {
count=0
while [ $count -eq 0 ]; do
SUDO_CHECK="$(dpkg-query -W -f='${Status}' sudo 2>/dev/null | grep -c "ok installed")"
HEADER
echo -e $error
unset error
echo -n " Please type a valid system user: "
read RTORRENT_USER
if [[ -z $(cat /etc/passwd | grep "^$RTORRENT_USER:") ]]; then
HEADER
echo " ${BOLD}The user \"$RTORRENT_USER\" does not exist!${NORMAL}"
echo
echo " [1] - Create the \"$RTORRENT_USER\" user"
echo " [2] - Create a new user"
echo
echo " [0] - Back"
echo
echo -e $error
unset error
echo -n " What you want to do? "
read -e user
case $user in
1)
# This method is for create a new system user previously seletected
# add them to the default group or to sudo group and create a new home directory for it
USERNAME="$RTORRENT_USER"
HEADER
echo "${BOLD} A password is required and a blank password is not allowed.${NORMAL}"
echo
echo " Username chosen: ${BOLD}$USERNAME${NORMAL}"
read -s -p " Enter password: " PWD
egrep "^$USERNAME" /etc/passwd >/dev/null
if [[ ! -n $PWD ]]; then
echo && echo
echo "${BOLD} An empty password is not allowed!${NORMAL}"
echo
read -p " Press any key to continue..." -n 1
else
# This perl command is for create encrypted password, is a needed passage
# for create a new user. An empy password is not possibile
ENCRYPTED_PASSWORD=$(perl -e 'print crypt($ARGV[0], "password")' $PWD)
# Check for 'home' dir, this is for custom installation of the os
if [[ ! -d "/home/" ]]; then
mkdir -p /home/
fi
if [[ $SUDO_CHECK -ne 1 ]]; then
useradd -m -p $ENCRYPTED_PASSWORD $USERNAME
else
echo && echo
echo "The package \"sudo\" seem to be installed."
read -p " You want to add the new user to 'sudo' group? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
# Add a user to 'sudo' group, if the package is installed
useradd -m -G sudo -p $ENCRYPTED_PASSWORD $USERNAME
fi
fi
if [[ $? -eq 0 ]]; then
RTORRENT_USER="$USERNAME"
RTORRENT_HOME_DIR=$(cat /etc/passwd | grep "$RTORRENT_USER": | cut -d: -f6)
count=1
echo && echo
echo " ${GREEN}User has been added to system!${NORMAL}"
echo
read -p " Press any key to continue..." -n 1
else
echo && echo
echo " ${RED}Failed to add a user!${NORMAL}"
echo
read -p " Press any key to continue..." -n 1
fi
fi
;;
2)
# This method is for create a new system user, add them to the default group
# or to sudo group and create a new home directory for it
HEADER
echo "${BOLD} A password is required and a blank password is not allowed.${NORMAL}"
echo
read -p " Enter username: " USERNAME
read -s -p " Enter password: " PWD
egrep "^$USERNAME" /etc/passwd >/dev/null
if [[ $? -eq 0 ]]; then
echo && echo
echo "${BOLD} The user \"$USERNAME\" exists!${NORMAL}"
echo
read -p " Press any key to continue..." -n 1
elif [[ ! -n $PWD ]]; then
echo && echo
echo "${BOLD} An empty password is not allowed!${NORMAL}"
echo
read -p " Press any key to continue..." -n 1
else
# This perl command is for create encrypted password, is a needed passage
# for create a new user. An empy password is not possibile
ENCRYPTED_PASSWORD=$(perl -e 'print crypt($ARGV[0], "password")' $PASSWORD)
# Check for /home/ dir, this is for custom installation for the os
if [[ ! -d "/home/" ]]; then
mkdir -p /home/
fi
if [[ $SUDO_CHECK -ne 1 ]]; then
useradd -m -p $ENCRYPTED_PASSWORD $USERNAME
else
echo && echo
read -p " You want to add the new user to 'sudo' group? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
# Add a user to 'sudo' group, if the package is installed
useradd -m -G sudo -p $ENCRYPTED_PASSWORD $USERNAME
fi
fi
if [ $? -eq 0 ]; then
RTORRENT_USER="$USERNAME"
RTORRENT_HOME_DIR=$(cat /etc/passwd | grep "$RTORRENT_USER": | cut -d: -f6)
count=1
echo && echo
echo " ${GREEN}User has been added to system!${NORMAL}"
echo
read -p " Press any key to continue..." -n 1
else
echo && echo
echo " ${RED}Failed to add a user!${NORMAL}"
echo
read -p " Press any key to continue..." -n 1
fi
fi
;;
0)
SET_RTORRENT_USER
;;
*)
echo
error="${RED} Not a usable number!${NORMAL}"
;;
esac
elif [[ $(cat /etc/passwd | grep "^$RTORRENT_USER:" | cut -d: -f3) -lt 999 ]]; then
echo
error="${BOLD} The UID for \"$RTORRENT_USER\" is too low!${NORMAL}"
elif [[ $RTORRENT_USER == nobody ]]; then
echo
error="${BOLD} You cant use \"$RTORRENT_USER\" as user!${NORMAL}"
else
RTORRENT_HOME_DIR=$(cat /etc/passwd | grep "$RTORRENT_USER": | cut -d: -f6)
count=1
fi
done
}
# Function to create users for the webinterface
function SET_WEB_USER {
while true; do
HEADER
echo "Please type the username for the web interface, a system user is not required."
echo "${BOLD}A blank password is possible, but not recommended.${NORMAL}"
echo -e $error
unset error
echo -n "Username for web interface: "
read WEB_USER
USER=$(htpasswd -n $WEB_USER 2>/dev/null)
if [[ $? = 0 ]]; then
WEB_USER_ARRAY+=($USER)
break
else
echo
error="${RED}You have entered an unusable username and/or different password.${NORMAL}"
fi
done
}
# Function to list webinterface users in the menu
function LIST_WEB_USERS {
for i in ${WEB_USER_ARRAY[@]}; do
USER_CUT=$(echo $i | cut -d \: -f 1)
echo -n " $USER_CUT"
done
}
# Function to list downloaded plugins in the menu
function LIST_PLUGINS {
if [ ${#PLUGIN_ARRAY[@]} -eq 0 ]; then
echo " No plugins downloaded!"
else
for i in "${PLUGIN_ARRAY[@]}"; do
echo -e " - $i"
done
fi
}
# Function to change temp installation directory
function CHANGE_TEMP_INSTALL_DIR {
count=0
while [ $count -eq 0 ]; do
HEADER
echo " If the directory don't exist, a possibility to create it's given."
read -p "Do you want to change the temporany installation directory? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
echo -n "Please type a valid system user: "
read NEW_DIR
if [[ -d $NEW_DIR ]]; then
# Change the old dir with the new one
TEMP_INSTALL_DIR="$NEW_DIR"
count=1
else
echo "${RED}Something went wrong!"
echo " The directory chosen \"$NEW_DIR\" don't exist.${NORMAL}"
echo
read -p "Do you want to create \"$NEW_DIR\"? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
# Create the new directory
mkdir -vp $NEW_DIR
# Change the old dir with the new one
TEMP_INSTALL_DIR="$NEW_DIR"
count=1
else
count=0
fi
count=0
fi
elif [[ $REPLY =~ [Nn]$ ]]; then
count=1
else
echo "${RED}Something went wrong...Error!${NORMAL}"
read -p " Press any key to continue..." -n 1
fi
done
}
# Function to change temp plugins directory
function CHANGE_TEMP_PLUGINS_DIR {
count=0
while [ $count -eq 0 ]; do
HEADER
echo " All the previous downloaded plugins, is moved into the new directory."
echo " If the directory don't exist, a possibility to create it's given."
read -p "Do you want to change the temporany plugins directory? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
echo -n "Please type a valid system user: "
read NEW_DIR
if [[ -d $NEW_DIR ]]; then
# Move all the directories/files into new temp dir
mv $TEMP_PLUGIN_DIR* $NEW_DIR
# Change the old dir with the new one
TEMP_PLUGIN_DIR="$NEW_DIR"
count=1
else
echo "${RED}Something went wrong!"
echo " The directory chosen \"$NEW_DIR\" don't exist.${NORMAL}"
echo
read -p "Do you want to create \"$NEW_DIR\"? [Y/n] " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
# Create the new directory
mkdir -vp $NEW_DIR
# Move all the directories/files into new temp dir
mv $TEMP_PLUGIN_DIR* $NEW_DIR
# Change the old dir with the new one
TEMP_PLUGIN_DIR="$NEW_DIR"
count=1
else
count=0
fi
fi
elif [[ $REPLY =~ [Nn]$ ]]; then
count=1
else
echo "${RED}Something went wrong...Error!${NORMAL}"
read -p " Press any key to continue..." -n 1
fi
done
}
# RaspberryPi Ascii Art taken from piksel on github, https://gist.github.com/piksel/3023588
# Header for the menu
function HEADER {
clear
echo "${GREEN}
.~~. .~~.
'. \ ' ' / .'${RED} _ _
.~ .~~~..~. ___ ___ ___ ___| |_ ___ ___ ___ _ _ ___|_|
: .~.'~'.~. : | _| .'|_ -| . | . | -_| _| _| | | | . | |
~ ( ) ( ) ~ |_| |__,|___| _|___|___|_| |_| |_ | | _|_|
( : '~'.~.'~' : ) |_| |___| |_|
~ .~ ( ) ~. ~
( : '~' : ) ${NORMAL}${BOLD}Web Server + rTorrent + ruTorrent Auto Install${NORMAL}${RED}
'~ .~~~. ~' ${NORMAL}${LBLUE} Patrick Kerwood @ LinuxBloggen.dk${NORMAL}${RED}
'~'${NORMAL}"
echo "${BOLD}--------------------------------------------------------------------------------${NORMAL}"
}
# Function for the plugins download part
function DOWNLOAD_PLUGIN {
clear
echo "${GREEN}-------------------------------------| Info |-----------------------------------${NORMAL}"
echo
echo " Plugin: ${LBLUE}$name${NORMAL}"
echo
echo -e " $desc"
echo
echo " Info at $homepage"
echo
read -p " You want to download it [Y/n]: " -n 1
if [[ $REPLY =~ [Yy]$ || -z $REPLY ]]; then
if [[ $PLUGIN_NEEDS -eq "geoip" ]]; then
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
mkdir -v /usr/share/GeoIP
gunzip GeoLiteCity.dat.gz
mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
rm GeoLiteCity.dat.gz
apt-get -y install php5-geoip
elif [[ $PLUGIN_NEEDS -eq "unrar" ]]; then
apt-get -y install unrar-free
elif [[ $PLUGIN_NEEDS -eq "mediainfo" ]]; then
curl -O http://dl.bintray.com/novik65/generic/plugins/_task-3.6.tar.gz
tar -zxvf _task-3.6.tar.gz -C $TEMP_PLUGIN_DIR
rm _task-3.6.tar.gz
apt-get -y install libzen0 libmediainfo0 mediainfo
elif [[ $PLUGIN_NEEDS -eq "ffmpeg" ]]; then
curl -O http://dl.bintray.com/novik65/generic/plugins/_task-3.6.tar.gz
tar -zxvf _task-3.6.tar.gz -C $TEMP_PLUGIN_DIR
rm _task-3.6.tar.gz
apt-get -y install ffmpeg
elif [[ $PLUGIN_NEEDS -eq "all" ]]; then
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
mkdir -v /usr/share/GeoIP
gunzip GeoLiteCity.dat.gz
mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
rm GeoLiteCity.dat.gz
mv /tmp/plugins/* $TEMP_PLUGIN_DIR
apt-get -y install php5-geoip ffmpeg curl libzen0 libmediainfo0 mediainfo unrar-free
else
if [[ ! -z $PLUGIN_NEEDS ]]; then
PLUGIN_NEEDS=""
fi
fi
echo
curl -O "$url"
$unpack
if [[ $? -eq "0" ]]; then
rm "$file"
echo
PLUGIN_ARRAY+=("${name}")
error=" Plugin downloaded, unpacked and moved to temp folder${NORMAL}"
count=0
return 0
else
echo
error="${RED} Something went wrong...Error!${NORMAL}"
return 1
fi
else
count=0
fi
echo
}
function SELECT_PLUGINS {
if [[ ! -d $TEMP_PLUGIN_DIR ]]; then mkdir $TEMP_PLUGIN_DIR; fi
count=0
while true; do
while [ $count -eq 0 ]; do
clear
count=1
echo "${GREEN}-----------------------------------| ${BOLD}Page 1${NORMAL}${GREEN} |-----------------------------------${NORMAL}"
echo " [1] - Erase Data ${GREEN}[recommended]${NORMAL}"
echo " [2] - Create v3.6"
echo " [3] - Traffic v3.6"
echo " [4] - RSS v3.6"
echo " [5] - Edit v3.6"
echo " [6] - Retrackers v3.6"
echo " [7] - Throttle v3.6"
echo " [8] - Cookies v3.6"
echo " [9] - Scheduler v3.6"
echo " [10] - Auto Tools v3.6"
echo " [11] - Data Dir v3.6 ${GREEN}[recommended]${NORMAL}"
echo " [12] - Track Lables v3.6 ${GREEN}[recommended]${NORMAL}"
echo " [13] - Geo IP v3.6"
echo " [14] - Ratio v3.6 ${GREEN}[recommended]${NORMAL}"
echo " [15] - Show Peers like wTorrent v3.6"
done
echo
echo " [p1-3] - Change plugin page"
echo " [q] - Exit plugin installation"
echo "${GREEN}--------------------------------------------------------------------------------${NORMAL}"
echo -e $error
unset error
echo
echo -n "Choose plugin to see info: "
read -e plugin
case $plugin in
p1)
count=0
;;
p2)
clear
count=1
echo "${GREEN}-----------------------------------| ${BOLD}Page 2${NORMAL}${GREEN} |-----------------------------------${NORMAL}"
echo " [16] - Seeding Time v3.6 ${GREEN}[recommended]${NORMAL}"
echo " [17] - HTTPRPC v3.6"
echo " [18] - Diskspace v3.6"
echo " [19] - Unpack v3.6"
echo " [20] - Get Dir v3.6"
echo " [21] - Source v3.6"
echo " [22] - Chunks v3.6"
echo " [23] - Data v3.6"
echo " [24] - CPU Load v3.6"
echo " [25] - Extsearch v3.6"
echo " [26] - Theme v3.6"
echo " [27] - Login Mgr v3.6"
echo " [28] - ruTorrent Label Management Suite v1.1 ${GREEN}[recommended]${NORMAL}"
echo " [29] - NFO ${GREEN}[recommended]${NORMAL}"
echo " [30] - Chat v2.0"
echo " [31] - Logoff v1.3"
;;
p3)
clear
count=1
echo "${GREEN}-----------------------------------| ${BOLD}Page 3${NORMAL}${GREEN} |-----------------------------------${NORMAL}"
echo " [32] - Pause v1.2"
echo " [33] - Instant Search v1.0"
echo " [34] - File Drop v3.6 (FF > 3.6 & Chrome only)"
echo " [35] - Check Port v3.6"
echo " [36] - History v3.6"
echo " [37] - iPad v3.6"
echo " [38] - Extended Ratio v3.6"
echo " [39] - Feeds v3.6"
echo " [40] - Media Information v3.6"
echo " [41] - RSS URL Rewrite v3.6"
echo " [42] - Screenshot v3.6"
echo " [43] - RPC v3.6"
echo " [44] - Rutracker Check v3.6"
echo " [45] - Noty v3.6"
echo " [46] - Task v3.6"
echo " [47] - All Plugins v3.6. More info at http://git.io/vtDfb"
;;
1)
name="Erase Data Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/erasedata-3.6.tar.gz"
file="erasedata-3.6.tar.gz"
desc="This plugin adds a context menu item to the right click menu which allows you\n to delete data."
homepage="https://github.com/Novik/ruTorrent/wiki/PluginErasedata"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
2)
name="Create Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/create-3.6.tar.gz"
file="create-3.6.tar.gz"
desc="This plugin allows for the creation of new .torrent files from a file or\n directory of files."
homepage="https://github.com/Novik/ruTorrent/wiki/PluginCreate"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
3)
name="Trafic Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/trafic-3.6.tar.gz"
file="trafic-3.6.tar.gz"
desc="The Trafic plugin is a subsystem for monitoring rtorrent traffic totals.\n It tracks both system wide and per-tracker totals.\n The plugin can display totals in three formats: hourly, daily, and mouthly.\n Statistics can be cleaned out at any time by clicking the 'Clear' button."
homepage="https://github.com/Novik/ruTorrent/wiki/PluginTrafic"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
4)
name="RSS Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/rss-3.6.tar.gz"
file="rss-3.6.tar.gz"
desc="This plugin is designed to fetch torrents via RSS download links.\n It has 2 main parts, one for entering feeds and one for setting up filters.\n For more information about rss, see http://en.wikipedia.org/wiki/RSS."
homepage="https://github.com/Novik/ruTorrent/wiki/PluginRSS"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
5)
name="Edit Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/edit-3.6.tar.gz"
file="edit-3.6.tar.gz"
desc="This plugin allows you to edit the list of trackers, and change the comment\n of the current torrent.\n After installation, a new context menu item will become available when you\n right click a torrent from the list: 'Edit Torrent...'"
homepage="https://github.com/Novik/ruTorrent/wiki/PluginEdit"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
6)
name="Retrackers Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/retrackers-3.6.tar.gz"
file="retrackers-3.6.tar.gz"
desc="This plugin appends specified trackers to the trackers list of all newly\n added torrents.\n By the way, torrents may be added by any way - not just via ruTorrent."
homepage="https://github.com/Novik/ruTorrent/wiki/PluginRetrackers"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
7)
name="Throttle Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/throttle-3.6.tar.gz"
file="throttle-3.6.tar.gz"
desc="Throttle plugin gives a convenient control over the possibility to set limits\n of speed for groups of torrents.\n After this plugin is installed a new option 'Channels' will appear in\n the Settings dialog.\n Speed limits for some channels can be set here. (by default - 10)\n Assignment of channel number for a particular torrent or for a group of\n torrents can be made in it's contextual menu.\n Note - The '0' value conventionally for rTorrent, means 'no limits'.\n So the lowest possible limit is 1 Kbps."
homepage="https://github.com/Novik/rutorrent/wiki/PluginThrottle"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
8)
name="Cookies Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/cookies-3.6.tar.gz"
file="cookies-3.6.tar.gz"
desc="Some trackers use cookies for the client authentication.\n It is transparent to user who uses a browser to work with such servers,\n cause browser store these cookies and returns them to the server automatically.\n The user just needs to enter login/password from time to time."
homepage="https://github.com/Novik/rutorrent/wiki/PluginCookies"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
9)
name="Scheduler v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/scheduler-3.6.tar.gz"
file="scheduler-3.6.tar.gz"
desc="You can enable a scheduler to define a max of six rTorrent behavior types\n at each particular hour of 168 week hours."
homepage="https://github.com/Novik/rutorrent/wiki/PluginScheduler"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
10)
name="Auto Tools Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/autotools-3.6.tar.gz"
file="autotools-3.6.tar.gz"
desc="The plugin provides some possibilities on automation.\n Following functions are realized for now:\n Auto Label, automatic creation of labels at addition of new torrent through\n the web interface.\n Auto Move: automatic transferring of torrent data files to other directory\n on downloading completion.\n Auto Watch: automatic adding torrents via nested set of\n watch directories."
homepage="https://github.com/Novik/rutorrent/wiki/PluginAutotools"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
11)
name="Data Dir Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/datadir-3.6.tar.gz"
file="datadir-3.6.tar.gz"
desc="The plugin is intended for replacement of the current torrent data directory\n on another.\n Such operation is required, for example if the torrent data directory\n has been moved manually.\n It is also possible to move downloaded torrent's data.\n After plugin installation there will be a new item 'Save to...' in the context\n menu of the downloading area which shows a dialogue 'Torrent data directory'.\n In this dialogue you can specify a new path to the torrent data."
homepage="https://github.com/Novik/rutorrent/wiki/PluginDataDir"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
12)
name="Track Lables Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/tracklabels-3.6.tar.gz"
file="tracklabels-3.6.tar.gz"
desc="The plug-in adds a set of labels on the category panel.\n These labels are created automatically on the basis of torrent's trackers."
homepage="https://github.com/Novik/rutorrent/wiki/PluginTracklabels"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
13)
name="Geo IP Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/geoip-3.6.tar.gz"
file="geoip-3.6.tar.gz"
desc="Packages 'GeoLiteCity' and 'php5-geoip' is needed. \n For details about installation and configuration of GeoIP PHP extension,\n please visit: http://us3.php.net/manual/en/book.geoip.php"
homepage="https://github.com/Novik/rutorrent/wiki/PluginGeoIP"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
PLUGIN_NEEDS="geoip"
DOWNLOAD_PLUGIN
;;
14)
name="Ratio Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/ratio-3.6.tar.gz"
file="ratio-3.6.tar.gz"
desc="This plugin allows to manage ratio limits for groups of torrents, conveniently.\n When the plugin is installed a new section 'Ratio groups' appears\n in the Settings dialog.\n Here user can define limits of ratio for some groups. (by default - 8)\n Assignation of group to one or several torrents is performed by selecting\n an appropriate option in the context menu of torrents."
homepage="https://github.com/Novik/rutorrent/wiki/PluginRatio"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
15)
name="Show Peers like wTorrent Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/show_peers_like_wtorrent-3.6.tar.gz"
file="show_peers_like_wtorrent-3.6.tar.gz"
desc="The plugin changes the format of values in columns 'Seeds' and 'Peers'\n in the torrents list."
homepage="https://github.com/Novik/rutorrent/wiki/PluginShow_peers_like_wtorrent"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
16)
name="Seeding Time Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/seedingtime-3.6.tar.gz"
file="seedingtime-3.6.tar.gz"
desc="The plugin adds the columns 'Finished' and 'Added' to the torrents list.\n This columns contains the time when download of the torrent was completed and\n accordingly, the time when torrent was added."
homepage="https://github.com/Novik/rutorrent/wiki/PluginSeedingtime"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
17)
name="HTTPRPC Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/httprpc-3.6.tar.gz"
file="httprpc-3.6.tar.gz"
desc="This plugin is designed as a easy to use replacement for the mod_scgi\n (or similar) webserver module, with emphasis on extremely low bandwidth use.\n If you install this plugin, you do not need to use mod_scgi or the RPC Plugin.\n Note: This plugin requires a faster server, and is not recommended for embedded\n systems, like a router or slow computer."
homepage="https://github.com/Novik/rutorrent/wiki/PluginHTTPRPC"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
18)
name="Diskspace Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/diskspace-3.6.tar.gz"
file="diskspace-3.6.tar.gz"
desc="This plugin adds an easy to read disk meter to the bottom menu bar."
homepage="https://github.com/Novik/rutorrent/wiki/PluginDiskspace"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
19)
name="Unpack Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/unpack-3.6.tar.gz"
file="unpack-3.6.tar.gz"
desc="Packages 'unrar-free' is needed.\n This plugin is designed to manually or automatically unrar/unzip torrent data."
homepage="https://github.com/Novik/rutorrent/wiki/PluginUnpack"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
PLUGIN_NEEDS="unrar"
DOWNLOAD_PLUGIN
;;
20)
name="Get Dir Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/_getdir-3.6.tar.gz"
file="_getdir-3.6.tar.gz"
desc="The service plugin _getdir gives to other plugins the possibility of\n comfortable navigation on a host file system.\n Shows only directories to which rtorrent can write and which php can show."
homepage="https://github.com/Novik/rutorrent/wiki/Plugin_getdir"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
21)
name="Source Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/source-3.6.tar.gz"
file="source-3.6.tar.gz"
desc="This plugin adds a 'Get .torrent' item to the right click context menu.\n Allowing you to download the original .torrent file from the server,\n to your local machine."
homepage="https://github.com/Novik/rutorrent/wiki/PluginSource"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
22)
name="Chunks Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/chunks-3.6.tar.gz"
file="chunks-3.6.tar.gz"
desc="This plugin adds a new tab to the tab bar called 'chunks'.\n The added tab allows you to monitor the download status of each individual\n torrent 'piece'"
homepage="https://github.com/Novik/rutorrent/wiki/PluginChunks"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
23)
name="Data Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/data-3.6.tar.gz"
file="data-3.6.tar.gz"
desc="This plugin adds the 'Get Data' item to the right click menu.\n This allows you to download the file in question via http to your\n local machine.\n On 32 bit systems, you can not download files larger than 2 GB, this is due\n to a php limitation"
homepage="https://github.com/Novik/rutorrent/wiki/PluginData"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
24)
name="CPU Load Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/cpuload-3.6.tar.gz"
file="cpuload-3.6.tar.gz"
desc="This plugin adds a CPU Load usage bar to the bottom toolbar."
homepage="https://github.com/Novik/rutorrent/wiki/PluginCpuload"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
25)
name="Extsearch Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/extsearch-3.6.tar.gz"
file="extsearch-3.6.tar.gz"
desc="This plugin adds the ability to search many popular torrent sites for content\n without leaving the rutorrent url."
homepage="https://github.com/Novik/rutorrent/wiki/PluginExtsearch"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
26)
name="Theme Plugin v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/theme-3.6.tar.gz"
file="theme-3.6.tar.gz"
desc="This plugin allows you to change the gui theme to one of several provided\n themes, or any your create, provided they are placed in the proper\n directory within the plugin."
homepage="https://github.com/Novik/rutorrent/wiki/PluginTheme"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
27)
name="Login Mgr v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/loginmgr-3.6.tar.gz"
file="loginmgr-3.6.tar.gz"
desc="This plugin is used to login to 3rd party torrent sites.\n It's designed to be used in cased where cookies fail.\n It is a support plugin used for RSS and ExtSearch.\n Note: This plugin saves passwords in plain text."
homepage="https://github.com/Novik/rutorrent/wiki/PluginLoginMgr"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
28)
name="Loot At v3.6"
url="http://dl.bintray.com/novik65/generic/plugins/lookat-3.6.tar.gz"
file="lookat-3.6.tar.gz"
desc="This plugin is intended for looking torrent's name in the external sources."
homepage="https://github.com/Novik/ruTorrent/wiki/PluginLookAt"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
29)
name="NFO Plugin"
url="http://srious.biz/nfo.tar.gz"
file="nfo.tar.gz"
desc="This plugin shows the contents of the .nfo file for a given torrent."
homepage="https://github.com/Novik/rutorrent/wiki/PluginNFO"
unpack="tar -zxvf $file -C $TEMP_PLUGIN_DIR"
DOWNLOAD_PLUGIN
;;
30)