forked from vendasta/setup-new-computer-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.sh
41 lines (34 loc) · 964 Bytes
/
functions.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
#===============================================================================
# Functions
#===============================================================================
printHeading() {
printf "\n\n\n\e[0;36m$1\e[0m \n"
}
printDivider() {
printf %"$COLUMNS"s |tr " " "-"
printf "\n"
}
printError() {
printf "\n\e[1;31m"
printf %"$COLUMNS"s |tr " " "-"
if [ -z "$1" ] # Is parameter #1 zero length?
then
printf " There was an error ... somewhere\n" # no parameter passed.
else
printf "\n Error Installing $1\n" # parameter passed.
fi
printf %"$COLUMNS"s |tr " " "-"
printf " \e[0m\n"
}
printStep() {
printf %"$COLUMNS"s |tr " " "-"
printf "\nInstalling $1...\n";
$2 || printError "$1"
}
exitscript () {
# Exit the script with an error, cleaning up resources along the way
local errorcode="${1:-1}"
shift
echo " Error: $@\n"
exit $errorcode
}