-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtransdroid-setup
289 lines (288 loc) · 16.9 KB
/
transdroid-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
#!/bin/bash
# Transdroid Setup
scriptversion="1.0.4-dev"
scriptname="transdroid.setup"
# Author: adamaze (frankthetank7254)
# Contributors: randomessence
#
# wget -qO ~/transdroid.setup http://git.io/lU_B9w && bash ~/transdroid.setup
#
############################
## Version History Starts ##
############################
#
############################
### Version History Ends ###
############################
#
############################
###### Variable Start ######
############################
#
scripturl="https://raw.githubusercontent.com/feralhosting/feralfilehosting/master/Feral%20Wiki/Other%20software/Transdroid%20-%20Control%20rTorrent%20-%20Deluge%20-%20Transmission%20From%20Your%20Android%20Phone/scripts/transdroid-setup.sh"
#
rtorrentjson="https://raw.githubusercontent.com/feralhosting/feralfilehosting/master/Feral%20Wiki/Other%20software/Transdroid%20-%20Control%20rTorrent%20-%20Deluge%20-%20Transmission%20From%20Your%20Android%20Phone/json/rtorrent-settings.json"
delugejson="https://raw.githubusercontent.com/feralhosting/feralfilehosting/master/Feral%20Wiki/Other%20software/Transdroid%20-%20Control%20rTorrent%20-%20Deluge%20-%20Transmission%20From%20Your%20Android%20Phone/json/deluge-settings.json"
transmissionjson="https://raw.githubusercontent.com/feralhosting/feralfilehosting/master/Feral%20Wiki/Other%20software/Transdroid%20-%20Control%20rTorrent%20-%20Deluge%20-%20Transmission%20From%20Your%20Android%20Phone/json/transmission-settings.json"
#
option1="ruTorrent"
option2="Deluge"
option3="Transmission"
option4="Quit"
#
tmpdir1=".transdroid_import"
tmpdir2="transdroid_import"
#
# Random password generation
randompass=$(< /dev/urandom tr -dc '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' | head -c20; echo;)
#
URL="https://$(whoami):$randompass@$(hostname -f)/$(whoami)/$tmpdir2"
#
############################
####### Variable End #######
############################
#
############################
#### Self Updater Start ####
############################
#
#
############################
##### Self Updater End #####
############################
#
############################
#### Core Script Starts ####
############################
#
echo
echo -e "Hello $(whoami), you have the latest version of the" "\033[36m""$scriptname""\e[0m" "script. This script version is:" "\033[31m""$scriptversion""\e[0m"
echo
read -ep "The scripts have been updated, do you wish to continue [y] or exit now [q] : " -i "y" updatestatus
echo
if [[ "$updatestatus" =~ ^[Yy]$ ]]
then
#
############################
#### User Script Starts ####
############################
#
echo This script will generate the "settings.json" file that Transdroid requires for importing settings. Please choose the client you are using.
echo
showMenu ()
{
echo "1) $option1"
echo "2) $option2"
echo "3) $option3"
echo "4) $option4"
echo
}
while [ 1 ]
do
showMenu
read -e CHOICE
echo
case "$CHOICE" in
"1")
mkdir -p ~/$tmpdir1
#
wget -qO ~/$tmpdir1/qrencode_3.3.0-2_amd64.deb http://ftp.uk.debian.org/debian/pool/main/q/qrencode/qrencode_3.3.0-2_amd64.deb
wget -qO ~/$tmpdir1/libqrencode3_3.3.0-2_amd64.deb http://ftp.uk.debian.org/debian/pool/main/q/qrencode/libqrencode3_3.3.0-2_amd64.deb
#
dpkg-deb -x ~/$tmpdir1/qrencode_3.3.0-2_amd64.deb ~/$tmpdir1
dpkg-deb -x ~/$tmpdir1/libqrencode3_3.3.0-2_amd64.deb ~/$tmpdir1
#
wget -qO ~/$tmpdir1/settings.json "$rtorrentjson"
read -ep "Please enter the ruTorrent password from your Account overview page: " pass
echo
#
sed -i 's/USERNAME-CHANGEME/'$(whoami)'/' ~/$tmpdir1/settings.json
sed -i 's/HOSTNAME_CHANGEME/'$(hostname -f)'/' ~/$tmpdir1/settings.json
sed -i 's/PASSWORD-CHANGEME/'$pass'/' ~/$tmpdir1/settings.json
#
mkdir -p ~/www/$(whoami).$(hostname)/public_html/$tmpdir2
#
# cp -f ~/$tmpdir1/settings.json ~/www/$(whoami).$(hostname)/public_html/$tmpdir2/settings.json
htpasswd -cbm ~/www/$(whoami).$(hostname -f)/public_html/$tmpdir2/.htpasswd "$(whoami)" "$randompass" > /dev/null 2>&1
#
if [[ -d ~/.nginx/conf.d/000-default-server.d ]]
then
echo -e 'location /'"$tmpdir2"' {\n auth_basic "'"$tmpdir2"'";\n auth_basic_user_file "'"$HOME"'/www/'$(whoami)'.'$(hostname -f)'/public_html/'"$tmpdir2"'/.htpasswd";\n}' > ~/.nginx/conf.d/000-default-server.d/transdroid_import.conf
/usr/sbin/nginx -s reload -c ~/.nginx/nginx.conf > /dev/null 2>&1
fi
#
echo -e 'AuthType Basic\nAuthName "'"$tmpdir2"'"\nAuthUserFile "'"$HOME"'/www/'$(whoami)'.'$(hostname -f)'/public_html/'"$tmpdir2"'/.htpasswd"\nRequire "'$(whoami)'"' > ~/www/$(whoami).$(hostname -f)/public_html/"$tmpdir2"/.htaccess
#
# LD_LIBRARY_PATH=~/.transdroid_import/usr/lib/x86_64-linux-gnu ~/.transdroid_import/usr/bin/qrencode -m 1 -t ANSI256 -o - "$URL"
LD_LIBRARY_PATH=~/.transdroid_import/usr/lib/x86_64-linux-gnu ~/.transdroid_import/usr/bin/qrencode -m 10 -t PNG "$(cat ~/.transdroid_import/settings.json)" -o ~/www/$(whoami).$(hostname)/public_html/$tmpdir2/rtorrent.png
#
echo -e "1: Open Transdroid and go to:" "\033[36m""Settings > System > Import settings""\e[0m"
echo
echo -e "2: Click" "\033[36m""Use QR code""\e[0m"
echo
echo -e "3: Open this URL in a browser:"
echo
echo -e "\033[32m""$URL/rtorrent.png""\e[0m"
echo
echo -e "4: Now scan with Transdroid to import""\e[0m"
echo
echo -e "Note: Imported connections will be merged with existing ones. Nothing will be lost."
echo
read -ep "After you have downloaded the config file, press ENTER to clean up." useless
echo
#
if [[ ! -z "$tmpdir1" && ! -z "$tmpdir2" ]]
then
cd && rm -rf $tmpdir1 ~/www/$(whoami).$(hostname)/public_html/$tmpdir2
if [[ -d ~/.nginx/conf.d/000-default-server.d ]]
then
rm -f ~/.nginx/conf.d/000-default-server.d/transdroid_import.conf
/usr/sbin/nginx -s reload -c ~/.nginx/nginx.conf > /dev/null 2>&1
fi
else
echo "Nothing was removed. Please check manually."
fi
;;
"2")
mkdir -p ~/$tmpdir1
#
wget -qO ~/$tmpdir1/qrencode_3.3.0-2_amd64.deb http://ftp.uk.debian.org/debian/pool/main/q/qrencode/qrencode_3.3.0-2_amd64.deb
wget -qO ~/$tmpdir1/libqrencode3_3.3.0-2_amd64.deb http://ftp.uk.debian.org/debian/pool/main/q/qrencode/libqrencode3_3.3.0-2_amd64.deb
#
dpkg-deb -x ~/$tmpdir1/qrencode_3.3.0-2_amd64.deb ~/$tmpdir1
dpkg-deb -x ~/$tmpdir1/libqrencode3_3.3.0-2_amd64.deb ~/$tmpdir1
#
wget -qO ~/$tmpdir1/settings.json "$delugejson"
read -ep "Please enter the Deluge password from your Account overview page: " pass
echo
#
sed -i 's/USERNAME-CHANGEME/'$(whoami)'/g' ~/$tmpdir1/settings.json
sed -i 's/HOSTNAME_CHANGEME/'$(hostname -f)'/' ~/$tmpdir1/settings.json
sed -i 's/PASSWORD-CHANGEME/'$pass'/' ~/$tmpdir1/settings.json
#
mkdir -p ~/www/$(whoami).$(hostname)/public_html/$tmpdir2
#
# cp -f ~/$tmpdir1/settings.json ~/www/$(whoami).$(hostname)/public_html/$tmpdir2/settings.json
htpasswd -cbm ~/www/$(whoami).$(hostname -f)/public_html/$tmpdir2/.htpasswd "$(whoami)" "$randompass" > /dev/null 2>&1
#
if [[ -d ~/.nginx/conf.d/000-default-server.d ]]
then
echo -e 'location /'"$tmpdir2"' {\n auth_basic "'"$tmpdir2"'";\n auth_basic_user_file "'"$HOME"'/www/'$(whoami)'.'$(hostname -f)'/public_html/'"$tmpdir2"'/.htpasswd";\n}' > ~/.nginx/conf.d/000-default-server.d/transdroid_import.conf
/usr/sbin/nginx -s reload -c ~/.nginx/nginx.conf > /dev/null 2>&1
fi
#
echo -e 'AuthType Basic\nAuthName "'"$tmpdir2"'"\nAuthUserFile "'"$HOME"'/www/'$(whoami)'.'$(hostname -f)'/public_html/'"$tmpdir2"'/.htpasswd"\nRequire "'$(whoami)'"' > ~/www/$(whoami).$(hostname -f)/public_html/"$tmpdir2"/.htaccess
#
# LD_LIBRARY_PATH=~/.transdroid_import/usr/lib/x86_64-linux-gnu ~/.transdroid_import/usr/bin/qrencode -m 1 -t ANSI256 -o - "$URL"
LD_LIBRARY_PATH=~/.transdroid_import/usr/lib/x86_64-linux-gnu ~/.transdroid_import/usr/bin/qrencode -m 10 -t PNG "$(cat ~/.transdroid_import/settings.json)" -o ~/www/$(whoami).$(hostname)/public_html/$tmpdir2/deluge.png
#
echo -e "1: Open Transdroid and go to:" "\033[36m""Settings > System > Import settings""\e[0m"
echo
echo -e "2: Click" "\033[36m""Use QR code""\e[0m"
echo
echo -e "3: Open this URL in a browser:"
echo
echo -e "\033[32m""$URL/deluge.png""\e[0m"
echo
echo -e "4: Now scan with Transdroid to import""\e[0m"
echo
echo -e "Note: Imported connections will be merged with existing ones. Nothing will be lost."
echo
read -ep "After you have downloaded the config file, press ENTER to clean up." useless
echo
#
if [[ ! -z "$tmpdir1" && ! -z "$tmpdir2" ]]
then
cd && rm -rf $tmpdir1 ~/www/$(whoami).$(hostname)/public_html/$tmpdir2
if [[ -d ~/.nginx/conf.d/000-default-server.d ]]
then
rm -f ~/.nginx/conf.d/000-default-server.d/transdroid_import.conf
/usr/sbin/nginx -s reload -c ~/.nginx/nginx.conf > /dev/null 2>&1
fi
else
echo "Nothing was removed. Please check manually."
fi
;;
"3")
mkdir -p ~/$tmpdir1
#
wget -qO ~/$tmpdir1/qrencode_3.3.0-2_amd64.deb http://ftp.uk.debian.org/debian/pool/main/q/qrencode/qrencode_3.3.0-2_amd64.deb
wget -qO ~/$tmpdir1/libqrencode3_3.3.0-2_amd64.deb http://ftp.uk.debian.org/debian/pool/main/q/qrencode/libqrencode3_3.3.0-2_amd64.deb
#
dpkg-deb -x ~/$tmpdir1/qrencode_3.3.0-2_amd64.deb ~/$tmpdir1
dpkg-deb -x ~/$tmpdir1/libqrencode3_3.3.0-2_amd64.deb ~/$tmpdir1
#
wget -qO ~/$tmpdir1/settings.json "$transmissionjson"
read -ep "Please enter the Transmission password from your Account overview page: " pass
echo
#
sed -i 's/USERNAME-CHANGEME/'$(whoami)'/' ~/$tmpdir1/settings.json
sed -i 's/HOSTNAME_CHANGEME/'$(hostname -f)'/' ~/$tmpdir1/settings.json
sed -i 's/PASSWORD-CHANGEME/'$pass'/' ~/$tmpdir1/settings.json
#
mkdir -p ~/www/$(whoami).$(hostname)/public_html/$tmpdir2
#
# cp -f ~/$tmpdir1/settings.json ~/www/$(whoami).$(hostname)/public_html/$tmpdir2/settings.json
htpasswd -cbm ~/www/$(whoami).$(hostname -f)/public_html/$tmpdir2/.htpasswd "$(whoami)" "$randompass" > /dev/null 2>&1
#
if [[ -d ~/.nginx/conf.d/000-default-server.d ]]
then
echo -e 'location /'"$tmpdir2"' {\n auth_basic "'"$tmpdir2"'";\n auth_basic_user_file "'"$HOME"'/www/'$(whoami)'.'$(hostname -f)'/public_html/'"$tmpdir2"'/.htpasswd";\n}' > ~/.nginx/conf.d/000-default-server.d/transdroid_import.conf
/usr/sbin/nginx -s reload -c ~/.nginx/nginx.conf > /dev/null 2>&1
fi
#
echo -e 'AuthType Basic\nAuthName "'"$tmpdir2"'"\nAuthUserFile "'"$HOME"'/www/'$(whoami)'.'$(hostname -f)'/public_html/'"$tmpdir2"'/.htpasswd"\nRequire "'$(whoami)'"' > ~/www/$(whoami).$(hostname -f)/public_html/"$tmpdir2"/.htaccess
#
# LD_LIBRARY_PATH=~/.transdroid_import/usr/lib/x86_64-linux-gnu ~/.transdroid_import/usr/bin/qrencode -m 1 -t ANSI256 -o - "$URL"
LD_LIBRARY_PATH=~/.transdroid_import/usr/lib/x86_64-linux-gnu ~/.transdroid_import/usr/bin/qrencode -m 10 -t PNG "$(cat ~/.transdroid_import/settings.json)" -o ~/www/$(whoami).$(hostname)/public_html/$tmpdir2/transmission.png
#
echo -e "1: Open Transdroid and go to:" "\033[36m""Settings > System > Import settings""\e[0m"
echo
echo -e "2: Click" "\033[36m""Use QR code""\e[0m"
echo
echo -e "3: Open this URL in a browser:"
echo
echo -e "\033[32m""$URL/transmission.png""\e[0m"
echo
echo -e "4: Now scan with Transdroid to import""\e[0m"
echo
echo -e "Note: Imported connections will be merged with existing ones. Nothing will be lost."
echo
read -ep "After you have downloaded the config file, press ENTER to clean up." useless
echo
#
if [[ ! -z "$tmpdir1" && ! -z "$tmpdir2" ]]
then
cd && rm -rf $tmpdir1 ~/www/$(whoami).$(hostname)/public_html/$tmpdir2
if [[ -d ~/.nginx/conf.d/000-default-server.d ]]
then
rm -f ~/.nginx/conf.d/000-default-server.d/transdroid_import.conf
/usr/sbin/nginx -s reload -c ~/.nginx/nginx.conf > /dev/null 2>&1
fi
else
echo "Nothing was removed. Please check manually."
fi
;;
"4")
echo "You chose to quit the script."
echo
exit
;;
esac
done
#
############################
##### User Script End #####
############################
#
else
echo -e "You chose to exit after updating the scripts."
echo
cd && bash
exit 1
fi
#
############################
##### Core Script Ends #####
############################
#