forked from Tvax/seedbox-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
seedbox-install.sh
executable file
·233 lines (198 loc) · 5.6 KB
/
seedbox-install.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
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
#!/bin/bash
##Check if system compatible before install
compatible(){
##Check if distribution is supported
if [[ -z "$(uname -a | grep Ubuntu)" && -z "$(uname -a | grep Debian)" ]];then
echo Distro not supported
exit 1
fi
##Check if systemd is running
if [[ -z "$(pidof systemd)" ]]; then
echo systemd not running
exit 2
fi
if [ "$UID" -ne 0 ]; then
echo Must be root to run the script
exit 3
fi
}
##Ask user to install the app
installApp(){
clear
while true; do
read -r -p 'Do you want to install '$1'?(Y/n)' choice
case "$choice" in
n|N) return 1;;
y|Y|"") return 0;;
*) echo 'Response not valid';;
esac
done
}
##Updates && Upgrades
updates(){
sudo apt-get update;
sudo apt-get upgrade;
}
deluge(){
sudo apt-get install deluge;
sudo apt-get install deluge-web;
sudo apt-get install deluged;
sudo apt-get install deluge-console;
sudo echo "[Unit]
Description=Deluge Bittorrent Client Web Interface
Documentation=man:deluge-web
After=network-online.target deluged.service
Wants=deluged.service
[Service]
Type=simple
User=${username}
UMask=027
ExecStart=/usr/bin/deluge-web
Restart=on-failure
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/deluge-web.service;
sudo systemctl enable /etc/systemd/system/deluge-web.service;
sudo systemctl start deluge-web;
sudo echo "[Unit]
Description=Deluge Bittorrent Client Daemon
Documentation=man:deluged
After=network-online.target
[Service]
Type=simple
User=${username}
UMask=007
ExecStart=/usr/bin/deluged -d
Restart=on-failure
# Time to wait before forcefully stopped.
TimeoutStopSec=300
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/deluged.service;
sudo systemctl enable /etc/systemd/system/deluged.service;
sudo systemctl start deluged;
}
plex(){
cd;
bash -c "$(wget -qO - https://raw.githubusercontent.com/mrworf/plexupdate/master/extras/installer.sh)";
sudo service plexservermedia start;
}
sonarr(){
sudo apt-get install libmono-cil-dev;
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FDA5DFFC;
sudo echo "deb http://apt.sonarr.tv/ master main" | sudo tee /etc/apt/sources.list.d/sonarr.list;
sudo apt-get update;
sudo apt-get install nzbdrone;
sudo echo "[Unit]
Description=Sonarr Daemon
[Service]
User=${username}
Type=simple
PermissionsStartOnly=true
ExecStart=/usr/bin/mono /opt/NzbDrone/NzbDrone.exe -nobrowser
TimeoutStopSec=20
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/sonarr.service;
sudo chown -R ${username}:${username} /opt/NzbDrone/
systemctl enable sonarr.service;
sudo service sonarr start;
}
radarr(){
sudo apt update && apt install libmono-cil-dev curl mediainfo;
sudo apt-get install mono-devel mediainfo sqlite3 libmono-cil-dev -y;
cd /tmp;
wget https://github.com/Radarr/Radarr/releases/download/v0.2.0.45/Radarr.develop.0.2.0.45.linux.tar.gz;
sudo tar -xf Radarr* -C /opt/;
sudo chown -R ${username}:${username} /opt/Radarr;
sudo echo "[Unit]
Description=Radarr Daemon
After=syslog.target network.target
[Service]
User=${username}
Type=simple
ExecStart=/usr/bin/mono /opt/Radarr/Radarr.exe -nobrowser
TimeoutStopSec=20
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/radarr.service;
sudo chown -R ${username}:${username} /opt/Radarr
sudo systemctl enable radarr;
sudo service radarr start;
}
jackett(){
sudo apt-get install libcurl4-openssl-dev;
wget https://github.com/Jackett/Jackett/releases/download/v0.7.1622/Jackett.Binaries.Mono.tar.gz;
sudo tar -xf Jackett* -C /opt/;
sudo chown -R ${username}:${username} /opt/Jackett;
sudo echo "[Unit]
Description=Jackett Daemon
After=network.target
[Service]
WorkingDirectory=/opt/Jackett/
User=${username}
ExecStart=/usr/bin/mono --debug JackettConsole.exe --NoRestart
Restart=always
RestartSec=2
Type=simple
TimeoutStopSec=5
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/jackett.service;
sudo systemctl enable jackett;
sudo service jackett start;
rm Jackett.Binaries.Mono.tar.gz;
}
headphones(){
sudo apt-get install git-core python;
cd /opt;
git clone https://github.com/rembo10/headphones.git;
sudo touch /etc/default/headphones;
sudo chmod +x /opt/headphones/init-scripts/init.ubuntu;
sudo ln -s /opt/headphones/init-scripts/init.ubuntu /etc/init.d/headphones;
sudo update-rc.d headphones defaults;
sudo update-rc.d headphones enable;
sudo service headphones start;
}
createUser(){
clear
read -p "Enter user name : " username
##if user already exists quit the function
grep -q $username /etc/passwd
if [ $? -eq 0 ]; then
echo "Using existing user '$username'"
sleep 2
return 1
fi
##otherwise ask for a password for the newly created user
read -p "Enter password : " password
sudo adduser $username --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
echo "${username}:${password}" | sudo chpasswd
}
main(){
##call compatible to check if distro is either Debian or Ubuntu
compatible
##create user
createUser
##call updates to upgrade the system
updates
##dictionnary to associate fonction with string name
declare -A arr
arr["plex"]=PlexMediaServer
arr+=( ["deluge"]=Deluge ["sonarr"]=Sonarr ["radarr"]=Radarr ["Headphones"]=Headphones ["jackett"]=Jackett )
for key in ${!arr[@]}; do
installApp ${arr[${key}]}
if [ $? == 0 ]; then
${key}
fi
done
}
main
BLUE=`tput setaf 4`
echo "Thanks for using this script"
echo "If you have any issues hit me up here :"
echo "https://github.com/Tvax/seedbox-install/issues"