-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_installer.sh
More file actions
executable file
·44 lines (38 loc) · 959 Bytes
/
java_installer.sh
File metadata and controls
executable file
·44 lines (38 loc) · 959 Bytes
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
#!/usr/bin/bash
set -e
# Check if we are root
if [ "$EUID" -ne 0 ]; then
echo "${0##*/}: Please run as root!" >&2
exit 1
fi
help() {
echo -e "Usage: $0 <option> <object> <priority>
\t <option> can be one of: install, uninstall, config
\t <object> is a path to a java folder
\t <priority> - an integer number defining the priority of a java binaries installing, should be set if the <option> is install, defaults to 100"
exit 1
}
if [ -z "$1" ] || [ -z "$2" ]; then
echo "One or both of the parameters are empty"
help
fi
binaries=$(ls "$2/bin")
for i in $binaries; do
case $1 in
"install")
if [ -z "$3" ]; then
priority=100
else
priority="$3"
fi
update-alternatives --install /usr/bin/"$i" "$i" "$2/bin/$i" "$priority"
;;
"uninstall")
update-alternatives --remove "$i" "$2/bin/$i"
;;
"config")
update-alternatives --config "$i"
;;
*) help ;;
esac
done