forked from Sub-7/FFmpegUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
377 lines (327 loc) · 12.9 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
#!/bin/bash
# FFmpegUI V1.01
# ffmpeg-4.1.3
# Sub-7 (28.06.2019)
#==============================================================================
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
distribution=$OS$ARCH$VERSION
hr=$(printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -)
lshw -C processor | grep product > HW-info/CPU
lshw -C system | grep product > HW-info/SYSTEM
lshw -C display | grep product > HW-info/GPU
CPU=HW-info/CPU
GPU=HW-info/GPU
MAINBOARD=HW-info/SYSTEM
NV_V=HW-info/NV_DR_V
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 Produkt > HW-info/GPU
fi
if [ $actualsize2 -ge $minsize ]; then
echo size is over $minsize bytes
else
lshw -C system | grep Produkt > HW-info/SYSTEM
fi
if [ $actualsize3 -ge $minsize ]; then
echo size is over $minsize bytes
else
lshw -C processor | grep Produkt > HW-info/CPU
fi
#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
reboot
fi
if [[ ${choices[2]} ]]; then
#Option 3 selected
echo $'\n'"$(tput setaf 2) ...setting up NVIDIA Driver$(tput sgr 0)"$'\n'
wget http://download.nvidia.com/XFree86/Linux-x86_64/430.14/NVIDIA-Linux-x86_64-430.14.run
sh ./NVIDIA-Linux-x86_64-430.14.run
rm -r NVIDIA-Linux-x86_64-430.14.run
nvidia-smi
echo $'\n'"$(tput setaf 2) NVIDIA Driver are 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 http://download.nvidia.com/XFree86/Linux-x86_64/430.14/NVIDIA-Linux-x86_64-430.14.run
sh ./NVIDIA-Linux-x86_64-430.14.run --no-kernel-module
rm -r NVIDIA-Linux-x86_64-430.14.run
nvidia-smi
echo $'\n'"$(tput setaf 2) NVIDIA Driver are 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_10.1.168_418.67_linux.run" ]; then
echo $'\n'"$(tput setaf 2) Found: cuda_10.1.168_418.67_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_10.1.168_418.67_linux.run --silent --toolkit --samples
else
wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.168_418.67_linux.run
apt-get install -y libxmu-dev
sh ./cuda_10.1.168_418.67_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-10.1/bin'" >> ~/.profile
echo "/usr/local/cuda-10.1/lib64" >> /etc/ld.so.conf
echo "/usr/local/cuda-10.1/bin" >> /etc/ld.so.conf
echo "/usr/local/cuda/include" >> /etc/ld.so.conf
source ~/.profile
sudo ldconfig
echo $'\n'"$(tput setaf 2) CUDA are installed.$(tput sgr 0)"$'\n'
fi
if [[ ${choices[5]} ]]; then
#Option 6 selected
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 install nasm yasm
# 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.1.3.tar.bz2 https://ffmpeg.org/releases/ffmpeg-4.1.3.tar.bz2 && \
tar xjvf ffmpeg-4.1.3.tar.bz2 && \
cd ~/ffmpeg_sources/ffmpeg-4.1.3 && \
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" \
--extra-cflags=-I/usr/local/cuda/include \
--extra-ldflags=-L/usr/local/cuda/lib64 \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-vaapi \
--enable-cuda \
--enable-cuvid \
--enable-nvenc \
--enable-libnpp \
--enable-nonfree && \
PATH="$HOME/bin:$PATH" make && \
make install && \
hash -r
cp -R ~/bin /usr/local
echo $'\n'"$(tput setaf 2) FFmpeg VAAPI+CUDA are 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 install nasm yasm
# 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.1.3.tar.bz2 https://ffmpeg.org/releases/ffmpeg-4.1.3.tar.bz2 && \
tar xjvf ffmpeg-4.1.3.tar.bz2 && \
cd ~/ffmpeg_sources/ffmpeg-4.1.3 && \
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-nonfree && \
PATH="$HOME/bin:$PATH" make && \
make install && \
hash -r
cp -R ~/bin /usr/local
echo $'\n'"$(tput setaf 2) FFmpeg VAAPI are 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 install software-properties-common
add-apt-repository ppa:heyarje/makemkv-beta
apt update
apt install makemkv-bin makemkv-oss -y
export LANG=C.UTF-8
apt-add-repository ppa:ondrej/php
sudo apt update -qq && sudo apt dist-upgrade -qq && sudo apt -y install \
php7.2-bcmath php7.2-zip php7.2-dev php7.2-xml php-pear apache2 libapache2-mod-php7.2 rar
pecl -v install rar
sed -i '2iextension=rar.so' /etc/php/7.2/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 cdrom www-data
sudo usermod -a -G video www-data
sudo usermod -a -G root www-data
sudo usermod -a -G sudo www-data
chown -R www-data /var/www/html/FFmpeg_UI
echo $'\n'"$(tput setaf 2) FFmpegUI and Apache2 are installed.$(tput sgr 0)"$'\n'
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 = "ubuntu6418.4" ]; then
echo $'\n'$hr"$(tput setaf 2) FFmpegUI v.1.01 installation (VAAPI + CUDA)$(tput sgr 0)"$'\n'$hr
echo " Distribution: $(tput setaf 2)$OS $ARCH $VERSION $(tput sgr 0)"
fi
while read -r line
do
name="$line"
echo " MB : $(tput setaf 2)${name:9}$(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 $NV_V)
echo " Nvidia Driver:$(tput setaf 2)${NV_VERSION:16}$(tput sgr 0)"
else
echo " Nvidia driver:$(tput setaf 1) is not installed$(tput sgr 0)"
fi
if [ -e "/usr/local/cuda/version.txt" ]; then
CUDA_V=$(cat /usr/local/cuda/version.txt)
echo " CUDA Version:$(tput setaf 2) ${CUDA_V:13}$(tput sgr 0)"
else
echo " CUDA:$(tput setaf 1) is 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 1-5 (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