-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
race-ready.sh
executable file
·122 lines (113 loc) · 4.26 KB
/
race-ready.sh
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
#!/bin/bash
# By B
user=$(whoami)
mkdir -p /home/${user}/.logs/
touch /home/${user}/.logs/race-ready.log
log="/home/${user}/.logs/race-ready.log"
port=$(grep 'WebUI\\Port' /home/${user}/.config/qBittorrent/qBittorrent.conf | cut -d= -f2)
subnet=$(cat /home/${user}/.install/subnet.lock)
function github_latest_version() {
# Function by Liara
# Argument expects the author/repo format
# e.g. swizzin/swizzin
repo=$1
curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/${repo}/releases/latest | grep -o '[^/]*$'
}
function _nvm() {
## Function for installing nvm.
if [[ ! -d /home/$user/.nvm ]]; then
echo "Installing node"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash >> "$log" 2>&1
echo "nvm installed."
else
echo "nvm is already installed."
fi
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install --lts >> "$log" 2>&1 || {
echo "node failed to install"
exit 1
}
echo "Node LTS installed."
}
function qbit_race() {
_nvm
. /home/${user}/.bashrc
echo "Installing qbit-race"
RACE_DIR="/home/${user}/scripts/qbit-race"
mkdir -p "${RACE_DIR}"
version=$(github_latest_version ckcr4lyf/qbit-race)
curl -sL "https://github.com/ckcr4lyf/qbit-race/archive/refs/tags/${version}.tar.gz" -o /tmp/qbit-race.tar.gz
tar xvf "/tmp/qbit-race.tar.gz" --directory "${RACE_DIR}" --strip-components=1 >> "$log" 2>&1
rm -f /tmp/qbit-race.tar.gz
cp "${RACE_DIR}/sample.env" "${RACE_DIR}/.env"
sed -i "s|QBIT_HOST=127.0.0.1|QBIT_HOST=${subnet}|g" "${RACE_DIR}/.env"
sed -i "s|QBIT_PORT=8080|QBIT_PORT=${port}|g" "${RACE_DIR}/.env"
cp "${RACE_DIR}/sample.settings.js" "${RACE_DIR}/settings.js"
sed -i 's|REANNOUNCE_INTERVAL: 5000,|REANNOUNCE_INTERVAL: 7000,|g' "${RACE_DIR}/settings.js"
sed -i 's|CONCURRENT_RACES: 1,|CONCURRENT_RACES: 3,|g' "${RACE_DIR}/sample.settings.js"
npm --prefix "${RACE_DIR}" install "${RACE_DIR}" >> "$log" 2>&1 || {
echo "Could not install dependencies. Please check the logs and consult the community support channel for your vendor."
exit 1
}
echo "Your script path is $(which node)"
echo "Your script argument is '${RACE_DIR}/bin/autodl_feed.js \"\$(InfoHash)\" \"\$(InfoName)\" \"\$(Tracker)\" \"\$(TorrentPathName)\"'"
echo "Your post-script is '$(which node) ${RACE_DIR}/bin/post_race.js \"%I\" \"%N\" \"%T\"'"
echo "qbit-race has been installed."
touch ~/.install/.qbit-race.lock
}
function nightwalker() {
echo "Cloning Nightwalker Repo"
git clone "https://github.com/brettpetch/nightwalker.git" /home/${user}/scripts/nightwalker >> "$log" 2>&1 || {
echo "Failed to clone nightwalker... Exiting."
exit 1
}
echo "Nightwalker cloned."
sudo box stop qbittorrent
sed -i "s|^.*AlternativeUIEnabled.*|WebUI\AlternativeUIEnabled=true|g" /home/${user}/.config/qBittorrent/qBittorrent.conf
sed -i "s|^.*RootFolder.*|WebUI\\\RootFolder=/home/${user}/scripts/nightwalker/|g" /home/${user}/.config/qBittorrent/qBittorrent.conf
sudo box start qbittorrent
touch ~/.install/.nightwalker.lock
}
echo 'This is unsupported software. You will not get help with this, please answer `yes` if you understand and wish to proceed'
if [[ -z ${eula} ]]; then
read -r eula
fi
if ! [[ $eula =~ yes ]]; then
echo "You did not accept the above. Exiting..."
exit 1
else
echo "Proceeding with installation"
fi
echo "Welcome to qbit-race installer..."
echo ""
echo "What do you like to do?"
echo "Logs are stored at ${log}"
echo "node = Install Node."
echo "qbitrace = Installs qbit-race + node (Depreciated/Unsupported)"
echo "nightwalker = Installs nightwalker"
echo "exit = Exits Installer"
while true; do
read -r -p "Enter it here: " choice
case $choice in
"node")
_nvm
break
;;
"qbitrace")
qbit_race
break
;;
"nightwalker")
nightwalker
break
;;
"exit")
break
;;
*)
echo "Unknown Option."
;;
esac
done
exit