-
Notifications
You must be signed in to change notification settings - Fork 0
/
framework.sh
executable file
·148 lines (129 loc) · 3.11 KB
/
framework.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env bash
#
# +----------------------------------------------------------------------------+
# | framework.sh |
# +----------------------------------------------------------------------------+
# | Copyright © 2019 Waldemar Schroeer |
# | waldemar.schroeer(at)rz-amper.de |
# +----------------------------------------------------------------------------+
echo "2"
# +----- Variables ------------------------------------------------------------+
RED=$(tput setaf 1)
BRIGHT=$(tput bold)
NORMAL=$(tput sgr0)
YN="(Yes|${BRIGHT}No${NORMAL}) >> "
# +----- Functions ------------------------------------------------------------+
echo_equals() {
counter=0
while [ $counter -lt "$1" ]; do
printf '='
(( counter=counter+1 ))
done
}
echo_title() {
title=$1
ncols=$(tput cols)
nequals=$(((width-${#title})/2-1))
tput setaf 4 0 0
echo_equals "$nequals"
tput setaf 6 0 0
printf " %s " "$title"
tput setaf 4 0 0
echo_equals "$nequals"
tput sgr0
echo
}
echo_Right() {
text=${1}
echo
tput cuu1
tput cuf "$((${width} - 1))"
tput cub ${#text}
echo "${text}"
}
echo_OK() {
tput setaf 2 0 0
echo_Right "[ OK ]"
tput sgr0
}
echo_Done() {
tput setaf 2 0 0
echo_Right "[ Done ]"
tput sgr0
}
echo_NotNeeded() {
tput setaf 3 0 0
echo_Right "[ Not Needed ]"
tput sgr0
}
echo_Skipped() {
tput setaf 3 0 0
echo_Right "[ Skipped ]"
tput sgr0
}
echo_Failed() {
tput setaf 1 0 0
echo_Right "[ Failed ]"
tput sgr0
}
echo_Error_Msg() {
echo -n -e "\n${RED} [ Error ]${NORMAL} ${1}\n\n"
}
antwoord() {
read -p "${1}" antwoord
if [[ ${antwoord} == [yY] || ${antwoord} == [yY][Ee][Ss] ]]; then
echo "yes"
else
echo "no"
fi
}
display_Notice() {
echo "3"
clear
tput setaf 6
cat ${cdir}/$1
tput sgr0
proceed="$(antwoord "Do you want to proceed? ${YN}")"
}
clear_Logfile() {
if [[ -f ${logfile} ]]; then
rm ${logfile}
fi
}
get_User() {
if ! [[ $(id -u) = 0 ]]; then
echo_Error_Msg "This script must be run as root."
exit 1
fi
}
get_OperatingSystem() {
os=$(uname -s)
kernel=$(uname -r)
architecture=$(uname -m)
}
get_Distribution() {
if [[ -f /etc/os-release ]]; then
. /etc/os-release
distribution=$NAME
version=$VERSION_ID
case ${ID} in
rhel|centos)
packagelistext="${ID}.${VERSION_ID::1}"
;;
fedora)
packagelistext="${ID}.${VERSION_ID}"
;;
esac
echo -e "\nSeems to be:"
echo -e " ${distribution} ${version} ${kernel} ${architecture}\n"
else
echo_Error_Msg "I need /etc/os-release to figure what distribution this is."
exit 1
fi
}
LogfileLocation() {
echo -n -e "\nLogfile: ${logfile}\r"
echo_OK
}
# +----- Main -----------------------------------------------------------------+
exit 0