-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_required_packages.sh
102 lines (86 loc) · 2.6 KB
/
check_required_packages.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
#!/bin/bash
set -euo pipefail
function identify_platform() {
platform="$(. /etc/os-release && echo "$ID")"
}
identify_platform
if [[ -z "$platform" ]]; then
echo "ERROR: This system couldn't be identified."
exit 1
else
echo "INFO: This system was identified as \"$platform\"."
fi
function get_required_packages() {
if [[ $# -gt 0 ]]; then
package_file=$1
required_packages="$(awk '{print $1}' $package_file)"
if [[ -z "$required_packages" ]]; then
echo "ERROR: could not parse required packages for $platform from $package_file"
exit 1
fi
return
fi
case "${platform,,}" in
"centos" | "rhel" | "rocky")
required_packages=('fontconfig' 'libX11' 'libxkbcommon-x11' 'xcb-util-renderutil' 'libglvnd-egl' 'libglvnd-opengl' 'libxkbcommon')
;;
"ubuntu")
required_packages=('fontconfig' 'libegl1' 'libopengl0' 'libxkbcommon0' 'libxcb-xinput0')
;;
*)
echo "WARNING: List of dependencies for distribution \"$platform\" is unknown."
echo "Please install libX11 and/or libfontconfig packages."
echo "List of supported platforms can be found at: https://www.schrodinger.com/supportedplatforms"
exit 1
;;
esac
}
get_required_packages "$@"
function check_if_package_installed() {
case "$platform" in
"ubuntu")
cmd="dpkg -s"
;;
"centos" | "rhel" | "rocky" | "sled" | "sles")
cmd="rpm -q"
;;
*)
echo "WARNING: package check command for distribution \"$platform\" is unknown."
;;
esac
}
check_if_package_installed
function get_package_manager() {
case "$platform" in
"centos" | "rhel" | "rocky")
package_manager="yum"
;;
"ubuntu")
package_manager="apt-get"
;;
"sles" | "sled")
package_manager="zypper"
;;
*)
echo "WARNING: package manager for distribution \"$platform\" is unknown."
;;
esac
}
get_package_manager
function get_missing_package() {
missing_packages=()
for package in ${required_packages[@]}; do
if ! ($cmd $package); then
missing_packages+=($package)
fi
done
if [ ${#missing_packages[@]} -eq 0 ]; then
echo "Your machine has the required packages."
else
echo "(${missing_packages[@]}) is/are required package/s to use Schrödinger suite. Please install them using:
sudo $package_manager install ${missing_packages[@]}"
exit 1
fi
}
echo -e "required_packages for your platform are: \n${required_packages[@]}"
get_missing_package