-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathupdate-rutorrent
executable file
·98 lines (88 loc) · 2.53 KB
/
update-rutorrent
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
#!/bin/bash
webroot_path="/var/www"
rutorrent_path="$webroot_path/rutorrent"
plugins_path="$rutorrent_path/plugins"
webserver_service="caddy.service"
rutorrent_repo="https://github.com/Novik/ruTorrent.git"
filemanager_repo="https://github.com/nelu/rutorrent-thirdparty-plugins.git"
mobile_repo="https://github.com/xombiemp/rutorrentMobile.git"
updated="no"
stop_rtorrent () {
systemctl stop rtorrent.service
}
start_rtorrent () {
systemctl start rtorrent.service
}
restart_webserver () {
systemctl restart "$webserver_service"
}
if [ ! -d "$rutorrent_path" ] ; then
echo -e "INSTALLING ruTorrent"
stop_rtorrent
cd "$webroot_path"
git clone "$rutorrent_repo" rutorrent
echo -e "ruTorrent installed from git\n"
updated="yes"
else
echo -e "UPDATING ruTorrent"
cd "$rutorrent_path"
git fetch
localhash=$(git rev-parse HEAD)
remotehash=$(git rev-parse origin/master)
if [ "$remotehash" != "$localhash" ] ; then
stop_rtorrent
git pull
echo -e "ruTorrent updated from $localhash to $remotehash\n"
updated="yes"
else
echo -e "ruTorrent is already at the latest version: $remotehash\n"
fi
fi
#cd "$plugins_path"
#plugin_repo=$(git remote get-url origin)
#if [ "$plugin_repo" != "$filemanager_repo" ] ; then
# stop_rtorrent
# git init
# git remote add -f origin "$filemanager_repo"
# git pull
# updated="yes"
#else
# git fetch
# localhash=$(git rev-parse HEAD)
# remotehash=$(git rev-parse origin/master)
# if [ "$remotehash" != "$localhash" ] ; then
# stop_rtorrent
# git pull
# echo -e "hwk plugins updated from $localhash to $remotehash\n"
# updated="yes"
# else
# echo -e "hwk plugins are already at the latest version: $remotehash\n"
# fi
#fi
if [ ! -d "$plugins_path/mobile" ] ; then
stop_rtorrent
cd "$plugins_path"
git clone "$mobile_repo" mobile
updated="yes"
else
cd "$plugins_path/mobile"
git fetch
localhash=$(git rev-parse HEAD)
remotehash=$(git rev-parse origin/large-screen)
if [ "$remotehash" != "$localhash" ] ; then
stop_rtorrent
git pull
echo -e "mobile updated from $localhash to $remotehash\n"
updated="yes"
else
echo -e "mobile is already at the latest version: $remotehash\n"
fi
fi
if [ "$updated" == "yes" ] ; then
echo -e "Updates were installed. Restarting rtorrent..."
stop_rtorrent
restart_webserver
start_rtorrent
else
echo -e "Already running the latest version of everything!\n"
fi