-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.sh
executable file
·285 lines (181 loc) · 5.49 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
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
function linux_install_mkvtoolnix {
echo ''
echo '** Installing MKVTOOLNIX **'
echo ''
sudo apt-get install -y mkvtoolnix
}
function mac_install_mkvtoolnix {
echo ''
echo '** Installing MKVTOOLNIX **'
echo ''
pushd /Applications
sudo unzip $SCRIPTDIR/setup/mac/MKVToolNix.zip
sudo chmod +x Mkvtoolnix.app/Contents/MacOS/mkvinfo
sudo chmod +x Mkvtoolnix.app/Contents/MacOS/mkvmerge
sudo chmod +x Mkvtoolnix.app/Contents/MacOS/mkvextract
sudo chmod +x Mkvtoolnix.app/Contents/MacOS/mkvpropedit
sudo chmod +x Mkvtoolnix.app/Contents/MacOS/mmg
sudo chmod +x Mkvtoolnix.app/Contents/MacOS/Mkvmmg
popd
}
function linux_install_makemkv {
echo ''
echo '** Installing MAKEMKV **'
echo ''
VER="$1"
TMPDIR=`mktemp -d`
# Install prerequisites
sudo apt-get install build-essential pkg-config libc6-dev libssl-dev libexpat1-dev libavcodec-dev libgl1-mesa-dev libqt4-dev
# Install this version of MakeMKV
pushd $TMPDIR
for PKG in bin oss; do
PKGDIR="makemkv-$PKG-$VER"
PKGFILE="$PKGDIR.tar.gz"
wget "http://www.makemkv.com/download/$PKGFILE"
tar xzf $PKGFILE
pushd $PKGDIR
# pre-1.8.6 version
if [ -e "./makefile.linux" ]; then
make -f makefile.linux
sudo make -f makefile.linux install
# post-1.8.6 version
else
if [ -e "./configure" ]; then
./configure
fi
make
sudo make install
fi
popd
done
popd
# Remove temporary directory
if [ -e "$TMPDIR" ]; then rm -rf $TMPDIR; fi
}
function mac_install_makemkv {
echo ''
echo '** Installing MAKEMKV **'
echo ''
TMPDIR=`mktemp -d`
# Install this version of MakeMKV
pushd $TMPDIR
curl -o makemkv.dmg http://www.makemkv.com/download/makemkv_v1.9.0_osx.dmg
hdiutil mount makemkv.dmg
sudo cp -rf /Volumes/makemkv*/MakeMKV.app /Applications
rm makemkv.dmg
popd
# Remove temporary directory
if [ -e "$TMPDIR" ]; then rm -rf $TMPDIR; fi
}
function linux_install_vobsub2srt {
echo ''
echo '** Installing VOBSUB2SRT **'
echo ''
TMPDIR=`mktemp -d`
# Install this version of MakeMKV
pushd $TMPDIR
sudo apt-get install -y libtiff5-dev libtesseract-dev tesseract-ocr-eng build-essential cmake pkg-config
processorType = $(uname -m)
debLink = ''
if [[ $processorType == 'x86_64' ]]; then
#64 bit
debLink = 'https://launchpad.net/~ruediger-c-plusplus/+archive/ubuntu/vobsub2srt/+files/vobsub2srt_1.0pre6-31-g1c782e5-ppa1_amd64.deb'
else
#32 bit
debLink = 'https://launchpad.net/~ruediger-c-plusplus/+archive/ubuntu/vobsub2srt/+files/vobsub2srt_1.0pre6-31-g1c782e5-ppa1_i386.deb'
fi
wget $debLink -O vobsub2srt.deb
sudo dpkg -i vobsub2srt.deb
popd
# Remove temporary directory
if [ -e "$TMPDIR" ]; then rm -rf $TMPDIR; fi
}
function mac_install_vobsub2srt {
echo ''
echo '** Installing VOBSUB2SRT **'
echo ''
which brew > /dev/null
if [[ $? -eq 1 ]]; then
echo 'Homebrew is not install. Please install this first: http://brew.sh'
exit 1
fi
brew install --all-languages tesseract
if [[ $? -ne 0 ]]; then
echo 'Tesseract install failed'
exit 1
fi
brew install --HEAD https://github.com/ruediger/VobSub2SRT/raw/master/packaging/vobsub2srt.rb
if [[ $? -ne 0 ]]; then
echo 'VobSub2SRT install failed'
exit 1
fi
}
function linux_install_bdsup2sub {
echo ''
echo '** Installing BDSUP2SUB **'
echo ''
cd /usr/local/bin
sudo wget http://www.videohelp.com/download/BDSup2Sub512.jar -O BDSup2Sub
sudo chmod +x /usr/local/bin/BDSup2Sub
}
function mac_install_bdsup2sub {
echo ''
echo '** Installing BDSUP2SUB **'
echo ''
pushd /Applications
sudo unzip $SCRIPTDIR/setup/mac/BDSup2Sub.zip
popd
# Remove temporary directory
if [ -e "$TMPDIR" ]; then rm -rf $TMPDIR; fi
}
## START ##
# Collect sudo credentials
sudo -v
os_name=$(uname)
#Install MKVToolnix
if [[ $os_name == 'Linux' ]]; then
which mkvinfo > /dev/null
if [ $? -ne 0 ]; then
linux_install_mkvtoolinx
fi
elif [[ $os_name == 'Darwin' ]]; then
if [[ ! -f /Applications/Mkvtoolnix.app/Contents/MacOS/mkvinfo ]]; then
mac_install_mkvtoolnix
fi
fi
#Install MakeMKV
if [[ $os_name == 'Linux' ]]; then
which makemkvcon > /dev/null
if [ $? -ne 0 ]; then
linux_install_makemkv 1.9.0
fi
elif [[ $os_name == 'Darwin' ]]; then
if [[ ! -f /Applications/MakeMKV.app/Contents/MacOS/makemkvcon ]]; then
mac_install_makemkv 1.9.0
fi
fi
#Install VobSub2SRT
which vobsub2srt > /dev/null
if [ $? -ne 0 ]; then
if [[ $os_name == 'Linux' ]]; then
linux_install_vobsub2srt
elif [[ $os_name == 'Darwin' ]]; then
mac_install_makemkv
fi
fi
#Install BDSup2Sub
if [[ $os_name == 'Linux' ]]; then
which makemkvcon
if [ $? -ne 0 ]; then
linux_install_bdsup2sub
fi
elif [[ $os_name == 'Darwin' ]]; then
if [[ ! -f /Applications/BDSup2Sub.app/Contents/MacOS/JavaApplicationStub ]]; then
mac_install_bdsup2sub
fi
fi
echo ''
echo '** Setup complete **'
echo ''