generated from caltechlibrary/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_software.bash
executable file
·49 lines (44 loc) · 1.4 KB
/
check_software.bash
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
#!/bin/bash
#
# Check software needed and their versions
#
function check_version() {
OPT="$1"
VERSION="$2"
CMD="$3"
MSG="$4"
if command -v "${CMD}" >/dev/null; then
HAS_VERSION=$("${CMD}" "${OPT}" | grep "${VERSION}")
if [ "$HAS_VERSION" = "" ]; then
echo "${CMD} version check: expected ${VERSION}, got $("${CMD}" "${OPT}")"
fi
else
echo "${CMD} is missing$MSG"
exit 1
fi
}
#
# Check the OS distribution supplied tools
#
echo ""
echo "Checking Bash and Multipass to run OpenSearch in a VM"
echo ""
## - Bash >= 3.2 (or equivalent POSIX shell)
check_version "--version" "3.2" "bash" ""
## - Multipass >= 1.13
check_version "--version" "1.13" "multipass" ", see <https://multipass.run> to install"
echo "You can opensearch_machine.bash, the Multipass VM, and install OpenSearch!"
echo ""
echo "Checking GNU Make, Pandoc, PageFind, Python3 and jq"
echo ""
## - GNU Make
check_version "--version" "3.8" "make" ""
## - Pandoc >= 3.1
check_version "--version" "3.1" "pandoc" ", see <https://pandoc.org> to install"
## - Python >= 3.10
check_version "--version" "3.12" "python3" ", see <https://python.org> to install"
## - PageFind >= v1.0.4
check_version "--version" "1.0.4" "pagefind" ", see <https://pagefind.app> to install"
## - jq >= v1.7
check_version "--version" "1.7" "jq" ", see <https://jqlang.github.io/jq/> to install"
echo "Success! You appear to have the software needed to rebuild this website"