-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpatch-linux
executable file
·69 lines (60 loc) · 1.94 KB
/
patch-linux
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
#!/bin/bash
##############################################
# Author: GwenDragon
# License: GPL
##############################################
if [ $UID != 0 ] ; then
echo "Only root can do that!
Please login with su or sudo-I as root and then start the script."
exit 255
fi
mod_dir="$( cd "$( dirname "$0" )" && pwd )"
if [ ! "$1" = "" ] ; then
mod_dir=$1
fi
vivaldi_installs=$(dirname $(find /opt -name "vivaldi-bin" )) ;
vivaldi_install_dirs=( $vivaldi_installs ) ;
echo "---------------------"
count=1
selected=0
echo "Found installations:"
for dir in $vivaldi_installs ; do
echo $dir": "$count ;
((count++)) ;
done
read -p "
Which installation patch?
Please enter number and press Enter or X for cancel
Enter selection: " selected ;
if [ "$selected" = "X" ] ; then
exit ;
fi
((selected--)) ;
if [ $selected -ge ${#vivaldi_install_dirs[@]} ] ; then
echo "Selection too large!"
fi
dir=${vivaldi_install_dirs[$selected]} ;
echo "---------------------
"
echo "Patch of "${mod_dir}" für "${vivaldi_install_dirs[$selected]} ;
cp "$dir/resources/vivaldi/browser.html" "$dir/resources/vivaldi/browser.html-$(date +%Y-%m-%dT%H-%M-%S)"
alreadypatched=$(grep '<link rel="stylesheet" href="style/custom.css" />' $dir/resources/vivaldi/browser.html);
if [ "$alreadypatched" = "" ] ; then
echo Patched browser.html
sed -i -e 's/<\/head>/<link rel="stylesheet" href="style\/custom.css" \/> <\/head>/' "$dir/resources/vivaldi/browser.html"
sed -i -e 's/<\/body>/<script src="custom.js"><\/script> <\/body>/' "$dir/resources/vivaldi/browser.html"
else
echo "browser.html is already patched!"
fi
if [ -f "$mod_dir/custom.css" ] ; then
echo Copied custom.css
cp -f "$mod_dir/custom.css" "$dir/resources/vivaldi/style/custom.css"
else
echo custom.css missing in $mod_dir
fi
if [ -f "$mod_dir/custom.js" ] ; then
echo Copied custom.js
cp -f "$mod_dir/custom.js" "$dir/resources/vivaldi/custom.js"
else
echo custom.js missing in $mod_dir!
fi