-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathsetup.sh
402 lines (354 loc) · 14.1 KB
/
setup.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
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
#!/bin/bash
# FFmpegUI V2.0
# ffmpeg-4.1.3
# Sub-7 (04.12.2020)
#==============================================================================
OS=$(awk '/DISTRIB_ID=/' /etc/*-release | sed 's/DISTRIB_ID=//' | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VERSION=$(awk '/DISTRIB_RELEASE=/' /etc/*-release | sed 's/DISTRIB_RELEASE=//' | sed 's/[.]0/./')
if [ -z "$OS" ]; then
OS=$(awk '{print $1}' /etc/*-release | tr '[:upper:]' '[:lower:]')
fi
if [ -z "$VERSION" ]; then
VERSION=$(awk '{print $3}' /etc/*-release)
fi
mkdir HW-info
distribution=$OS$ARCH
hr=$(printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -)
lshw -C processor | grep product > HW-info/CPU
dmidecode -t 2 | grep product > HW-info/SYSTEM
lshw -C display | grep product > HW-info/GPU
nvidia-smi --query-gpu=driver_version --format=csv,noheader > HW-info/NVV
CPU=HW-info/CPU
GPU=HW-info/GPU
MAINBOARD=HW-info/SYSTEM
NVV=HW-info/NVV
minsize=1
actualsize1=$(wc -c <"$GPU")
actualsize2=$(wc -c <"$MAINBOARD")
actualsize3=$(wc -c <"$CPU")
if [ $actualsize1 -ge $minsize ]; then
echo size is over $minsize bytes
else
lshw -C display | grep Product > HW-info/GPU
fi
if [ $actualsize2 -ge $minsize ]; then
echo size is over $minsize bytes
else
dmidecode -t 2 | grep Product > HW-info/SYSTEM
fi
if [ $actualsize3 -ge $minsize ]; then
echo size is over $minsize bytes
else
lshw -C processor | grep Product > HW-info/CPU
fi
sudo mv cloudcmd /etc/init.d/
sudo update-rc.d cloudcmd defaults
#Menu options
options[0]=" 1 Install Dependencies"
options[1]=" 2 blacklist 'nouveau' driver (reboot required)?"
options[2]=" 3 Install NVIDIA GPU driver (Bare Metal + Proxmox KVM)"
options[3]=" 4 Install NVIDIA GPU driver (Proxmox LXC)"
options[4]=" 5 Install CUDA"
options[5]=" 6 Install FFmpeg (supports VAAPI+CUDA)"
options[6]=" 7 Install FFmpeg (supports VAAPI)"
options[7]=" 8 Install Apache2 and FFmpegUI"
options[8]=" 9 reboot"
LOGFILE=install.log
RETAIN_NUM_LINES=10
function logsetup {
TMP=$(tail -n $RETAIN_NUM_LINES $LOGFILE 2>/dev/null) && echo "${TMP}" > $LOGFILE
exec > >(tee -a $LOGFILE)
exec 2>&1
}
function log {
echo "[$(date --rfc-3339=seconds)]: $*"
}
rm -r install.log
logsetup
#Actions to take based on selection
function ACTIONS {
if [[ ${choices[0]} ]]; then
#Option 1 selected
echo $'\n'"$(tput setaf 2) ...setting up Dependencies$(tput sgr 0)"$'\n'
sh dependencies.sh
fi
if [[ ${choices[1]} ]]; then
#Option 2 selected
echo $'\n'"$(tput setaf 2) ...add 'nouveau' to the blacklist.$(tput sgr 0)"$'\n'
echo $'blacklist nouveau\noptions nouveau modeset=0' >/etc/modprobe.d/nvidia-installer-disable-nouveau.conf
update-initramfs -u
fi
if [[ ${choices[2]} ]]; then
#Option 3 selected
echo $'\n'"$(tput setaf 2) ...setting up NVIDIA Driver$(tput sgr 0)"$'\n'
wget https://us.download.nvidia.com/XFree86/Linux-x86_64/460.73.01/NVIDIA-Linux-x86_64-460.73.01.run
sh ./NVIDIA-Linux-x86_64-460.73.01.run
rm -r NVIDIA-Linux-x86_64-460.73.01.run
nvidia-smi
echo $'\n'"$(tput setaf 2) NVIDIA Driver installed.$(tput sgr 0)"$'\n'
fi
if [[ ${choices[3]} ]]; then
#Option 4 selected
echo $'\n'"$(tput setaf 2) ...setting up NVIDIA Driver$(tput sgr 0)"$'\n'
wget https://us.download.nvidia.com/XFree86/Linux-x86_64/460.73.01/NVIDIA-Linux-x86_64-460.73.01.run
sh ./NVIDIA-Linux-x86_64-460.73.01.run --no-kernel-module
rm -r NVIDIA-Linux-x86_64-460.73.01.run
nvidia-smi
echo $'\n'"$(tput setaf 2) NVIDIA Driver installed.$(tput sgr 0)"$'\n'
fi
if [[ ${choices[4]} ]]; then
#Option 5 selected
echo $'\n'"$(tput setaf 2) ...setting up CUDA$(tput sgr 0)"$'\n'
echo $'\n'"$(tput setaf 2) Please follow the command-line prompts$(tput sgr 0)"$'\n'
if [ -e "cuda_11.2.2_460.32.03_linux.run" ]; then
echo $'\n'"$(tput setaf 2) Found: cuda_11.2.2_460.32.03_linux.run$(tput sgr 0)"$'\n'
apt-get install -y g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
sh ./cuda_11.2.2_460.32.03_linux.run --silent --toolkit --samples
else
wget https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_460.32.03_linux.run
apt-get install libxmu-dev
sh ./cuda_11.2.2_460.32.03_linux.run --silent --toolkit --samples
fi
echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64" >> ~/.profile
echo "PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/cuda-11.2/bin'" >> ~/.profile
echo "/usr/local/cuda-11.2/lib64" >> /etc/ld.so.conf
echo "/usr/local/cuda-11.2/bin" >> /etc/ld.so.conf
echo "/usr/local/cuda/include" >> /etc/ld.so.conf
source ~/.profile
sudo ldconfig
echo $'\n'"$(tput setaf 2) CUDA installed.$(tput sgr 0)"$'\n'
fi
if [[ ${choices[5]} ]]; then
#Option 6 selected
apt install -y nvidia-cuda-toolkit
echo $'\n'"$(tput setaf 2) ...setting up FFmpeg VAAPI+CUDA$(tput sgr 0)"$'\n'
git clone https://github.com/FFmpeg/nv-codec-headers.git && \
cd ~/FFmpegUI/nv-codec-headers && \
make -j4 && \
make install
rm -R ~/FFmpegUI/nv-codec-headers
mkdir -p ~/ffmpeg_sources ~/bin
cd ~/ffmpeg_sources && \
apt -y --force-yes install nasm yasm
# Install libaom from source.
mkdir -p ~/ffmpeg_sources/libaom && \
cd ~/ffmpeg_sources/libaom && \
git clone https://aomedia.googlesource.com/aom && \
cmake ./aom && \
make && \
sudo make install
# Warning: libaom does not yet appear to have a stable API
#cd ~/ffmpeg_sources && \
#git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom && \
#mkdir aom_build && \
#cd aom_build && \
#PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off -DENABLE_NASM=on ../aom && \
#PATH="$HOME/bin:$PATH" make && \
#make install
cd ~/ffmpeg_sources && \
wget -O ffmpeg-4.3.2.tar.bz2 https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2 && \
tar xjvf ffmpeg-4.3.2.tar.bz2 && \
cd ~/ffmpeg_sources/ffmpeg-4.3.2 && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-cflags=-I/usr/local/cuda/include \
--extra-ldflags=-L/usr/local/cuda/lib64 \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-vaapi \
--enable-cuvid \
--enable-nvenc \
--enable-libnpp \
--enable-libaom \
--enable-cuda-nvcc \
--enable-nonfree && \
PATH="$HOME/bin:$PATH" make && \
make install && \
hash -r
cp -R ~/bin /usr/local
echo $'\n'"$(tput setaf 2) FFmpeg VAAPI+CUDA installed.$(tput sgr 0)"$'\n'
fi
if [[ ${choices[6]} ]]; then
#Option 7 selected
echo $'\n'"$(tput setaf 2) ...setting up FFmpeg VAAPI$(tput sgr 0)"$'\n'
git clone https://github.com/FFmpeg/nv-codec-headers.git && \
cd ~/FFmpegUI/nv-codec-headers && \
make -j4 && \
sudo make install
rm -R ~/FFmpegUI/nv-codec-headers
mkdir -p ~/ffmpeg_sources ~/bin
cd ~/ffmpeg_sources && \
apt-get -y install nasm yasm
# Install libaom from source.
mkdir -p ~/ffmpeg_sources/libaom && \
cd ~/ffmpeg_sources/libaom && \
git clone https://aomedia.googlesource.com/aom && \
cmake ./aom && \
make && \
sudo make install
# Warning: libaom does not yet appear to have a stable API
#cd ~/ffmpeg_sources && \
#git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom && \
#mkdir aom_build && \
#cd aom_build && \
#PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off -DENABLE_NASM=on ../aom && \
#PATH="$HOME/bin:$PATH" make && \
#make install
cd ~/ffmpeg_sources && \
wget -O ffmpeg-4.3.2.tar.bz2 https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2 && \
tar xjvf ffmpeg-4.3.2.tar.bz2 && \
cd ~/ffmpeg_sources/ffmpeg-4.3.2 && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-vaapi \
--enable-libaom \
--enable-nonfree && \
PATH="$HOME/bin:$PATH" make && \
make install && \
hash -r
cp -R ~/bin /usr/local
echo $'\n'"$(tput setaf 2) FFmpeg VAAPI installed.$(tput sgr 0)"$'\n'
fi
if [[ ${choices[7]} ]]; then
#Option 8 selected
echo $'\n'"$(tput setaf 2) ...setting up FFmpegUI and Apache2$(tput sgr 0)"$'\n'
apt-get -y --force-yes install software-properties-common
add-apt-repository ppa:heyarje/makemkv-beta -y
apt update -y
apt -y install makemkv-bin makemkv-oss
export LANG=C.UTF-8
apt-add-repository ppa:ondrej/php -y --force-yes
sudo apt update -qq && sudo apt dist-upgrade -qq &&
sudo apt install -y --force-yes php-bcmath php-zip php-dev php-xml php-pear apache2 libapache2-mod-php php-pear rar
sed -i '2iextension=rar.so' /etc/php/*.*/apache2/php.ini
mkdir ~/FFmpegUI/FFmpeg_UI/media
mkdir ~/FFmpegUI/FFmpeg_UI/media/input
mkdir ~/FFmpegUI/FFmpeg_UI/media/tmp
mkdir ~/FFmpegUI/FFmpeg_UI/media/output
mkdir ~/FFmpegUI/FFmpeg_UI/media/backup
cp -R ~/FFmpegUI/FFmpeg_UI /var/www/html/
sudo usermod -a -G video root
sudo usermod -a -G postfix root
sudo usermod -a -G postfix www-data
sudo usermod -a -G cdrom www-data
sudo usermod -a -G video www-data
sudo usermod -a -G root www-data
sudo usermod -a -G sudo www-data
pip3 install --upgrade youtube-dl
chown -R www-data /var/www/html/FFmpeg_UI
echo $'\n'"$(tput setaf 2) FFmpegUI and Apache2 installed.$(tput sgr 0)"$'\n'
chmod -R 777 /var/www/html/FFmpeg_UI/media
echo Your username for FFmpegUI is: "$(tput setaf 2)admin$(tput sgr 0)"
htpasswd -c /var/.htpasswd admin
echo $'\n'"$(tput setaf 3) now edit: /etc/apache2/apache2.conf
search for <Directory /var/www/>
repleace AllowOverride None
by AllowOverride All
then: service apache2 restart$(tput sgr 0)"$'\n'
echo "$(tput setaf 2) We did it, installation is complete$(tput sgr 0)"
echo "$(tput setaf 2) visit http://your-host/FFmpeg_UI$(tput sgr 0)"$'\n'
fi
if [[ ${choices[8]} ]]; then
#Option 9 selected
echo $'\n'"$(tput setaf 2) ...rebooting$(tput sgr 0)"$'\n'
sudo reboot
fi
}
#Variables
ERROR=" "
#Clear screen for menu
clear
#Menu function
function MENU {
if [ $distribution = "ubuntu64" ]; then
echo $"$hr"
echo $"$(tput setaf 2) FFmpegUI v.2.0 installation (VAAPI + CUDA)$(tput sgr 0)"
echo $' https://github.com/Sub-7/FFmpegUI'$'\n'$hr
echo " Distribution: $(tput setaf 2)$OS $ARCH $VERSION $(tput sgr 0)"
else
echo " $(tput setaf 1) Distribution not supported, see install.log in FFmpegUI folder for errors.$(tput sgr 0)"
fi
while read -r line
do
name="$line"
echo " MB : $(tput setaf 2)${name:14}$(tput sgr 0)"
done < "$MAINBOARD"
while read -r line
do
name="$line"
echo " CPU : $(tput setaf 2)${name:9}$(tput sgr 0)"
done < "$CPU"
while read -r line
do
name="$line"
echo " GPU : $(tput setaf 2)${name:9}$(tput sgr 0)"
done < "$GPU"
if [ -e "/usr/bin/nvidia-smi" ]; then
NV_VERSION=$(head -n 1 $NVV)
echo " Nvidia Driver:$(tput setaf 2)${NV_VERSION}$(tput sgr 0)"
else
echo " Nvidia driver:$(tput setaf 1) not installed$(tput sgr 0)"
fi
if [ -e "/usr/local/cuda/version.json" ]; then
CUDA_V=$(jq '.cuda_cudart.version' /usr/local/cuda/version.json)
echo " CUDA Version:$(tput setaf 2) ${CUDA_V}$(tput sgr 0)"
else
echo " CUDA:$(tput setaf 1) not installed$(tput sgr 0)"
fi
if [ -e "/dev/dri/renderD128" ]; then
echo " renderD128: $(tput setaf 2) OK$(tput sgr 0)"$'\n'
else
echo " renderD128: $(tput setaf 1) does not exist.$(tput sgr 0)!!! please refer cpu_passthrough.txt "$'\n'
fi
echo $hr
echo $'\n'" Install Options"$'\n'
for NUM in ${!options[@]}; do
echo " [""${choices[NUM]:- }""]""${options[NUM]}"
done
echo "$ERROR"
}
#Menu loop
while MENU && read -e -p " Select options (ENTER when done): " -n1 SELECTION && [[ -n "$SELECTION" ]]; do
clear
if [[ "$SELECTION" == *[[:digit:]]* && $SELECTION -ge 1 && $SELECTION -le ${#options[@]} ]]; then
(( SELECTION-- ))
if [[ "${choices[SELECTION]}" == "x" ]]; then
choices[SELECTION]=""
else
choices[SELECTION]="x"
fi
ERROR=" "
else
ERROR="Invalid option: $SELECTION"
fi
done
ACTIONS