-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.sh
48 lines (42 loc) · 1.17 KB
/
config.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
#!/usr/bin/env bash
set -euo pipefail
LATEST_VERSION=9
function ask_question {
read -n 1 -r -p "${1} (y/n) " "$2"
# move to new line
echo
if [[ "${!2}" =~ ^[Yy]$ ]]; then
if [[ "$2" != "CONFIRM" ]]; then
echo "$2=y" >> ./saved-config.sh
fi
else
unset "$2"
fi
}
function setup_config {
while [[ -z ${CONFIRM+x} ]]; do
rm -f ./saved-config.sh
echo "#!/usr/bin/env bash" >> ./saved-config.sh
ask_question "Graphical system?" GRAPHICAL
[[ ${GRAPHICAL+x} ]] && ask_question "Using Intel iGPU?" INTEL_GPU
[[ ${GRAPHICAL+x} ]] && ask_question "Using AMD GPU?" AMD_GPU
[[ ${GRAPHICAL+x} ]] && ask_question "Using NVIDIA GPU?" NVIDIA_GPU
ask_question "User only (skip ALL package installs and gloabl config)?" USER_ONLY
ask_question "Confirm answers?" CONFIRM
echo
done
# redo bootstrap if new version
unset BOOTSTRAP
# output last so config is redone if interrupted
echo "VERSION=${LATEST_VERSION}" >> ./saved-config.sh
}
if [[ -f ./saved-config.sh ]]; then
source ./saved-config.sh
if [[ -z ${VERSION+x} ]]; then
setup_config
elif (( $VERSION < $LATEST_VERSION )); then
setup_config
fi
else
setup_config
fi