forked from dannyti/seedbox-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 4
/
createRTorrentUserInstall
executable file
·117 lines (96 loc) · 7.82 KB
/
createRTorrentUserInstall
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
#!/bin/bash
# Hellish Tech
# No commercial usage without authorization
exec 1> >(logger -s -t $(basename $0)) 2>&1
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-u|--username)
USERNAME="$2"
shift # past argument
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
trlt="$(curl -s https://api.github.com/repos/autodl-community/autodl-trackers/releases/latest | sed -rn 's/(.*)"tag_name": "v(.*)",/\2/p')"
dltrkrs="https://github.com/autodl-community/autodl-trackers/releases/download/v$trlt/autodl-trackers-v$trlt.zip"
IRSSIPASSWORD1=`sfsGenerateRandomPasswordString`
USERPASSWORD=$(echo "$(cat /etc/seedbox-from-scratch/users/${USERNAME}.info)" | grep "Password: " | head -n1 | awk '{print $2}')
SYSTEMHOSTNAME=`cat /etc/seedbox-from-scratch/hostname.info`
WEBSERVERPORT=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 8081 -ep 8180)
WEBSSLSERVERPORT=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 8444 -ep 8543)
IRSSIPORT1=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 51000 -ep 51999)
SERVERPORT=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 51414 -ep 51513)
UDPPORT=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 6882 -ep 6982)
OTHERPORT=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 5001 -ep 5999)
USERUID=$(id -u ${USERNAME})
USERGID=$(id -g ${USERNAME})
HTPASSWDGENED=$(/etc/seedbox-from-scratch/sfsGenerateUserHtpassword -u ${USERNAME})
docker pull thevisad/rutorrent:latest
docker run --restart=always -d --name ${USERNAME}_rutorrent -e LOCAL_USER_ID=${USERUID} -h ${SYSTEMHOSTNAME} -v /home/${USERNAME}/downloads/manual:/downloads -v /home/${USERNAME}/rtorrent/config:/config -e PGID=${USERGID} -e PUID=${USERUID} -p ${WEBSSLSERVERPORT}:443 -p ${WEBSERVERPORT}:80 -p ${SERVERPORT}:${SERVERPORT} -p ${UDPPORT}:6881 -p ${OTHERPORT}:${OTHERPORT} -v /etc/seedbox-from-scratch/ssl:/etc/ssl/certs -v /etc/localtime:/etc/localtime:ro thevisad/rutorrent
CHECKIFRUNNING=$(/etc/seedbox-from-scratch/sfsRunningUserDockerInfo -u ${USERNAME} -d rutorrent | tr -cd '[[:alnum:]]._-' )
if [[ (${CHECKIFRUNNING} == "STOPPED") || (${CHECKIFRUNNING} == "RUNNING") ]]; then
sudo docker cp /etc/seedbox-from-scratch/templates/rutorrent.plugins.filemanager.conf.php.template ${USERNAME}_rutorrent:/usr/share/webapps/rutorrent/plugins/filemanager/conf.php
sudo docker cp /etc/seedbox-from-scratch/templates/rutorrent.plugins.fileshare.conf.php.template ${USERNAME}_rutorrent:/usr/share/webapps/rutorrent/plugins/fileshare/conf.php
sudo docker cp /etc/seedbox-from-scratch/templates/Snoopy.class.inc.template ${USERNAME}_rutorrent:/usr/share/webapps/rutorrent/php/Snoopy.class.inc
sudo wget https://raw.githubusercontent.com/nelu/rutorrent-thirdparty-plugins/stable/filemanager/flm.class.php -O /tmp/rutorrent.filemanager.flm.class.php
sudo wget https://raw.githubusercontent.com/nelu/rutorrent-thirdparty-plugins/stable/filemanager/settings.js.php -O /tmp/rutorrent.filemanager.settings.js.php
sudo perl -pi -e "s/\\\$topDirectory/\\\$homeDirectory/g" /tmp/rutorrent.filemanager.settings.js.php
sudo perl -pi -e "s/\\\$topDirectory\, \\\$fm/\\\$homeDirectory\, \\\$topDirectory\, \\\$fm/g" /tmp/rutorrent.filemanager.flm.class.php
sudo perl -pi -e "s/\\\$this\-\>userdir \= addslash\(\\\$topDirectory\)\;/\\\$this\-\>userdir \= \\\$homeDirectory \? addslash\(\\\$homeDirectory\) \: addslash\(\\\$topDirectory\)\;/g" /tmp/rutorrent.filemanager.flm.class.php
sudo docker cp /tmp/rutorrent.filemanager.flm.class.php ${USERNAME}_rutorrent:/usr/share/webapps/rutorrent/plugins/filemanager/flm.class.php
sudo docker cp /tmp/rutorrent.filemanager.settings.js.php ${USERNAME}_rutorrent:/usr/share/webapps/rutorrent/plugins/filemanager/settings.js.php
sudo rm -R /tmp/rtorrentinstalltemp/
sudo mkdir -p /tmp/rtorrentinstalltemp/.irssi/scripts/
sudo curl -sL http://git.io/vlcND | grep -Po '(?<="browser_download_url": ")(.*-v[\d.]+.zip)' | sudo xargs wget --quiet -O /tmp/rtorrentinstalltemp/.irssi/scripts/autodl-irssi.zip
sudo unzip -o /tmp/rtorrentinstalltemp/.irssi/scripts/autodl-irssi.zip -d /tmp/rtorrentinstalltemp/.irssi/scripts/
sudo rm /tmp/rtorrentinstalltemp/.irssi/scripts/autodl-irssi.zip
sudo mkdir -p /tmp/rtorrentinstalltemp/.irssi/scripts/autorun/
sudo mv /tmp/rtorrentinstalltemp/.irssi/scripts/autodl-irssi.pl /tmp/rtorrentinstalltemp/.irssi/scripts/autorun/
sudo wget -qO /tmp/rtorrentinstalltemp/autodl-trackers.zip $dltrkrs
sudo unzip -qo /tmp/rtorrentinstalltemp/autodl-trackers.zip -d /tmp/rtorrentinstalltemp/.irssi/scripts/AutodlIrssi/trackers/
sudo mkdir -p /tmp/rtorrentinstalltemp/.autodl
sudo cp /etc/seedbox-from-scratch/templates/home.user.autodl.autodl.cfg.template /tmp/rtorrentinstalltemp/.autodl/autodl.cfg
sudo chown -R root:root /tmp/rtorrentinstalltemp/.irssi
sudo perl -pi -e "s/<PASSWORD>/$IRSSIPASSWORD1/g" /tmp/rtorrentinstalltemp/.autodl/autodl.cfg
sudo perl -pi -e "s/<PORT>/$IRSSIPORT1/g" /tmp/rtorrentinstalltemp/.autodl/autodl.cfg
sudo perl -pi -e "s/use Digest\:\:SHA1 qw/use Digest\:\:SHA qw/g" /tmp/rtorrentinstalltemp/.irssi/scripts/AutodlIrssi/MatchedRelease.pm
sudo docker cp /tmp/rtorrentinstalltemp/.irssi ${USERNAME}_rutorrent:/root/
sudo docker cp /tmp/rtorrentinstalltemp/.autodl ${USERNAME}_rutorrent:/root/
# Replace this with the new data??>
sudo cp /etc/seedbox-from-scratch/templates/docker.nginx.conf.template /home/${USERNAME}/rtorrent/config/nginx/nginx.conf
sudo cp /etc/seedbox-from-scratch/templates/rutorrent.conf.users.plugins.autodl-irssi.conf.php.template /tmp/rutorrent.conf.users.plugins.autodl-irssi.conf.php.template.tmp
sudo perl -pi -e "s/<PASSWORD>/$IRSSIPASSWORD1/g" /tmp/rutorrent.conf.users.plugins.autodl-irssi.conf.php.template.tmp
sudo perl -pi -e "s/<PORT>/$IRSSIPORT1/g" /tmp/rutorrent.conf.users.plugins.autodl-irssi.conf.php.template.tmp
sudo docker cp /tmp/rutorrent.conf.users.plugins.autodl-irssi.conf.php.template.tmp ${USERNAME}_rutorrent:/usr/share/webapps/rutorrent/plugins/autodl-irssi/conf.php
sudo mkdir -p /tmp/rtorrentinstalltemp/rutorrent/plugins/
sudo git clone https://github.com/autodl-community/autodl-rutorrent.git /tmp/rtorrentinstalltemp/rutorrent/plugins/autodl-irssi
sudo cp /tmp/rtorrentinstalltemp/rutorrent/plugins/autodl-irssi/_conf.php /tmp/rtorrentinstalltemp/rutorrent/plugins/autodl-irssi/conf.php
sudo docker cp /tmp/rtorrentinstalltemp/rutorrent/plugins/* ${USERNAME}_rutorrent:/var/www/localhost/rutorrent/plugins
sudo rm -R /tmp/rtorrentinstalltemp/
sudo echo ${HTPASSWDGENED} > /tmp/temp.htpasswd
sudo docker cp /tmp/temp.htpasswd ${USERNAME}_rutorrent:/usr/share/webapps/.htpasswd
sudo rm -rf /tmp/temp.htpasswd
sudo echo "SERVICE: RTORRENT" > /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "USERNAME: $USERNAME" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "ACCESSURL: https://$SYSTEMHOSTNAME:$WEBSSLSERVERPORT" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "ACCESSURL: http://$SYSTEMHOSTNAME:$WEBSERVERPORT" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "WEBSSLSERVERPORT: $WEBSSLSERVERPORT" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "WEBSERVERPORT: $WEBSERVERPORT" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "IRSSIPORT1: $IRSSIPORT1" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "SERVERPORT: $SERVERPORT" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "UDPPORT: $UDPPORT" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "OTHERPORT: $OTHERPORT" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "UDPPORT: $UDPPORT" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo echo "IRSSIPASSWORD1: $IRSSIPASSWORD1" >> /home/${USERNAME}/private/rutorrent.serviceinfo
sudo chown www-data:www-data /home/${USERNAME}/private/*.serviceinfo
sudo docker restart ${USERNAME}_rutorrent
fi
if [[ -n $1 ]]; then
echo "Last line of file specified as non-opt/last argument:"
tail -1 $1
fi