-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstaller.sh
executable file
·132 lines (109 loc) · 3.02 KB
/
installer.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
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
# exit on error
set -e
# set color
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# check sudo
OS=$(uname -o)
if [[ $OS != 'Android' ]] && [[ "$EUID" -ne 0 ]]; then
printf " Sorry, you need to run this as root\n"
printf " Try running with command ${YELLOW}sudo${NC}\n"
printf " ${BLUE}curl -Ls https://git.io/torrenter.sh | sudo bash -${NC}\n"
exit 1
fi
printf "\nPlease wait, this might take few minutes to complete...\n"
sleep 2
# installer
package_installer() {
installer="$1"
packages="$2"
if [[ $packages == "" ]]; then
packages="git nodejs"
fi
for package in $packages
do
if ! hash $package 2>/dev/null; then
printf 'y\n' | $installer $package
fi
done
}
# install nodejs, npm and yarn
if [[ $OS == 'Android' ]]; then
pkg update
pkg install git nodejs -y
# install torrenter
npm i -g torrenter
else
# Alpine Linux
if hash apk 2>/dev/null; then
package_installer "apk add --update"
# Arch Linux
elif hash pacman 2>/dev/null; then
pacman -Syy
package_installer "pacman -S"
# CentOS / Fedora / RHEL
elif hash dnf 2>/dev/null; then
if ! hash node 2>/dev/null; then
curl -Ls https://rpm.nodesource.com/setup_12.x | bash -
fi
package_installer "dnf install -y"
elif hash yum 2>/dev/null; then
if ! hash node 2>/dev/null; then
curl -Ls https://rpm.nodesource.com/setup_12.x | bash -
fi
package_installer "yum install -y"
# Debian / Ubuntu
elif hash apt 2>/dev/null; then
apt update
if ! hash node 2>/dev/null; then
curl -Ls https://deb.nodesource.com/setup_12.x | bash -
fi
package_installer "apt install"
# Gentoo
elif hash emerge 2>/dev/null; then
package_installer "emerge"
# MacOS
elif hash brew 2>/dev/null; then
package_installer "brew install"
elif hash port 2>/dev/null; then
package_installer "port install"
# Solus
elif hash eopkg 2>/dev/null; then
package_installer "eopkg install"
# FreeBSD
elif hash pkg 2>/dev/null; then
package_installer "pkg install" "git node"
# NetBSD
elif hash pkgin 2>/dev/null; then
package_installer "pkgin install"
# OpenBSD
elif hash pkg 2>/dev/null; then
package_installer "pkg_add" "git node"
# openSUSE and SLE
elif hash pkg 2>/dev/null; then
package_installer "zypper install" "git nodejs12"
# Void Linux
elif hash xbps-install 2>/dev/null; then
package_installer "xbps-install -Sy"
else
printf "Unsupported OS!\n"
exit 1
fi
# install torrenter
npm i -g yarn
yarn global add torrenter
fi
# fix config directory
cd ~/
mkdir -p .config
# fix android downloads
if [[ $OS == 'Android' ]]; then
[ -d storage ] || termux-setup-storage
node /data/data/com.termux/files/usr/lib/node_modules/torrenter/indexer.js
if ! grep -q termux .config/torrenter-nodejs/config.json; then
sed -i -e 's@downloads@/data/data/com.termux/files/home/storage/downloads@g' .config/torrenter-nodejs/config.json
fi
fi
printf "\nInstall finished, run ${YELLOW}torrenter${NC} to start\n\n"