-
Notifications
You must be signed in to change notification settings - Fork 3
/
check-prerequisites.sh
79 lines (66 loc) · 2.46 KB
/
check-prerequisites.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
#!/bin/bash
# bash-gorillas is a demake of QBasic GORILLAS completely rewritten
# in Bash.
# Copyright (C) 2013 Istvan Szantai <szantaii at sidenote dot hu>
#
# 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 3 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 (LICENSE).
# If not, see <http://www.gnu.org/licenses/>.
# Check availability of necessary programs and minimum terminal size
check_prerequisites()
{
# Check if 'tput' command is available
which tput > /dev/null
# If 'tput' is not available, then print
# error message and exit with status code '2'
if (($? != 0))
then
# Restore terminal screen
tput rmcup
printf "Your system is missing the program 'tput' which is necessary \
for bash-gorillas\nto run. 'tput' can be found in the following packages on \
the following distributions:\n Distribution Package name\n\
---------------------------------\n Arch Linux ncurses\n \
Debian ncurses-bin\n Fedora ncurses\n \
openSUSE ncurses-utils\n Ubuntu ncurses-bin\n"
exit 2
fi
# Check if 'bc' command is available
which bc > /dev/null
# If 'bc' is not available, then print
# error message and exit with status code '2'
if (($? != 0))
then
# Restore terminal screen
tput rmcup
printf "Your system is missing the program 'bc' which is necessary \
for bash-gorillas\nto run. 'bc' can be found in the 'bc' package on most Linux \
distributions.\n"
exit 2
fi
# Check if terminal has at least $min_term_width columns and
# $min_term_height lines
#
# If either terminal width or height is less than
# $min_term_width and $min_term_height print error message
# and exit with status code '3'
if ((term_width < min_term_width || term_height < min_term_height))
then
# Restore terminal screen
tput rmcup
printf "bash-gorillas needs a terminal with size of at least \
${min_term_width}x${min_term_height} (${min_term_width} columns, \
${min_term_height} lines).\n"
exit 3
fi
}