This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathffmpeg-installer.sh
executable file
·206 lines (196 loc) · 5.26 KB
/
ffmpeg-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
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
#!/bin/bash
########################################################
# Script to install FFmpeg on GNU/Linux #
# Website: https://www.johnvansickle.com/ffmpeg/ #
# Created by q3aql ([email protected]) #
# Builds by John Van Sickle ([email protected]) #
# Licensed by GPL v2.0 #
# Date: 27-03-2021 #
########################################################
VERSION="v2.0"
M_DATE="270321"
# Variables
URL="https://www.johnvansickle.com/ffmpeg/"
URL_RELEASES="https://johnvansickle.com/ffmpeg/releases/"
URL_BUILDS="https://johnvansickle.com/ffmpeg/builds/"
TMP_DIR=/tmp
PATH_INSTALL=/usr/bin/
# Downloader
APP_DOWNLOAD="x"
NAME_APP_DOWNLOAD="x"
# Function to check root permission
function rootMessage() {
mkdir -p /etc/root &> /dev/null
administrator=$?
if [ ${administrator} -eq 0 ] ; then
rm -rf /etc/root
else
echo ""
echo "* ffmpeg-install ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "+ Root permissions are required!"
echo ""
exit
fi
}
# Function to detect "kernel" name
function kernelCheck() {
KERNEL=$(uname -s)
if [ $KERNEL == "Linux" ]; then
KERNEL=linux
else
echo ""
echo "* ffmpeg-install ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "+ Unsupported OS ($KERNEL)"
echo ""
exit
fi
}
# Function to detect "arch" system.
function archCheck() {
archs=$(uname -m)
case "${archs}" in
i?86)
ARCH=i686
;;
x86_64)
ARCH=amd64
;;
*)
echo ""
echo "* ffmpeg-install ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "+ Unsupported Arquitecture (${archs})"
echo ""
exit
esac
}
# Function to check if 'curl' is installed.
function curlCheck () {
curl --help &> /dev/null
if [ "$?" -eq 0 ] ; then
echo "OK" > /dev/null
else
echo ""
echo "* ffmpeg-install ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "+ Error: You must install 'curl'."
echo ""
exit
fi
}
# Function to check available downloaders (wget, axel or aria2c).
function checkDownloader() {
# Check wget installed
wget --help &> /dev/null
checkWget="$?"
# Check axel installed
axel --help &> /dev/null
checkAxel="$?"
# Check aria2c installed
aria2c --help &> /dev/null
checkAria2="$?"
# Check variables
if [ ${checkAria2} -eq 0 ] ; then
APP_DOWNLOAD='aria2c --check-certificate=false'
NAME_APP_DOWNLOAD="aria2c"
elif [ ${checkAxel} -eq 0 ] ; then
APP_DOWNLOAD='axel'
NAME_APP_DOWNLOAD="axel"
elif [ ${checkWget} -eq 0 ] ; then
APP_DOWNLOAD='wget -c'
NAME_APP_DOWNLOAD="wget"
elif [ "x${APP_DOWNLOAD}" = "x" ] ; then
echo ""
echo "* ffmpeg-install ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "+ Error: You must install 'wget' or 'axel' or 'aria2'."
echo ""
exit
fi
}
# Check all configs
rootMessage
kernelCheck
archCheck
curlCheck
checkDownloader
# Sintax to install, update and uninstall FFmpeg.
case ${1} in
--install|-install|--update|-update)
cd ${TMP_DIR}
rm -rf ffmpeg-*
echo ""
echo "* ffmpeg-install ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
if [ "${2}" == "release" ] ; then
curl ${URL} | grep "${URL_RELEASES}" | cut -d '"' -f 2 | grep "${ARCH}" | head -1 > $TMP_DIR/ffmpeg-url
if [ "$?" -eq 0 ] ; then
echo "OK" > /dev/null
else
echo "+ Connection problem!"
echo "* Exiting..."
exit
fi
else
curl ${URL} | grep "${URL_BUILDS}" | cut -d '"' -f 2 | grep "${ARCH}" | head -1 > $TMP_DIR/ffmpeg-url
if [ "$?" -eq 0 ] ; then
echo "OK" > /dev/null
else
echo "+ Connection problem!"
echo "* Exiting..."
exit
fi
fi
URL_PACKAGE=`cat $TMP_DIR/ffmpeg-url`
NAME_PACKAGE=`cat /tmp/ffmpeg-url | cut -d "/" -f 6`
#clear
echo "* Downloading ${NAME_PACKAGE} (${NAME_APP_DOWNLOAD})"
${APP_DOWNLOAD} ${URL_PACKAGE}
if [ "$?" -eq 0 ] ; then
echo "OK" > /dev/null
else
echo ""
echo "+ Connection problem!"
echo "* Exiting..."
exit
fi
tar Jxvf ${NAME_PACKAGE}
rm -f ffmpeg-url ffmpeg*xz
cd ffmpeg-*
cp -rfv ffmpeg ${PATH_INSTALL}
cp -rfv ffprobe ${PATH_INSTALL}
cd ..
rm -rf ffmpeg-*
echo "* Finished!"
exit
;;
--uninstall|-uninstall)
echo ""
echo "* ffmpeg-install ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "* Uninstalling FFmpeg..."
sleep 3
rm -rfv /usr/bin/ffmpeg
rm -rfv /usr/bin/ffprobe
echo "* Finished!"
;;
--help|-help|-h|*)
echo ""
echo "* ffmpeg-install ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "* Script: q3aql ([email protected])"
echo "* Builds: John Van Sickle ([email protected])"
echo ""
echo "+ Syntax:"
echo ""
echo " $ ffmpeg-install --install --> Install FFmpeg (Git version)"
echo " $ ffmpeg-install --install release --> Install FFmpeg (Stable version)"
echo " $ ffmpeg-install --update --> Update FFmpeg (Git version)"
echo " $ ffmpeg-install --update release --> Update FFmpeg (Stable version)"
echo " $ ffmpeg-install --uninstall --> Uninstall FFmpeg previously installed"
echo " $ ffmpeg-install --help --> Show help"
echo ""
exit
esac