-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutmp-install
executable file
·231 lines (215 loc) · 7.65 KB
/
utmp-install
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
#!/bin/bash
source $(dirname $0)/utmp-lib.sh
YTDLP=$1
FFPLAY=$2
FFMPEG=$3
#for those with wacky OSs - change it to one of the ones listed below
MOS=$4
#for if this is broken and the user knows that, FORCE reinstall of everything
FORCE=$5
#OS REF SHEET
#$OSTYPE supported name treatment
#solaris n solaris ?
#arch n arch ?
#darwin y macOS linux (minus apt)
#linux y ~linux linux
#linux-gnu y gnu linux
#bsd y bsd linux
#cygwin y ? windows
#msys y ? windows
#linux-android y ~ termux
#termux y termux termux
# Display an error message for an unrecognized operating system
clueless() {
echerr "Unrecognized operating system. Cannot install dependencies automatically."
}
tryagain="Please install one of them manually and try again"
if [[ $FORCE -eq 1 ]]; then
echwarn "FORCE REINSTALLING!"
fi
# allow OS override
ostype=${OSTYPE//[0-9.]/} #strip numbers
if ! [ "$MOS" == "changethis" ]; then
ostype=$MOS
fi
# install method based on OS
if [[ "$ostype" == "linux"* ]] || [[ "$ostype" == "darwin"* ]] || [[ "$ostype" == "bsd" ]]; then
method="linux"
if cmd_exists apt && ! [[ "$ostype" == "darwin"* ]]; then
ech "apt detected, confirming updated status..."
sudo apt update
sudo apt upgrade
fi
elif [[ "$ostype" == "msys" || "$ostype" == "cygwin" || "$ostype" == "win32" ]]; then
method="windows"
elif [[ "$ostype" == "termux" ]]; then
method="termux"
ech "Termux detected, confirming termux setup..."
termux-setup-storage # Allow termux to download files into your phone's storage
pkg update && pkg upgrade # Update all packages
else
clueless
fi
ech "Detected OS: $ostype"
#GIT
check_git() {
#check for git (why would you not have git??)
if ! cmd_exists git || [[ $FORCE -eq 1 ]]; then
ech "Git not found. Installing git..."
if cmd_exists brew; then ech "Using: brew"
brew install git
elif cmd_exists dnf; then ech "Using: dnf"
sudo dnf install git
elif cmd_exists apt && ! [[ "$ostype" == "darwin"* ]]; then ech "Using: apt"
sudo apt install git
elif cmd_exists pkg; then ech "Using: pkg"
pkg install git
elif cmd_exists port; then ech "Using: MacPorts/DarwinPorts"
sudo port install git
else
echerr "couldn't install git :( $tryagain"
fi
ech "git installed."
git --version
else
ech "git found."
fi
}
# Check and install yt-dlp
check_yt_dlp() {
if ! cmd_exists $YTDLP || [[ $FORCE -eq 1 ]]; then
ech "Installing yt-dlp..."
if [[ "$method" == "linux" ]]; then
fdown=0
if cmd_exists brew; then ech "Using: brew"
brew install yt-dlp
elif cmd_exists apt && ! [[ "$ostype" == "darwin"* ]]; then ech "Using: apt"
sudo apt install yt-dlp
elif cmd_exists curl; then ech "Using: curl (file download)"; fdown=1
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
elif cmd_exists wget; then ech "Using: wget (file download)"; fdown=1
wget -O /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp
elif cmd_exists aria2c; then ech "Using: aria2c (file download)"; fdown=1
aria2c -o /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp
else
echerr "apt, brew, curl, wget, aria2c not found. $tryagain."
fi
if [[ fdown=1 ]]; then # if downloaded file directly,
sudo chmod a+rx /usr/local/bin/yt-dlp # make it executable
fi
elif [[ "$method" == "windows" ]]; then
if cmd_exists winget; then ech "Using: winget"
winget install yt-dlp
elif cmd_exists choco; then ech "Using: choco"
choco install yt-dlp
elif cmd_exists scoop; then ech "Using: scoop"
scoop install yt-dlp
else
echerr "winget, choco, scoop not found. $tryagain."
fi
elif [[ "$method" == "termux" ]]; then
pkg install python
pip install -U yt-dlp
else
clueless
fi
ech "yt-dlp installed."
else
ech "yt-dlp found."
fi
}
# Check and install if SDL
#check for sdl
check_sdl() {
if ! cmd_exists sdl2-config || [[ $FORCE -eq 1 ]]; then
ech "SDL library not found. Installing SDL..."
if [[ "$method" == "linux" || "$method" == "darwin" ]]; then
if cmd_exists brew; then ech "Using: brew"
brew install sdl2
elif cmd_exists apt && ! [[ "$ostype" == "darwin"* ]]; then ech "Using: apt"
sudo apt install libsdl2-dev
else
echwarn "brew, apt not found."
ech "Using: git (manual)"
git clone https://github.com/libsdl-org/SDL.git -b SDL2 /usr/local/bin/SDL2
cd /usr/local/bin/SDL2
mkdir build
cd build
../configure
make
sudo make install
cd $WDIR
fi
elif [[ "$method" == "windows" ]]; then
ech "Using: git (manual)"
mkdir ~/Documents/PowerShell/Modules
git clone https://github.com/libsdl-org/SDL.git -b ~/Documents/PowerShell/Modules/SDL2
cd ~/Documents/PowerShell/Modules/SDL
mkdir build
cd build
../configure
make
sudo make install
cd $WDIR
elif [[ "$method" == "termux" ]]; then
if cmd_exists pkg; then ech "Using: pkg"
pkg install sdl2
fi
else
clueless
fi
ech "SDL library installed."
else
ech "SDL library found."
fi
}
# Check and install ffmpeg and ffplay
check_ffmpeg() {
if ! cmd_exists $FFMPEG || ! cmd_exists $FFPLAY || [[ $FORCE -eq 1 ]]; then
ech "Installing ffmpeg and ffplay..."
check_sdl
if cmd_exists brew; then ech "Using: brew"
brew install ffmpeg
elif cmd_exists apt && ! [[ "$ostype" == "darwin"* ]]; then ech "Using: apt"
sudo apt install ffmpeg
else
ech "Using: git (manual)"
ech "Compiling and installing ffmpeg..."
#path
path="/usr/local/bin"
if [[ "$method" == "windows" ]]; then
path="~/Documents/PowerShell/Modules"
mkdir $path/Modules
#windows has special package placement
fi
#clean and clone
ech "git cloning ffmpeg"
rm -R $path/ffmpeg
git clone https://git.ffmpeg.org/ffmpeg.git $path/ffmpeg
#c make
ech "compiling ffmpeg"
cd $path/ffmpeg
./configure --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
make
make install
cd $WDIR
#extract
ech "extracting executables"
mv $path/ffmpeg $path/ffmpegfolder
cp $path/ffmpegfolder/ffmpeg $path/ffmpeg
cp $path/ffmpegfolder/ffprobe $path/ffprobe
cp $path/ffmpegfolder/ffplay $path/ffplay
rm -R $path/ffmpegfolder
fi
ech "ffmpeg and ffplay installed."
ffmpeg -version
ffplay -version
else
ech "ffmpeg and ffplay found."
fi
}
# Check and install dependencies
check_git
check_yt_dlp
check_ffmpeg
exit 0