-
Notifications
You must be signed in to change notification settings - Fork 2
/
fix_java
executable file
·90 lines (75 loc) · 2.64 KB
/
fix_java
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
#!/bin/bash
# fix_java
# This downloads Java from URL and installs it as good as it gets...
# Copyright (C) 2014-2015 Alexander Swen <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Alexander Swen
# Private contact: [email protected]
# CHANGELOG:
# 2014-01-08 A.Swen created.
# SETTINGS
date=$(date +%Y%m%d)
me=$(basename $0)
mydir=$(dirname $0)
# FUNCTIONS
die () {
rc=$1
shift
echo "==========================">&2
echo "==== FATAL ERROR ====" >&2
echo "==========================">&2
echo "" >&2
echo $@ >&2
exit $rc
}
# I need to know where to download from
if [ $# -lt 2 ];then
echo "usage: fix_java <url> <version>"
echo "example: fix_java http://javadl.sun.com/webapps/download/AutoDL?BundleId=78697 jre1.7.0_25"
exit 1
fi
# check dir
if [ ! -d /usr/$2 ];then
sudo mkdir -p /usr/$2
wget -O - $1 | sudo tar zxf - -C /usr
sudo chown -R root:root /usr/$2
sudo rm /usr/java
sudo ln -sf /usr/$2 /usr/java
if [ "$(uname -m | grep '64')" ]; then
echo we are on 64bit
pluginsrc=/usr/java/lib/amd64/libnpjp2.so
else
echo we are on 32bit
pluginsrc=/usr/java/lib/i386/libnpjp2.so
fi
if [ ! -f ${pluginsrc} ];then
die 1 "pluginsource ${pluginsrc} not found"
return
fi
# fix google chrome plugin
gcpplugins=/opt/google/chrome/plugins
[ -d ${gcplugins} ]|| sudo install -dm 755 ${gcplugins}
[ -L ${gcplugins}/libnpjp2.so ]|| sudo ln -s ${pluginsrc} ${gcplugins}/libnpjp2.so
# fix chromium plugin
chromiumplugins=/usr/lib/chromium/plugins
[ -d ${chromiumplugins} ]|| sudo install -dm 755 ${chromiumplugins}
[ -L ${chromiumplugins}/libnpjp2.so ]|| sudo ln -s ${pluginsrc} ${chromiumplugins}/libnpjp2.so
# fix ff plugin
if [ -f ~/.mozilla/firefox/profiles.ini ];then
ffplugins=$(awk -v homedir=~ '/Path/ {sub (/Path=/, ""); print homedir"/.mozilla/firefox/"$1"/plugins" }' ~/.mozilla/firefox/profiles.ini)
[ -d ${ffplugins} ] || mkdir -p ${ffplugins}
[ -L ${ffplugins}/libnpjp2.so ]|| sudo ln -s /usr/java/lib/amd64/libnpjp2.so ${ffplugins}/libnpjp2.so
fi
else
die 1 "dir /usr/$2 already exists"
fi