Overhaul install script
Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
parent
ce2413484c
commit
b2e45c8af1
26 changed files with 692 additions and 407 deletions
5
.install/lib/lib.sh
Normal file
5
.install/lib/lib.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
declare LIB_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
source "${LIB_DIR}/output.sh"
|
55
.install/lib/output.sh
Executable file
55
.install/lib/output.sh
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
RESET="$(tput sgr0)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
RED="$(tput setaf 1)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
DEFAULT="$(tput op)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BOLD="$(tput bold)"
|
||||
|
||||
output::log() {
|
||||
echo -e " ● ${1}" |& tee -a "${INSTALL_LOG}"
|
||||
}
|
||||
|
||||
output::debug() {
|
||||
if [ -n "${INSTALL_DEBUG}" ]; then
|
||||
tee -a "${INSTALL_LOG}"
|
||||
else
|
||||
cat > "${INSTALL_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
output::list() {
|
||||
for element in "${@}"; do
|
||||
echo -e " - ${element}"
|
||||
done
|
||||
}
|
||||
|
||||
output::success() {
|
||||
echo -e " ${GREEN}●${DEFAULT} ${1}" |& tee -a "${INSTALL_LOG}"
|
||||
}
|
||||
|
||||
output::question() {
|
||||
printf " ${YELLOW}${1}${DEFAULT}" |& tee -a "${INSTALL_LOG}"
|
||||
}
|
||||
|
||||
output::error() {
|
||||
echo -e " ${RED}✘${DEFAULT} ${1}" |& tee -a "${INSTALL_LOG}"
|
||||
}
|
||||
|
||||
output::section() {
|
||||
echo -e "\n${BOLD}-- ${1} --${RESET}" |& tee -a "${INSTALL_LOG}"
|
||||
}
|
||||
|
||||
output::prompt() {
|
||||
output::question "${1} [y/N] "
|
||||
read -n 1 -r
|
||||
echo ""
|
||||
|
||||
if [[ ${REPLY} =~ ^[yY]$ ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue